[nycbug-talk] what are your usefull hacks, the real simple ones

Ray Lai nycbug at cyth.net
Mon May 8 12:12:56 EDT 2006


On Mon, May 08, 2006 at 12:00:56PM -0400, Ah Pook wrote:
> On Monday 08 May 2006 11:37 am, Ray Lai wrote:
> > in my .profile, which gives me prompts like:
> >
> > 	ray at x[~] cd tmp
> > 	ray at x[~/tmp] cd /tmp
> > 	ray at x[/tmp]
> 
> For bash, I have
> PS1="\[ [1;34m\]\u\[ [37m\]@\[ [0;35m\]\h \[ [1;37m\]\w$\[ [0m\] "
> 
> Same thing, pretty much.  I'd cry without colour codes - different 
> colours for each host helps immensely when you're ssh'ing around all 
> day.  I'm always blue, root is always red.

Yeah, but color doesn't work everywhere.  Ever used terminals with
a white background?  Horrendous.

Plus, I (almost) never login as root.

> > Oh, and half the fun was figuring out how it worked.
> 
> Fun, hmm?  :-)  I remember spending (too) many hours trying to get bash, 
> ksh, and zsh to show the same thing.  It's one of those things that you 
> get working and never touch again, if you're lucky.  zsh:
> export PROMPT="%{^[[1;34m%}%n%{^[[37m%}@^[[36m%m %{^[[37m%}%d$%{^[[0m%} 
> "

When I first started using this code, I didn't use the bash/zsh
special escapes to print the username, host, or directory because
pdksh didn't support them.  It turned out to be a blessing in
disguise when I tried to to use the same prompt at work, where they
use some decade-old systems.  All those fancy color/underline/bold
codes don't work there either.

-Ray-



More information about the talk mailing list