Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm seeing this in my .bashrc file:

      [\033[01;34m\]\w\[\033[00m\]\$ '

and I have absolutely no idea what all those escapes codes mean. I've tried searching, but I have no idea what to search for (Unix escape codes? BASH escape codes? Terminal/TTY escape codes? etc.) Would someone kindly explain what those are/how they work? :)

share|improve this question
up vote 9 down vote accepted

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.)
  • The backslash escapes are prompt escapes. \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.
share|improve this answer
The ESC codes are known as ANSI Escape Sequences. You can find a lot about them on the net. – Mark Jul 19 '11 at 19:41
+1 Thanks for the explanations! :) @Mark: That's really useful, thanks for pointing it out! I had no idea what to call them before. :) – Mehrdad Jul 19 '11 at 20:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.