All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 # Fancy setting of the xterm title
5 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
8 # Source repository: git://git.madduck.net/etc/zsh.git
10 # Based on http://www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
16 print -nR $'\033k'$1$'\033'\\
17 print -nR $'\033]0;'$2$'\a'
20 print -nR $'\033]0;'$*$'\a'
25 __get_session_flags() {
26 [ -n "$SSH_CONNECTION" ] || return
28 [ -n "$DISPLAY" ] && flags="${flags}x"
29 [ -n "$SSH_AUTH_SOCK" ] && flags="${flags}a"
30 [[ $SSH_CLIENT = *:* ]] && flags="${flags}6"
31 [ -n "$flags" ] && echo "[${flags}]"
34 __get_standard_prompt() {
35 [[ -z $SSH_CLIENT ]] || print -nP "%m"
36 print -P "%#%25\<..\<%~ $(__get_session_flags)"
39 _set_plain_xterm_title() {
40 __set_xterm_title "$(__get_standard_prompt)"
42 precmd_functions+=_set_plain_xterm_title
44 _set_cmd_xterm_title () {
45 local -a cmd; cmd=(${(z)1}) # Re-parse the command line
47 # Construct a command that will output the desired job number.
49 fg) if (( $#cmd == 1 )); then
50 # No arguments, must find the current job
51 cmd=(builtin jobs -l %+)
53 # Replace the command name, ignore extra args.
54 cmd=(builtin jobs -l ${(Q)cmd[2]})
56 %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
57 *) # Not resuming a job,
58 __set_xterm_title $cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
59 return;; # so we're all done
62 local -A jt; jt=(${(kv)jobtexts}) # Copy jobtexts for subshell
64 # Run the command, read its output, and look up the jobtext.
65 # Could parse $rest here, but $jobtexts (via $jt) is easier.
68 cmd=(${(z)${(e):-\$jt$num}})
69 __set_xterm_title $leader$cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
72 preexec_functions+=_set_cmd_xterm_title