Commit c1446b47 authored by Erik Demaine's avatar Erik Demaine
Browse files

Automatic title: Replace fg with description from jobs

parent b259cdf7
...@@ -72,7 +72,19 @@ function omz_termsupport_preexec { ...@@ -72,7 +72,19 @@ function omz_termsupport_preexec {
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}" local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<' if [[ "$CMD" = fg ]]; then
# replace fg, possibly with argument, with description from jobs
local JOB
if [[ ${(z)1} = fg ]]; then # no arguments
JOB="$(jobs %%)"
else # arguments
JOB="$(jobs ${${(z)1}[2]})"
fi
JOB="${${(z)JOB}[4,$]}" # trim job number, +, pid, status
title ${JOB:gs/%/%%} ${JOB:gs/%/%%}
else
title '$CMD' '%100>...>$LINE%<<'
fi
} }
precmd_functions+=(omz_termsupport_precmd) precmd_functions+=(omz_termsupport_precmd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment