メモ
linuxのコマンドプロンプトの表示を環境によって変えたかったり、gitのブランチ名を表示させたかったりしたので
変更の仕方をメモする
▼ 現状のプロンプトの設定を確認
echo $PS1
▼ 表示内容の調整
ユーザー名[環境名]@今いる階層(gitブランチ名)$
▼ gitブランチ名表示処理を用意
$ cd ~
$ vi .git_branch_name.sh
function git_branch_name {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
▼ .bashrcに追記
source ~/.git_branch_name.sh
export PS1='\[\033[32m\]\u[環境名]\[\033[31m\]@\[\033[32m\]\w\[\033[31m\]$(git_branch_name)\[\033[00m\]\$ '