Whats in your $PYTHONSTARTUP$ ?

Steve Purcell stephen_purcell at yahoo.com
Thu Mar 29 09:23:28 EST 2001


Randall Hopper wrote:
> Just a little fragment to colorize my python prompts.  Nowadays, I'm always
> on a VT100 color capable terminal (recent xterm, aterm, FreeBSD/Linux
> console, etc.).
> 
>      import sys,os
>      if os.environ.get( 'TERM' ) in [ 'xterm', 'vt100' ]:
>        sys.ps1 = '\001\033[0:1;32m\002>>> \001\033[0m\002'
>        sys.ps2 = '\001\033[0:31m\002... \001\033[0m\002'
> 

That's nice. And you can set the xterm title string using:

    if os.environ['TERM'] in ('rxvt', 'xterm'):
      sys.stdout.write('\033]0;python in %s\007' % os.getcwd())

You could add in all kinds of nice stuff like the Python version number and
the hostname (sys.version, socket.gethostname)...

-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo




More information about the Python-list mailing list