From owner-freebsd-questions@FreeBSD.ORG Mon May 14 08:51:12 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14CB8106566C for ; Mon, 14 May 2012 08:51:12 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id C60288FC19 for ; Mon, 14 May 2012 08:51:11 +0000 (UTC) Received: from r56.edvax.de (port-92-195-20-192.dynamic.qsc.de [92.195.20.192]) by mx01.qsc.de (Postfix) with ESMTP id 8321F3D1AB; Mon, 14 May 2012 10:51:04 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id q4E8p3ej001937; Mon, 14 May 2012 10:51:03 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Mon, 14 May 2012 10:51:03 +0200 From: Polytropon To: Reed Loefgren Message-Id: <20120514105103.532295af.freebsd@edvax.de> In-Reply-To: <4FAFC253.5000200@forethought.net> References: <4FAFAF7F.4010409@webrz.net> <20120513152509.09dbfc10.freebsd@edvax.de> <4FAFC253.5000200@forethought.net> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: CSH prompt X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 May 2012 08:51:12 -0000 On Sun, 13 May 2012 08:16:51 -0600, Reed Loefgren wrote: > 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`]$ "' Allow me a final note: It's "normal" to denote non-root access with % (for csh) or $ (for sh, bash and many others), and root access with #. You can easily configure that to be automatically instead of $ if you like. Example: set promptchars = "%#" set prompt = "%n@%m:%~%# " For root, # will appear at the end, and % for non-root. Of course, you can easily apply this to your setting if you like, and you can define other characters if needed (e. g. "$#" or ">#"). Even though in your prompt shown above, root is shown by red color, that important attribute _might_ be missing when using a non-color terminal or a misconfigured emulator, so the user might not be aware of the immense power currently active (as no user name is shown in the prompt). Maybe this inspiration is useful to you. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...