summaryrefslogtreecommitdiff
path: root/lib/termsupport.zsh
diff options
context:
space:
mode:
authorErik Demaine <edemaine@mit.edu>2019-07-07 10:48:36 -0400
committerErik Demaine <edemaine@mit.edu>2019-07-07 10:48:36 -0400
commit902e3172c9b991ca0995a0dcd658caa29b918d8e (patch)
tree5988bc8683d91729f61ec040dada1bab3abae08c /lib/termsupport.zsh
parentc1446b4750a31506daba7fc7d41957dd515e8022 (diff)
downloadzsh-902e3172c9b991ca0995a0dcd658caa29b918d8e.tar.gz
zsh-902e3172c9b991ca0995a0dcd658caa29b918d8e.tar.bz2
zsh-902e3172c9b991ca0995a0dcd658caa29b918d8e.zip
Avoid error messages when there is no job
Diffstat (limited to 'lib/termsupport.zsh')
-rw-r--r--lib/termsupport.zsh17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index a74ad9922..59a1efb02 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -72,19 +72,22 @@ function omz_termsupport_preexec {
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}"
+ # replace fg, possibly with argument, with description from jobs
if [[ "$CMD" = fg ]]; then
- # replace fg, possibly with argument, with description from jobs
local JOB
if [[ ${(z)1} = fg ]]; then # no arguments
- JOB="$(jobs %%)"
+ JOB="$(jobs %% 2>/dev/null)"
else # arguments
- JOB="$(jobs ${${(z)1}[2]})"
+ JOB="$(jobs ${${(z)1}[2]} 2>/dev/null)"
+ fi
+ if [[ $? -eq 0 ]]; then
+ JOB="${${(z)JOB}[4,$]}" # trim job number, +, pid, status
+ title ${JOB:gs/%/%%} ${JOB:gs/%/%%}
+ return
fi
- JOB="${${(z)JOB}[4,$]}" # trim job number, +, pid, status
- title ${JOB:gs/%/%%} ${JOB:gs/%/%%}
- else
- title '$CMD' '%100>...>$LINE%<<'
fi
+
+ title '$CMD' '%100>...>$LINE%<<'
}
precmd_functions+=(omz_termsupport_precmd)