LoginSignup
0
2

More than 5 years have passed since last update.

MacのターミナルでGitのブランチ名を表示 + 色付け

Posted at

brewでインストール

$ brew install git

下記ファイルを移動

$ cd /usr/local/Cellar/git/2.17.0/etc

$ mv git-prompt.sh /usr/local/git/contrib/completion/

$ mv git-completion.bash /usr/local/git/contrib/completion/

.bashrcに記述

$ sudo vim ~/.bashrc

# git settings
source /usr/local/git/contrib/completion/git-prompt.sh
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
0
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
0
2