From 168c0372ae76381ca0de343783c9a4f2f87a4df9 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Sun, 15 Feb 2009 22:50:14 +0100 Subject: [Functions] tries to get real process name when calling back a job to foreground with 'fg'... TBC --- 01_Functions.zsh | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/01_Functions.zsh b/01_Functions.zsh index d598023..842e4d6 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -24,24 +24,34 @@ cmd_exists () term_title() { - [[ -t 1 ]] && - case $TERM in - sun-cmd) - print -Pn "\e]l%n@%m %~$@\e\\" # Never tested.. - ;; - *term*|rxvt*|putty) - print -Pn "\e]0;%n@%m (%l) %~$@\a" # Sets term title - ;; - screen) - # hardstatus - print -Pn "\e]2;[SCREEN #n] ?u(u) ?%n@%m (%l) %~$@\a" # Sets hardstatus line (term title) - # caption - [ $# -gt 0 ] && shift # discards the first arg, which is the separator, if any - print -Pn "\ek${@:-%~}\e\\" - ;; - *) - ;; - esac + + # Jobs + typeset -A command + for word in ${=2} ; command[$#comand]=$word + if [ "$command[0]" = "fg" ] + then + lastjob=$(ps ft `tty` | grep "[0-9]\+[[:blank:]]\+`tty | sed 's/\/dev\///'`[[:blank:]]\+T.\? \+.:.. \\\_ " | tail -n1 | cut -c32-) + set $1 $lastjob + fi + + [[ -t 1 ]] && + case $TERM in + sun-cmd) + print -Pn "\e]l%n@%m %~$@\e\\" # Never tested.. + ;; + *term*|rxvt*|putty) + print -Pn "\e]0;%n@%m (%l) %~$@\a" # Sets term title + ;; + screen) + # hardstatus + print -Pn "\e]2;[SCREEN #n] ?u(u) ?%n@%m (%l) %~$@\a" # Sets hardstatus line (term title) + # caption + [ $# -gt 0 ] && shift # discards the first arg, which is the separator, if any + print -Pn "\ek${@:-%~}\e\\" + ;; + *) + ;; + esac } preprint() -- cgit v1.2.3