Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 1999 23:58:53 -0600 (CST)
From:      Ryan Thompson <freebsd@sasknow.com>
To:        Duke Normandin <01031149@3web.net>
Cc:        freebsd-questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: csh prompt
Message-ID:  <Pine.BSF.4.10.9912152348410.88140-100000@sasknow.com>
In-Reply-To: <000501bf478e$3ef90ae0$579ac5d1@webserver>

next in thread | previous in thread | raw e-mail | index | archive | help

On Wed, 15 Dec 1999, Duke Normandin wrote:

> Hi...
Hi, Duke!

> I've been reading a Linux shell tutorial and the man pages. ;)
> Searched the mailing list for, and found examples of, prompts with
> various shells.
> 
> In my ~/.cshrc file:
> 
> set prompt = "' hostname -s'# "
> 
> works. 

It shouldn't work!  Are you sure you typed the above correctly?  See
below.


> Why doesn't the following?
> 
> set prompt = "'whoami'@'hostname -s':$cwd# "
> 
> I keep getting for example:
> 
> 'whoami'@'hostname':/etc# _

You're getting the exec elements spelled out (whoami and hostname) because
you've used the wrong quotation marks.  When you want to exec something in
this fashion, you need to use "backticks"  ( ` ).  So, instead of
'whoami', you should use `whoami`.

AND, you've also hit on another important point with your use of $cwd.
Since your prompt is set in your .cshrc file, it is set only when you log
in, and is not changed after each command.  Therefore, if you ran your
.cshrc script while you were in /etc, your prompt is always going to say
/etc.  :-)

Try the following instead (this is actually very similar to what I use):

set prompt = "`whoami`@`hostname -s`:`pwd`# "

alias cd 'cd \!* ; set prompt = "`whoami`@`hostname -s`:`pwd`# "'
alias pushd 'cd \!* ; set prompt = "`whoami`@`hostname -s`:`pwd`# "'
alias popd 'popd ; set prompt = "`whoami`@`hostname -s`:`pwd`# "'

You may not use pushd and popd (yet), but they've been included for
completeness.  Suffice to say, everytime you change directories with cd,
pushd, or popd, your prompt will be refreshed.

For user accounts, you may want to replace the # with a $ to differentiate
between userland and the super user.  (# is usually reserved for the
elite, and represents a true symbol of power :-)

Hope this helps,
 - Ryan

---

  Ryan Thompson <ryan@sasknow.com>
  50% Owner, Technical and Accounts
  Phone: +1 (306) 664-1161

  SaskNow Technologies     http://www.sasknow.com
  #106-380 3120 8th St E   Saskatoon, SK  S7H 0W2




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?Pine.BSF.4.10.9912152348410.88140-100000>