Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 May 2012 08:16:51 -0600
From:      Reed Loefgren <rloefgren@forethought.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: CSH prompt
Message-ID:  <4FAFC253.5000200@forethought.net>
In-Reply-To: <20120513152509.09dbfc10.freebsd@edvax.de>
References:  <4FAFAF7F.4010409@webrz.net> <20120513152509.09dbfc10.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On 05/13/12 07:25, Polytropon wrote:
> On Sun, 13 May 2012 14:56:31 +0200, Jos Chrispijn wrote:
>> In cshell I use this prompt: set prompt = "%B[%@]%b %m[%/]>  "
>> The problem I face now is that if I use this prompt with symbolic links,
>> the presented location is displaying the symbolic link rather than the
>> real directory name.
>> Is there a way of preventin this?
> Yes, a very ugly way which I just found out:
>
> 	alias precmd 'set WD=`pwd`; set prompt = "%B[%@]%b %m[$WD]>  "'
>
> Example:
>
> 	[3:21pm] r56[/]>  cd /sys
> 	[3:21pm] r56[/usr/src/sys]>  _
>
> It redefines the whole prompt at any command that could
> affect the current working directory (not only "cd" can
> do that). This is needed as any call to `pwd` stored into
> a variable will only affect $prompt once - this is when
> it's set, only at this time $WD would be evaluated. So
> that's why this strange command. :-)
>
> Oh, and I just improved it. How about this?
>
> 	alias precmd 'set prompt = "%B[%@]%b %m[`pwd`]>  "'
>
> Much better. :-)

I've butchered it further, but thanks for doing the *real* work:

user:
alias precmd 'set prompt = "\n%{\033[32m%}%m [%h] [%@]%b%{\033[0m%} 
[`pwd`]$ "'

root:
alias precmd 'set prompt = "\n%{\033[31m%}%m [%h] [%@]%b%{\033[0m%} 
[`pwd`]$ "'

Regards,

r








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