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

Ray Lai nycbug at cyth.net
Mon May 8 11:37:52 EDT 2006


Marc Spitzer wrote:
> any other short and quick hacks out there?

I have:

	PROMPT=$(hostname)
	PROMPT=${USER:-${LOGNAME}}@${PROMPT%%.*}
	TILDE='~'
	PS1='${PROMPT}[${TILDE[(1-0${PWD%%@([!!/]*|$HOME*)}1)]-}${PWD#$HOME}] '

in my .profile, which gives me prompts like:

	ray at x[~] cd tmp 
	ray at x[~/tmp] cd /tmp
	ray at x[/tmp] 

It works in every Korn shell implementation I've used and might
work in Bourne (not Again) shells (bash freaks out).  It's nice
having a snippet of code to set my prompt everywhere.

Oh, and half the fun was figuring out how it worked.  (From Christian
"naddy" Weisgerber: <http://marc.theaimsgroup.com/?m=109974730617615>.)

-Ray-



More information about the talk mailing list