LoginSignup
6
3

More than 3 years have passed since last update.

ターミナルにブランチを表示する

Last updated at Posted at 2019-07-21

$git branch -aをしなくても、ターミナルにブランチが表示されるようにしたい。
111.png

以下を.bashrcファイルに書き込みすればOK

source /usr/local/etc/bash_completion.d/git-prompt.sh
source /usr/local/etc/bash_completion.d/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\n\$ '

手順

.bashrcファイルの開き方

$code .bashrc

.bashrcに追加で記述

source /usr/local/etc/bash_completion.d/git-prompt.sh
source /usr/local/etc/bash_completion.d/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\n\$ '

.bashrcの内容を読み込み

$source .bashrc

完了!

参考
https://bottoms-programming.com/archives/terminal-branch-name.html
(下の記事では、$が改行されないバージョン)
https://qiita.com/lemtosh469/items/334ff76366e054a3a3aa

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