Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 2000 21:38:22 -0700 (PDT)
From:      John Baldwin <jhb@pike.osd.bsdi.com>
To:        Rahul Siddharthan <rsidd@physics.iisc.ernet.in>
Cc:        djkanter@northwestern.edu, freebsd-questions@FreeBSD.ORG
Subject:   Re: Setting shell prompt for C-shell
Message-ID:  <200007210438.VAA38937@pike.osd.bsdi.com>
In-Reply-To: <20000721095347.A9557@physics.iisc.ernet.in> from Rahul Siddharthan at "Jul 21, 2000 09:53:47 am"

next in thread | previous in thread | raw e-mail | index | archive | help
> Alfred Perlstein said on Jul 20, 2000 at 18:45:59:
> > * David J. Kanter <djkanter@northwestern.edu> [000720 18:22] wrote:
> > > I'm having trouble customizing the shell prompt for csh. I'd like to have:
> > > 
> > > pwd % (ex. /home/david % or /usr/bin % ...)
> > > 
> > > In my .cshrc I have:
> > > 
> > > set prompt="`pwd` % "
> > > 
> > > Which works fine upon start-up (/home/david % ) but doesn't change as I make
> > > my way through various directories. Look...
> 
> > `pwd` gets evaluated right then and there, not every time you
> > hit enter, try this instead:
> > 
> > set prompt="%~ >"

This only works in tcsh, and "%/ >" more closely matches what the original
poster requested.

> What is that supposed to do?  When I try it I simply get a prompt like
> %~ >              (this is with /bin/csh on 3.4)

Yes, csh dosen't handle % escapes in the prompt.

> and 
> ~ >               (with tcsh on the same machine)

Try changing to a different directory, then read the manpage for tcsh. :)
Basically, %~ is like %/, but it will use ~ for your home directory, and
~foo for foo's home directory instead of the actual path.  If you typically
log into several machines, then a prompt such as "%B%n@%m%b:%~\n%# " can
be useful.  It would render as follows:

john@john:~                                                                     >

but with the username and machine in bold.

> > Please see the shell's manpage (man csh), in ancient and more
> > barbaric times someone would show up at your door for forking pwd
> > every time you hit enter.
> 
> What I use is something like this:
> alias cd 'cd \!*; set prompt="\! `pwd`>"'
> 
> which sets the prompt afresh every time you use cd.  Is that what you
> mean above?

That works, but is only necessary for archaic shells like the original csh or
sh.

> Rahul.

--

John Baldwin <jhb@bsdi.com>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007210438.VAA38937>