I'm seeing this in my .bashrc
file:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\
[\033[01;34m\]\w\[\033[00m\]\$ '
and I have absolutely no idea what all those escapes codes mean.
I'm seeing this in my .bashrc
file:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\
[\033[01;34m\]\w\[\033[00m\]\$ '
and I have absolutely no idea what all those escapes codes mean.
There are three kinds of escape codes in there: bash parameter expansion, bash prompt expansion, and terminal escape codes.
${debian_chroot:+($debian_chroot)}
means “if $debian_chroot
is set and non-empty, then ($debian_chroot)
, else nothing”. (See /etc/bash.bashrc
for how debian_chroot
is defined. As the name indicates this is a Debian thing.)\u
is replaced by the user name, \h
is replace by the machine name, and so on (see the manual for a list). Parts within \[…\]
are terminal escapes; the brackets tell bash that these parts don't take any room on the screen (this lets bash calculate the width of the prompt). \033
is the ESC character (character number 033 octal, i.e. 27 decimal, sometimes written \e
or ^[
); it introduces terminal escape sequences.ESC [ codes m
(written CSI Pm m
in the xterm control sequences list) changes the color or appearance of the following text. For example the code 1
switches to bold, 32
switches the foreground color to green, 0
switches to default attributes.