Giter VIP home page Giter VIP logo

my-git-bash's Introduction

Git Bash

My Git Bash

GitHub

目录

开始使用

以下所有命令都需要在「以管理员身份运行」的 Git Bash 中执行。

先克隆仓库然后 cd 到仓库目录中再执行下面的所有操作。

$ git clone https://github.com/xnng/my-git-bash.git
$ cd my-git-bash

gitee 镜像:

$ git clone https://gitee.com/xnng/bash.git
$ cd bash

安装字体

此字体可解决 unicode 字符乱码问题,执行命令后,将字体文件拖放进去即可完成安装。

$ start c://Windows//Fonts && start %cd%/fonts

Git Bash

安装主题

$ cp .minttyrc ~ && cp git-prompt.sh /etc/profile.d

Git Bash

安装主题后同时会开启复制粘贴快捷键:Ctrl + Shift + C/V,需要 Git Bash 版本大于 2.20.0 才可以使用。

安装 Tmux

tmux 是一个终端复用神器,可实现单窗口多标签页、分屏等功能,借助插件还能保存和一键恢复窗口数据。

tmux for windows 源地址:https://github.com/hongwenjun/tmux_for_windows

$ cp tmux/bin/* /usr/bin && cp tmux/share/* /usr/share -r

同时开启鼠标操作:

$ echo -e "setw -g mouse\nset-option -g mouse on" > ~/.tmux.conf

tmux 使用:https://juejin.im/post/5a8917336fb9a0633e51ddb9

tmux 基本操作

Tmux 基本操作演示

tmux 分屏

Tmux 分屏演示

安装 wget 和 tree 命令

$ cp tools/* /usr/bin

终端快捷键

附 Git Bash 终端快捷键

按键 效果
Alt + Enter 全屏
关闭窗口 Ctrl + D(需当前行没有字符才可用)
清屏 Ctrl + L
打开终端 右键快捷方式,在属性中自行设置
复制粘贴 Ctrl + Shift + C/V(v2.20.0 版本后才支持)

其他快捷键遵循 Bash 标准快捷键,例如 Ctrl + R 搜索历史命令、exit 退出终端、clearreset 清屏、Ctrl + E/A 光标到行首尾,等等可自行搜索。

个人设置

以下为我的个人配置备份,请勿模仿。

安装我的 alias

$ cp .bash_profile ~

安装我的 Tmux 配置

$ cp tmux/.tmux.conf ~

安装 tmux 自动恢复 session 和持久化 session 插件

插件会使新建 tmux 工作区的时间明显变长,非必要情况下无需使用插件。

$ mkdir -p ~/.tmux/plugins/tpm
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

将注释的部分全部打开,按 prefix I 安装插件。

安装我的 git 配置

$ cp .gitconfig ~

其它

在 VSCode 中配置 Git Bash

在 VSCode 中使用 Git Bash 只需要在 Settings.json 中添加如下两行即可,第一行中 bash.exe 的文件路径需要改成自己的,第二行是非必须配置,不配置无法使用 alias

{
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "terminal.integrated.shellArgs.windows": ["--login", "-i"]
}

Git Bash

解决 win10 快捷键不能秒启动问题

Git Bash 设置了全局快捷键后,可能出现按下快捷键后延迟两秒左右终端才打开的现象,只需要在服务中禁用掉 superFetch 即可,此服务在比较新的 win10 上改名为了 sysMain,禁用服务后重启操作系统生效

解决某些命令会卡住不动或无法上下选择脚手架选项的问题

使用某些命令,如 pythonmongomysqlredis-cli 时会发现有卡住不动的现象,只需要在命令前面加上 winpty 即可,每次之性命都都要加这个会比较麻烦,可以设置 alias 重写命令,例如:

alias wsl='winpty wsl'
alias mysql='winpty mysql -uroot -p'
alias mongo='winpty mongo'
alias redis-cli='winpty redis-cli'

很多脚手架工具在初始化项目的时候提供了可以上下选择选项的功能,该功能在 git bash 中可用,但是无法显示上下选择的效果,需要在命令前加上 winpty,同时脚手架命令需要加上后缀 .cmd,例如:

alias vue='winpty vue.cmd'

更新日志

  • 2019-04-28

    • 添加解决某些命令会卡住不动或无法上下选择脚手架选项的解决方法
  • 2019-03-25

    • 添加 vscode 配置
    • 添加快捷加启动慢解决方法
  • 2019-03-23

    • 移除一键安装脚本,分离通用和个人配置
    • 新增 tmux 演示 gif 图片
    • 新增快捷键列表
  • 2019-02-03

    • 移除 vim 配置
    • 将命令提示符由 Unicode 字符改为圆点,提高兼容性
    • 修复安装脚本
    • 开启 256 真色支持
    • 优化 tmux 状态栏配色
    • 开启 Ctrl + Shift + C/V 快捷键支持
  • 2018-12-24

    • 新增 tmux 插件使 session 能持久化到本地
    • 终端背景色由绿色修改为灰色
    • 将红色颜色配置由橙色改回红色

my-git-bash's People

Contributors

xnng avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.