# HG changeset patch # User Oleksandr Gavenko # Date 1318596407 -10800 # Node ID d2bb2c3da51b0bc24cace90eda7a61e2327546da # Parent 97139da7327399a0459050a2f5042f80bfd43006 Make color prompt for interactive Python. diff -r 97139da73273 -r d2bb2c3da51b .pystartup --- a/.pystartup Fri Oct 14 15:24:08 2011 +0300 +++ b/.pystartup Fri Oct 14 15:46:47 2011 +0300 @@ -6,8 +6,9 @@ # Store the file in ~/.pystartup, and set an environment variable to point # to it: "export PYTHONSTARTUP=~/.pystartup" in bash. +import os +import sys import atexit -import os import readline import rlcompleter @@ -20,6 +21,15 @@ if os.path.exists(historyPath): readline.read_history_file(historyPath) +term_with_colors = ['xterm', 'xterm-color', 'xterm-256color', 'linux', 'screen', 'screen-256color', 'screen-bce'] +if os.environ.get('TERM') in term_with_colors: + green='\033[32m' + red='\033[31m' + reset='\033[0m' + sys.ps1 = red + '>>> ' + reset + sys.ps2 = green + '... ' + reset +del term_with_colors + atexit.register(save_history) -del os, atexit, readline, rlcompleter, save_history, historyPath +del os, sys, atexit, readline, rlcompleter, save_history, historyPath