Built-in String Processing?

Fred Stluka stluka at software.org
Wed Oct 31 13:49:46 AEST 1990


In article <1990Oct29.160325.23250 at ux1.cso.uiuc.edu> hirchert at harriett.ncsa.uiuc.edu (Kurt Hirchert) writes:
> 
> # aliases for changing the prompt to include current directory
> alias setprompt	'set prompt="("`pwd |'\
> 'sed -e "s|^$home|~|"'\
> '`") "'\""`hostname` \\!% "\"
> alias cd	"cd \!* ; setprompt"
> alias chdir	"chdir \!* ; setprompt"
> alias pushd	"pushd \!* ; setprompt"
> alias popd	"popd \!* ; setprompt"

Here's a trick I stumbled across while setting up my own
version of this a while back.

Try typing:

	dirs

If the directories that it reports are always in the form 
you want (on my Apollo, ~ is displayed instead of the long
pathname to my home directory), you can eliminate sed from
the pipeline in setprompt by using dirs instead of pwd as
the starting point.  

Example:

    alias setprompt \
    'set noglob;set d=(`dirs`);set prompt="$d[1] % ";unset noglob'
	
--Fred

Fred Stluka                          Internet: stluka at software.org
Software Productivity Consortium     UUNET:    ...!uunet!software!stluka
2214 Rock Hill Rd, Herndon VA 22070  



More information about the Comp.unix.shell mailing list