prompt question

Erik Fortune erik at westworld.esd.sgi.com
Fri Feb 8 11:36:07 AEST 1991


Hah!  You want silly, extreme prompts?  Here's
an excerpt from *my* aliases file:  (-:

alias back 'cd $lastdir'
alias cd 'cd \!:* ; ExitDir ; FixLocation ; FixPrompt ; EnterDir'

alias ExitDir	'set lastdir=${thisdir}'
alias EnterDir	'set thisdir=${cwd} ; FixPrompt'
#aliases to make cd,pushd,and popd understandable

if ( ! $?PROMPTCOMMENT )	setenv PROMPTCOMMENT ""
if ( ! $?CDENTER )		setenv CDENTER .cdinit.cmd
if ( ! $?CDEXIT )		setenv CDEXIT .cdexit.cmd
if ( ! $?rev_vid )		setenv rev_vid ""
if ( ! $?norm_vid )		setenv norm_vid ""
if ( ! $?host_pfx )		setenv host_pfx ""
if ( ! $?thisdir )		set this_dir = .
if ( ! $?lastdir )		set last_dir =  .

alias EnterDir     'if (-e "$thisdir/$CDENTER") source $thisdir/$CDENTER'
alias ExitDir      'if (-e "$thisdir/$CDEXIT") source $thisdir/$CDEXIT'
alias FixLocation  'set lastdir = "$thisdir";set thisdir = "`pwd`"'
alias FixPrompt 'set prompt="${host_pfx}${rev_vid}<${HOST}:${PROMPTCOMMENT}${cwd:t}>${norm_vid} "'


I use color xterm, and the $host_pfx is the escape sequence to change xterm
foreground and background colors, so the color of my window varies with the
host I'm talking to.   If I'm not on an xterm (but I am on ansi), it changes
the colors of prompt depending on the host I'm currently logged into.
The $rev_vid is the escape sequence to set whatever terminal I'm on into
reverse video, $norm_vid sets it back.

A session looks like this (I'm rlogged in to "piranha" in a directory /mumble/mumble/blah:
[ xterm is white on navy, prompt is navy on white ]
    <piranha:blah> ~^Z
[ xterm changes color to white on firebrick, prompt is firebrick on white ]
    <westworld:erik> 

It's ugly, but I love it.

Oh, yeah.   If a directory has a file named .cdinit.cmd in it, the file is sourced
whenever I cd into the directory.   If a directory has a .cdexit.cmd, the file is
sourced when I leave.  I have local aliases for lots of directories.

-- Erik



More information about the Comp.unix.misc mailing list