if [ $TERM = "screen" ] then function title { # Use these two for GNU Screen: local myhost myhost=${$(hostname)//.*/} print -nR $'\033k'$myhost$'\033'\\ print -nR $'\033]0;'$1$'\a' } preexec () { emulate -L zsh local -a cmd; cmd=(${(z)1}) title ${$(hostname)//.*/} "$cmd[1,-1]" } eval "function precmd () { $functions[precmd] title \$PWD }" fi