From c1446b4750a31506daba7fc7d41957dd515e8022 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Sat, 6 Jul 2019 12:10:30 -0400 Subject: [PATCH] Automatic title: Replace fg with description from jobs --- lib/termsupport.zsh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index aa14f3f07..a74ad9922 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -72,7 +72,19 @@ function omz_termsupport_preexec { local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]: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)