exit code in bash prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps1_prompt() { | |
local ps1_exit=$? | |
if [ $ps1_exit -eq 0 ]; then | |
#ps1_status=`echo -e "\[\033[32m\]"'\$'"\[\033[0m\]"` | |
ps1_status='\$' | |
else | |
ps1_status=`echo -e "\[\033[1;31m\]"'\$'"\[\033[0m\]"` | |
fi | |
ps1_git='' | |
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\[\033[01;34m\]\w\[\033[00m\]${ps1_git}${ps1_status} " | |
PS1="\[\e[1;31m\][\u@\h \w] (${ps1_exit}) \$\[\e[0m\] " | |
} | |
# preserve earlier PROMPT_COMMAND entries... | |
PROMPT_COMMAND="ps1_prompt;$PROMPT_COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment