Skip to content

Instantly share code, notes, and snippets.

@metalefty
Created June 19, 2013 07:42
Show Gist options
  • Save metalefty/5812350 to your computer and use it in GitHub Desktop.
Save metalefty/5812350 to your computer and use it in GitHub Desktop.
直前のコマンドの終了ステータスでプロンプトの色を変更する
# bashrc の中で実行するコマンドが $? を上書きする前に参照するために最初の方に書く
# colored prompt
RETURN_CODE='\[$(if [ $? -eq 0 ]; then echo -en \e[32m ; else echo -en \e[31m; fi; echo -en █\e[m;)\]'
#
# 途中に git-completion や bash-completion によるプロンプトの変更をお好みで挟んで
#
# 最後に終了ステータスによって切り替えたものをくっつける
PS1="${RETURN_CODE}${PS1}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment