fixed return value display

This commit is contained in:
Paweł Płazieński 2015-12-16 23:00:31 +01:00
parent 9993d2c020
commit a119d1fe2e

29
.zshrc
View File

@ -6,10 +6,12 @@
DEFAULT_USER="nivertius"
EDITOR="vim"
#---------------------------------- Setup -------------------------------------
#---------------------------------- Pre Setup ---------------------------------
autoload colors; colors
LAST_RETURN_VALUE=0
#---------------------------------- Tab completion ----------------------------
# Force a reload of completion system if nothing matched; this fixes installing
@ -175,15 +177,22 @@ prompt_dir() {
prompt_status() {
local symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR"
[[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols "
if [[ $LAST_RETURN_VALUE -ne 0 ]]; then
symbols+="%{%F{red}%}$CROSS"
if [[ $LAST_RETURN_VALUE -ne 1 ]]; then
symbols+="$CROSS $CROSS"
fi
fi
if [[ $(jobs -l | wc -l) -gt 0 ]]; then
symbols+="%{%F{cyan}%}$GEAR"
fi
if [[ -n "$symbols" ]]; then
prompt_segment $PRIMARY_FG default " $symbols "
fi
}
## Main prompt
prompt_main() {
RETVAL=$?
CURRENT_BG='NONE'
prompt_status
prompt_root
@ -361,6 +370,14 @@ REPORTTIME=5
for command in find wget; \
alias $command="noglob $command"
#---------------------------------- Post Setup --------------------------------
store_last_return_value() {
LAST_RETURN_VALUE="$?"
}
precmd_functions=(store_last_return_value $precmd_functions)
#---------------------------------- Machine specific --------------------------
if [[ -r $HOME/.zlocal ]]; then