事前準備
$ git version
Git のバージョンを確認し、Apple git の場合は、homebrew の git にアップデートしておく。
$ brew install git
gitcomprication.bash を移動する
gitcomprication.bash を 指定のディレクトリに移動する。
$ mkdir -p /usr/local/git/contrib/completion/
$ cd usr/local/Cellar/git/{gitのversionの数字}/etc/bash_completion.d
$ mv git-completion.bash /usr/local/git/contrib/completion/
~/.bashrc に設定する
# git settings
source /usr/local/git/contrib/completion/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
~/.bashrc を反映させる
$ source ~/.bashrc
※-bash: __git_ps1: command not found エラーが出た場合
# git-completion.bash の前に追加で git-prompt.sh を読み込ませる
source /usr/local/etc/bash_completion.d/git-prompt.sh
source /usr/local/etc/bash_completion.d/git-completion.bash
この手順でGit のブランチ名が出るようになりました\( ^0^ )/
参考
http://38ch.hateblo.jp/entry/2017/02/12/180145
https://sue445.hatenablog.com/entry/2012/08/30/005627