# change terminal title

I want to make a shell alias that starts a certain program and also changes the title of the terminal to the name of the program. How can I do that?

In case it matters, I am running the terminal on Ubuntu and connecting to a Debian server via ssh.

-

In Bash, I use the following trap command in the last line of my .bashrc to echo all commands to the titlebar.

# trap commands and echo them to xterm titlebar. Must be last line.
trap 'echo -ne "\033]0;$BASH_COMMAND$USER@${HOSTNAME}>$(pwd)\007"' DEBUG


So if you execute sleep 10, you will see your titlebar change to sleep 10 for the duration of the command, after which it will change back to user@host>pwd.

-
And for zsh, see Title and Hardstatus in the zsh wiki. –  Gilles Apr 13 '11 at 19:28

Most terminals recognize a certain escape sequence as an attempt to change the title, so this will work:

\$ alias foo-with-title='echo -ne "\033]0;foo\007"; foo'

-
Where is this documented? –  enzotib Mar 1 '12 at 15:00