I would like the CasebashMac:bfgenv chris$ part of the following line to appear in a different color in my terminal.

CasebashMac:bfgenv chris$ python

2 Answers 2


I set the PS1 variable in my .bashrc to achieve this.

  • Open Terminal
  • [editorofchoice] ~/.bashrc
  • Add a line with the following:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

  • Save the .bashrc
  • Exit Terminal and re-open. You should now have a green prompt.
  • 1
    Where is this bashrc file?
    – Casebash
    Commented Oct 17, 2010 at 0:45
  • 1
    @Casebash It should be in you home folder for your user account. If it does not exist, which often it doesn't, just create it. Commented Oct 17, 2010 at 8:43
  • 1
    “.bashrc” won’t be there by default, and since it has a DOT, you won’t see it in finder (unless you have told it to show invisible files). Therefore it’s usually safe to use “vi” or “pico" to edit the file, because if it doesn’t exist, it will create it. Commented Oct 17, 2010 at 14:02
  • It works if I run the command using export, but not in my .bashrc file. CasebashMac:~ chris$ cat ~/.bashrc PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    – Casebash
    Commented Oct 17, 2010 at 20:04
  • @Casebash. I am not sure what he problem is. I copied that straight out of the .bashrc on my machine. The actual PS1 line I got from my Ubuntu Server since I wanted both to be the same. Also make sure you exit both the terminal and quit terminal and then reopen. Commented Oct 18, 2010 at 9:07

The terminal app does not actually change the colours, this is controlled by the shell that is being run. The default shell is bash and controlling colours is done by altering the prompt. There are many tutorials and other documents on the web to tell you more.

One guide to customising the prompt is from IBM

  • Please include an example directly into your answer.
    – nohillside
    Commented Jan 16, 2019 at 23:46
  • @Hillside - not really as I think too broad for an answer
    – mmmmmm
    Commented Jan 16, 2019 at 23:48
  • @nohillside but then again see my answer here apple.stackexchange.com/questions/59480/… - OK we have a duplicate - my answer there is much better than here and the the answer here is not that good. Close this as a duplicate?
    – mmmmmm
    Commented Jan 16, 2019 at 23:58

Not the answer you're looking for? Browse other questions tagged .