[comp.sources.misc] v03i070: csh prompt generator

bsrdp@cu.warwick.ac.uk.UUCP (Mr H Boothroyd) (07/01/88)

Posting-number: Volume 3, Issue 70
Submitted-by: "Mr H Boothroyd" <bsrdp@cu.warwick.ac.uk.UUCP>
Archive-name: anotherprompt

> From: jap@syssun.cl.msu.edu (Joseph A. Porkka)
> Newsgroups: comp.sources.misc: Volume 3, Issue 52
> Subject: v03i052: My favorite csh prompt generator

Thank you for networking the idea. It gave me something to start on to
adapt for my own use here.

I'm not sure whether a line for `popd'

     alias popd  'popd  \!* && prompt'

was lost in transmission or omitted by you.  It is needed in addition to
the three lines that arrived:

>    alias cd 'cd \!* && prompt'
>    alias prompt 'if ($?prompt) set prompt="! ${host}:${user} ${cwd}: "'
>    alias pushd 'pushd \!* && prompt'

You may just possibly be interested in the rather heavy adaptations that I
made to my .cshrc (with local help) in order to get
   - a prompt that leaves out my global address when in my workspace,
   - a full prompt when outside my workspace.

I can't help feeling there ought to be easier ways, but I'm not really into
unix and c.

     alias plocal  'expr "$cwd" : "$HOME/\(.*\)"'
     alias pglobal 'expr "$cwd" : "/\(.*\)"'
     alias prompt1 'if "$cwd" =~ "$HOME"* set prompt = "! `plocal`: " '
     alias prompt2 'if "$cwd" !~ "$HOME"* set prompt = "! `pglobal`: " '
     alias cd      'cd \!* && prompt1 && prompt2'
     alias pushd   'pushd \!* && prompt1 && prompt2'
     alias popd    'popd  \!* && prompt1 && prompt2'
     cd "$cwd"

-----------------------
Hylton Boothroyd         Janet:  h.boothroyd@uk.ac.warwick.cu
Warwick Business School  Darpa:  h.boothroyd%cu.warwick.ac.uk@cunyvm.cuny.edu
University of Warwick    Uucp:   h.boothroyd%sol@warwick.uucp
COVENTRY                 Earn/Bitnet: <Janet address>@UKACRL
England  CV4 7AL         Phone:  +44 203 523523  Extension 2428
-----------------------