Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 was wondering if there is a way of changing the color of the ">>>" characters at the beginning of a newline in python when accessed from Ubuntu's terminal. I already edited the ~/.bashrc to change the color of the text in my terminal, but is there any file like this for python?

share|improve this question
up vote 3 down vote accepted

You can edit the Python prompt - see

I can't say how one would embed colour codes in the prompt string, but it should be possible.

share|improve this answer
So I was able to change the color of the ">>> " by importing sys and then writing this: sys.ps1 = '\033[01;33m>>>\033[00m ' ; the problem is that the change is only temporary. – Bogdan Aug 23 '12 at 11:02
You can bypass this by writing a script, say mypython which runs python with the -i and -c flag. This can be used to run the import sys and the prompt assignment on startup. – Steve Kroon Aug 24 '12 at 5:57
@SteveKroon: See below answer for setting it permanently. – user Nov 12 '15 at 15:01

You said

the problem is that the change is only temporary

To make it permanent, Guido recommends to



in your environment so you won't hve to think about it.

share|improve this answer

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.