Linked by Shane on Wed 24th Nov 2010 22:40 UTC
Thread beginning with comment 451078
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
Linked by Thom Holwerda on 04/18/13 11:21 UTC
Linked by Thom Holwerda on 04/16/13 9:29 UTC
More Features »
Sponsored Links



Member since:
2009-05-07
Here's what I've used for the last few years... on Mac OS X... this copy is tweaked a little to privatize... I don't know if this is generally useful for people or not, but in our environment some fairly long subpaths repeat themselves over and over again, so it occurred to me that I could run the path through a script to abbreviate those common paths.
Sarah
----- .bash_profile -----
PS1='$(/Some/place/sarahprompt.py)\n\!\$ '
----- begin sarahprompt.py -----
#!/usr/bin/python -E -S
import os
import time
# Date like: May17
tinydate=time.strftime("%b%d")
# \x1B is escape, \e doesn't work and I don't know why.
# Set title of window or tab
def title(str):
return '\x1B];'+str+'\007';
# Make a colored bar with text in it in the current window
def bar(str):
return "\x1B[2K\x1B[0;1;47m\x1B[0K"+str+"\x1B[0m";
# Get the current directory, and substitute ~ for home dir
current_path=os.environ["PWD"]
home=os.environ["HOME"]
if (current_path.startswith(home)):
current_path="~"+current_path[len(home):]
current_path=current_path.replace("/some/long/tedious/path/","/(abb rev)/")
#... add more replacements here ...
# Last two path elements (works right for less than two, too!
tinypath="/".join(current_path.split("/")[-2:])
# Prompt string sets the title and the bar
prompt=title(tinydate+" "+tinypath)+bar(current_path)
# Print the string (which passes it back to bash for display)
print prompt
----- end sarahprompt.py -----