In .bashrc
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
I understand ${debian_chroot:+($debian_chroot)}\u@\h: \w
, but not \[\e]0;
. What does it make?
bashescape-charactersprompt
In .bashrc
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
I understand ${debian_chroot:+($debian_chroot)}\u@\h: \w
, but not \[\e]0;
. What does it make?
Best Answer
The
\e]0;
is an escape sequence;\e
is replaced with ASCII 27 (ESC), so the terminal receives the 4 charactersESC ] 0 ;
tells xterm to set icon and title bar, that ends in BEL (\a
).So the sequence
\e]0;STUFFGOESHERE\a
will set the title of the terminal to STUFFGOESHERE. In your example it'll set the title to user/host/path.FWIW, xterm escape sequences are documented at: https://www.x.org/docs/xterm/ctlseqs.pdf