How to change Terminator title terminal title, ZSH on Debian?

The following worked for me to rename each tab in gnome-terminal. I added the following code to my ~/.zshrc file.

precmd () { print -Pn "\e]0;$TITLE\a" }
title() { export TITLE="$*" }

This creates a title function to rename each tab.

Note, if you are using oh-my-zsh you will need to disable its auto title command. You can do that by uncommenting this line in your ~/.zshrc file:

DISABLE_AUTO_TITLE="true"

You set your window title with the xtem escape sequences, in most implementations the first will work best:

echo -en "\e]0;string\a" #-- Set icon name and window title to string
echo -en "\e]1;string\a" #-- Set icon name to string
echo -en "\e]2;string\a" #-- Set window title to string

EDIT: The above only sets the title once. To set zsh to always display the sting in the title you add the following to your .zprofile in your home directory:

case $TERM in
    xterm*)
        precmd () {print -Pn "\e]0;string\a"}
        ;;
esac

This should work regardless of the shell used:

printf "\033];%s\07\n" "hello world"