Add previous non-zero status to ps1

This commit is contained in:
Tony Grosinger 2021-11-04 12:46:19 -07:00
parent f17b5f7091
commit d2f48f8bef

10
.bashrc
View File

@ -97,6 +97,14 @@ else
c_git_dirty=
fi
prev_status_prompt () {
status=$?
if [ $status -ne 0 ]; then
red=`tput setaf 1; tput bold`
echo " -- ${red}${status}${c_reset}"
fi
}
git_prompt () {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
@ -134,6 +142,6 @@ kubectl_context() {
if [ "$BASH" != "" ]; then
# Prompt
PS1="\n╔ \w\$(git_prompt) \$(kubectl_context)\n╚ \h\$ "
PS1="\n╔ \w\$(prev_status_prompt)\$(git_prompt) \$(kubectl_context)\n╚ \h\$ "
fi