Getting UNIX prompt to display curr

Michael Stanley jms at hcx.uucp
Sat Mar 25 14:21:31 AEST 1989


In article <1383 at deimos.cis.ksu.edu>, lbn at ksuvax1.cis.ksu.edu (Lars Bo Nielsen) writes:
> Simply (in CSH):
> 
> 1) Full pathname:
> 	alias cd 'cd \!*; set foo=`pwd`; set prompt=$foo"% "'
> 2) Only name of current dir:
> 	alias cd 'cd \!*; set foo=`pwd`; set prompt=$foo:t"% "'
> 3) Include name of machine in prompt
> 	alias cd 'cd \!*; set foo=`pwd`; set prompt=$host":"$foo"% "'
> or	alias cd 'cd \!*; set foo=`pwd`; set prompt=$host":"$foo:t"% "'

Ah, but csh includes the environment variable $cwd.  This makes setting
foo unnecessary.  It seems to me that you could remove the part that says:

	set foo=`pwd`

and replace every occurrence of $foo with $cwd.

I haven't actually tested these examples so I hope I didn't just stick
my foot in my mouth, but I did do something like this once so I'm pretty
sure it'll work.  I only make this suggestion because if your system is
running slow, every extra binary you run (in this case 'pwd') will just
be that much more irritation.


	Michael Stanley      (...!uunet!harris.cis.ksu.edu!jms at hcx)



More information about the Comp.unix.questions mailing list