Question

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;

Était-ce utile?

La 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.

Autres conseils

You can also use the escape sequence to color your prompt.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top