This commit is contained in:
Diogo Kersting 2017-05-17 08:15:29 +00:00 committed by GitHub
commit 5d086f4f26

View file

@ -25,6 +25,9 @@
# jobs are running in this shell will all be displayed automatically when
# appropriate.
# Comment this to disable right side features like "$pipestatus return codes"
ENABLE_RPROMPT=y
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
@ -198,6 +201,22 @@ prompt_virtualenv() {
fi
}
prompt_code_returns() {
local show_returns=''
for n in $pipestat ; do
[[ "0" != "$n" ]] && show_returns=y
done
if [ "$show_returns" ] ; then
for n in $pipestat ; do
if [[ "0" != "$n" ]] ; then
prompt_segment red white $n
else
prompt_segment black blue $n
fi
done
fi
}
# Status:
# - was there an error
# - am I root
@ -225,4 +244,11 @@ build_prompt() {
prompt_end
}
## Right side prompt
build_rprompt() {
pipestat=($pipestatus)
prompt_code_returns
}
[[ "$ENABLE_RPROMPT" == "y" ]] && RPROMPT='%{%f%b%k%}$(build_rprompt) '
PROMPT='%{%f%b%k%}$(build_prompt) '