Getting csh prompt to display the current dir.

Jeff Gustafson SSUCS004 at vmd.cso.uiuc.edu
Mon Apr 3 17:31:17 AEST 1989


In the INFO-UNIX digest for Tue, 28 Mar 1989   V7#034,
lbn at ksuvax1.cis.ksu.edu (Lars Bo Nielsen) wrote:
(here come some thickly applied >'s)

>In article <2113 at cveg.uucp> jms at hcx.uucp (Michael Stanley) writes:
>>
>>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"% "'
>>>  [Three more examples]
>>
>>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.
>
>You are right.  Here are the modified (quicker) versions:

And here, Mr. Nielsen gives the results of the suggestions made above.
However, I hasten to add that not every version of csh has the $cwd
environment variable.  I work on a Sperry 5000/90, and the Unisys proprietary
version of csh does not have $cwd (nor does it allow the old $< trick, push,
and pop).  Granted, I am an exception to a general rule, but we're always
out there somewhere and must help each other out.  (O, woe....)

Without the $cwd variable, the foo is a necessity.  One can get around the
$< problem (if one must) by coding:

             set instuff = `cat | head -1` (to read exactly one line of input)

instead of the old

            set instuff = $<  .

For the push and pop utilities, I refer you to "The C-Shell Field Guide"
by Gail Anderson and Paul Anderson.  It's the best work I've seen covering
csh.

What irks me so much is that the Sperry manuals explicitly state that $<
works.  Ah, well... we live and we learn.

I also cannot properly use the source command.  Does anyone out there have any
useful suggestions for a poor user of a brain-dead C-shell?  [I say that for
the sake of my ego; no doubt I am overlooking something, I'm a "sh" refugee.]
Your input shall be most welcome.

           Jeff Gustafson
           J-168, Academic Computing Services
           Sangamon State University
           Springfield, IL 62794-9243
           <SSUCS004 at UIUCVMD>
           <SSUCS004 at vmd.cso.uiuc.edu>



More information about the Comp.unix.questions mailing list