SRL Archive - Python/Perl Help and Tutorials

[Bash/Python] Colourful shells


Wizzup?

2010-09-14 10:40:50

Paste this in your shell to get a colourful and dynamic shell. (Bash only, requires python to be installed)

export PS1="\[\` /usr/bin/python -c \"print ''.join(map(lambda x : '\033[%i;1m%s\033[0;0m' % (__import__('random').randint(31, 38), x),  __import__('sys').argv[1]))\" '\u@\h \w $ ' \`\]"

Readable version:

export PS1="\[\` /usr/bin/python -c \"
s = '\033[%i;1m%s\033[0;0m'
out = ''
import sys
from random import randint
arg = sys.argv[1]
for i in arg:
out += s % (randint(31, 38), i)
print out\" '\u@\h \w $ ' \`\]"

Yakman

2010-09-14 11:25:28

*thumbs up*

noidea

2010-11-21 00:10:00

bump.
fixed white space

Wizzup?

2010-11-21 05:53:32

Nice… ;)

Camaro'

2010-11-21 16:52:29

From: Wizzup?
Nice… ;)


This is awesome :)