ensure that Profile -> Terminal -> Terminal may report title is checked
Then add the following to .zshrc
# set iterm title
iterm_title() {
echo -ne "\e]1;$1\a"
}
# set iterm tab title on prompt
iterm_title_pwd() {
# shorten path
p="${PWD/#$HOME/~}"
# replace parent directories with first letter but not the last one
p=$(echo $p | sed -E 's|([^/])[^/]*\/|\1/|g')
iterm_title "$p"
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd iterm_title_pwd