function title { local tmp tmp=(${(f)*}) printf "\e]0;%s\a" "${tmp[1]}" } case "$TERM" in (*xterm*|rxvt*) function title_precmd { title "${(%):-[%n@%m] %~}" } function title_preexec { title "$1" } ;; (*) function title_precmd {} function title_preexec {} ;; esac autoload -U add-zsh-hook add-zsh-hook precmd title_precmd add-zsh-hook preexec title_preexec