summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2009-02-15 22:50:14 +0100
committerHugues Hiegel <hugues@hiegel.fr>2009-02-15 22:50:14 +0100
commit168c0372ae76381ca0de343783c9a4f2f87a4df9 (patch)
tree7312c4ed94535c680e951139d92dffebacc7c571
parentf4780eb51a5e9f85e1031105f850357907f0f94a (diff)
[Functions] tries to get real process name when calling back a job to foreground with 'fg'... TBC
-rw-r--r--01_Functions.zsh46
1 files 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()