LoginSignup
2
2

More than 3 years have passed since last update.

Git補完 bash

Last updated at Posted at 2019-09-06

hub

$ brew install hub
$ curl https://raw.githubusercontent.com/github/hub/master/etc/hub.bash_completion.sh -o ~/.hub.bash_completion.sh
$ chmod a+x ~/.hub.bash_completion.sh

git-completion

$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
$ chmod a+x ~/.git-completion.bash

git-prompt

$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
$ chmod a+x ~/.git-prompt.sh

.bashrc か .bash_profile を編集

~/.bashrc

eval "$(hub alias -s)"
alias git='hub'
alias gco='git checkout'
source ~/.git-completion.bash
source ~/.hub.bash_completion.sh
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWSTASHSTATE=1
PS1='\W $(__git_ps1 "[%s]") $ '

確認

$ source ~/.bashrc

別タブで

カレントディレクトリ (ブランチ名) $

カレントディレクトリ (ブランチ名) $ git p
p              pr             pull           pull-request   push 

プロンプトに現在のブランチとステータスが追加されGit(hub)コマンドの補完も効いていると思います。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2