Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

1 Answer 1

up vote 1 down vote accepted

You can edit the Python prompt - see http://www.doughellmann.com/PyMOTW/sys/interpreter.html#interactive-prompts

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

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.