From the default .bashrc
is this:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
The result is examined by issuing the echo command:
$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
It appears that the ${debian_chroot:+($debian_chroot)}
conditional insertion will be performed for the command line prompt but not for the terminal title. It appears the .bashrc
author intended it to be displayed in both places just to the left of user@host
but in fact it did not make it into both places. The evaluation of debian_chroot
happened in defining PS1 but it was not meant to be evaluated at that time, rather it was meant to be evaluated at the time of prompting. The root of the problem is that when building strings ""
quoting evaluates and ''
quoting does not. The evaluation was early because the whole thing enclosed in \[
\]
was meant for the title. Is interpretation correct?
debian_chroot
was set, its value would be in the title-setting part. – muru Dec 30 '15 at 01:04debian_chroot=foo bash
. – muru Dec 30 '15 at 01:14debian_chroot
is set. – muru Dec 30 '15 at 01:28