LoginSignup
6
5

More than 3 years have passed since last update.

macOSのプロンプトにGitのブランチ名を表示する

Last updated at Posted at 2017-05-15

コマンドラインでGitのブランチ名が見えているとなにかと便利なので。

.bash_profile
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh

PS1='\[\e[1;36m\][\h: \W]$\[\e[1;32m\]$(__git_ps1)\[\e[0m\] '

結果

ブランチ名が表示されました。
これでコミット先のブランチを間違える可能性が減りますね。

git_prompt.png

こちらを参考にしました

http://qiita.com/fernet/items/4dcb6f82520d87227121
http://qiita.com/calpo22/items/8ce258e1f03453a86609

6
5
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
6
5