Search code examples
bashps1

Characters in PS1 variable


My PS1 variable :

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

I understand everything except the first part \[\e]0;\u@\h: \w\a\]. What is the purpose of this part? It doesn't seem to affect my prompt. In fact my question could be reduce even more to this part : \e]0;


Solution

  • Escape ]0 (the \e]0 you're interested in) modifies an XTerm title bar. More at this link: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/xterm-title-bar-manipulations.html

    Everything inside the []:

    \[\e]0;\u@\h: \w\a\]
    

    Is marked as a non-printing character, so bash can do the right thing with line wrapping, etc. In this case that means "put the current user@hostname and current working directory in the title bar". The \a is a bell character.