[X-Unix] Call for bash prompts

Joe Block jpb at ApesSeekingKnowledge.net
Fri Feb 20 19:27:59 PST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 20, 2004, at 9:29 AM, Kirk McElhearn wrote:

> I'm helping Rob Griffiths update his Mac OS X Hints book for Panther, 
> and
> one of the hints is about customizing the shell prompt. Naturally, the
> Jaguar edition uses tcsh, so I'm updating this for bash. (We've made 
> the
> decision to assume that users are working with bash.)
>
> I'm looking for a long, cool, complex, multi-line prompt to use as an
> example. Anyone have one they want to contribute? The "winning" prompt 
> will
> have the contributor's name in the book.

Well, do you count updating the Terminal.app / X11 xterm window title 
bar in addition to the prompt as making it multiline and complicated?

# here is the relevant portion of my .bash_profile
export PS1='[\u@\h:\w]\$ '
export TITLEBAR='\[\033]0;\u@\h:\w \007\]'
# Terminal sets TERM_PROGRAM so we can tell it apart from regular VT100
case "$TERM_PROGRAM" in
         "Apple_Terminal")PS1="$TITLEBAR$PS1"
esac
case "$TERM" in
         
"xterm"|"vt100"|"color-xterm"|"xterm-color")PS1="$TITLEBAR$PSRAW"
esac

This sets the prompt (and the Terminal window's title bar) to

[username at hostname:/path/to/cwd]$

to prevent awkward errors like rebooting the wrong server from the 
command line, or deleting the live configuration files when you think 
you're working on the . If you don't want the full path, just the 
current directory name, replace \w with \W.  Replacing \h with \H will 
put the Rendezvous name in the prompt on Panther.

Fiddling the title bar is also convenient because it allows you to use 
Terminal's Dock menu to jump straight to the window you want rather 
than guessing, which is important to me because I typically have 6-12 
windows open.

jpb
- -- 
Joe Block <jpb at ApesSeekingKnowledge.net>

The goal of Computer Science is to build something that will last at 
least until we've finished building it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD4DBQFANtBAyEXo8W2M9hsRAgSGAJio3GKrt+ZpvlqjIdtSMTMS9KVzAKDFLk+2
Ht15kXrQywgW4/1RpYe1Bg==
=4O5X
-----END PGP SIGNATURE-----



More information about the X-Unix mailing list