DISABLE_AUTO_TITLE="true" function precmd_set_title { title="" if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then title+="$USER@$HOST:" fi location="${PWD/#"$HOME"/~}" title+="$location" echo -ne "\e]2;$title\a" } function preexec_set_title { title="" if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then title+="$USER@$HOST:" fi title+="$2 - " location="${PWD/#"$HOME"/~}" title+="$location" echo -ne "\e]2;$title\a" } autoload -Uz add-zsh-hook add-zsh-hook precmd precmd_set_title add-zsh-hook preexec preexec_set_title