Skip to content

Instantly share code, notes, and snippets.

@digitalm
Last active October 26, 2017 06:59
Show Gist options
  • Save digitalm/223fe821ff97d8eed903309c35242a69 to your computer and use it in GitHub Desktop.
Save digitalm/223fe821ff97d8eed903309c35242a69 to your computer and use it in GitHub Desktop.
bash/zsh git-completion support

概要

  1. 補完用シェルスクリプトを任意の場所に置く
/Users/mika/.git-completion.sh
  1. 起動時に読み込む

手順

  1. スクリプトをコピーしてくる
curl -o ~/.git-completion.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
  1. 起動時に読み込むように設定する
$ vi ~/.bash_profile

書き込む

# git completion to console
source ~/.git-completion.sh
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

esc 押す 保存して閉じる

$ :wq!
  1. 設定できたかの確認 現在のセッションで読み込み直す
source ~/.git-completion.sh

gitリポジトリのあるところに移動する cd ~/dev/

表示されているか見る mika@Sawara-743:~/dev/manageee (fix-scroll-loop *)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment