
In xterm, the following escape sequence can change the title of terminal windows:
ESC]0;title_stringBELwhere ESC and BEL is 033 and 007 (in octal ASCII) respectively. For example, we can use the following echo command to set the terminal title as "Hello World.":echo -ne "\033]0;Hello World.\007"However, if you issue the above command in your terminal, the title may not be changed. It is because the
PROMPT_COMMAND environment variable have already been defined for changing the terminal title. The value in PROMPT_COMMAND environment variable will be executed as command prior to issuing each prompt. In my terminal, the value of PROMPT_COMMAND is:echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"In the above command,
${USER} and ${HOSTNAME} is the username and hostname respectively, while the ${PWD/$HOME/~} is the current working directory with $HOME abbreviated as ~. Therefore, in my terminal, the title will be changed to show username, hostname and current working directory, e.g.:ahlam@oxygen: ~/downloadTo customize your terminal title, you should update the value of
PROMPT_COMMAND, e.g.:export PROMPT_COMMAND='echo -ne "\033]0;Hello World.\007"'Reference:
How to change the title of an xterm
man bash
