Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On RHEL6 and CentOS 6, /etc/bashrc sets PROMPT_COMMAND here:

case $TERM in
    if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
    if [ -e /etc/sysconfig/bash-prompt-screen ]; then
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'

All of these options, as far as I know, are printed invisibly. What is the use of this?

I know that PROMPT_COMMAND is to be executed before display the prompt (PS1 usually). I do not understand why echoing something that is not visible is of any use.

share|improve this question
up vote 9 down vote accepted

\033 is the octal code for the Esc (Escape) character, which is a good hint that the echoed strings in your PROMPT_COMMAND are terminal control sequences. Both sequences in your examples look like they set the terminal title to user@host:pwd.

The first case, xterm* sets the window name and icon title. For a detailed explanation, look at the list of xterm control sequences and scroll down until you find OSC P s; P t; ST under Operating System Controls (OSC is ESC ] and ST is ESC \).

The second case is for the screen terminal emulator, and in the list of screen control sequences, it explains that ESC _ sets screen's hardstatus (simply put, that's the title of the screen window).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.