2013年11月1日金曜日

Git 補完・ブランチ名表示 メモ(2013.11)

git-completionの設定メモ

以前設定したときのメモはこちら
ネタ帳 A.B.C: Git 補完・ブランチ名表示 メモ
http://neta-abc.blogspot.jp/2013/02/git.html

環境

Mac OS X Maverics
Xcode 5.0.1
Git version 1.8.3.4 (Apple Git-47)
(GitはXcode付属のものを使う)

git-completion.bash/git-prompt.shのコピー

下記の2ファイルをホームディレクトリにリネームしてコピーする。
cp /Applications/Xcode.app/Contents/Developer/usr/share/git-core ~/.git-completion.bash
cp /Applications/Xcode.app/Contents/Developer/usr/share/git-core ~/.git-prompt.sh

.bash_profileの設定
if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
fi

if [ -f ~/.git-prompt.sh ]; then
    source ~/.git-prompt.sh
fi

PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

動作確認

下記のコマンドで.bash_profileを再読み込みする。
. .bash_profile

Gitで管理されたディレクトリに移動するとブランチ名が表示され、Gitのコマンド補完が効くようになる。

0 件のコメント:

コメントを投稿