From owner-freebsd-questions Sat Jun 12 19:28:40 1999 Delivered-To: freebsd-questions@freebsd.org Received: from server4.reno.powernet.net (server4.reno.powernet.net [208.226.189.15]) by hub.freebsd.org (Postfix) with ESMTP id BA60614C4B for ; Sat, 12 Jun 1999 19:28:36 -0700 (PDT) (envelope-from trzy@powernet.net) Received: from p3-24.reno.powernet.net (p3-24.reno.powernet.net [208.226.189.144]) by server4.reno.powernet.net (8.9.0/8.8.5) with ESMTP id TAA25627; Sat, 12 Jun 1999 19:21:12 -0700 (PDT) Date: Sat, 12 Jun 1999 19:17:00 -0700 (PDT) From: Bart Trzynadlowski X-Sender: trzy@Brzuszek To: Mark Ovens Cc: freebsd-questions@freebsd.org Subject: Re: prompts In-Reply-To: <19990613015335.A255@marder-1> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Well, I used the below method to implement the prompt along with # for superuser and $ for user. However it only updates with cd, not chdir. # set prompt and display it at start up before any cd command is used case `id -u` in 0) PS1="`pwd`# ";; # for root... uid 0 *) PS1="`pwd`$ ";; esac # update prompt with each cd -- will NOT update if chdir is used though cd() { chdir "$@" case `id -u` in 0) PS1="`pwd`# ";; *) PS1="`pwd`$ ";; esac } However I still don't know how to make the # at the end of my csh prompt expand to % for user and # for superuser. It's just static at # for all users. But it does update the directory so thanks to everyone who helped out! Shells are such a chore. I'm gonna have to get myself one of those shell books. Thanks! Bart Trzynadlowski On Sun, 13 Jun 1999, Mark Ovens wrote: > On Sat, Jun 12, 1999 at 01:26:18PM -0700, Bart Trzynadlowski wrote: > > > > > > So there is no automated way to make it so the shell expands > > it to # or % according to the user class? I know that if the > > prompt is just defined as: > > set prompt = "\$ " > > then csh expands it to # for root and % for a user. > > I didn't know that. You've taught me something > > > But I noticed that I cannot do: > > set prompt "`pwd`\$" > > ANYTHING I put in front of the \$ is ignored. > > > > Hmm, one would expect it to work. I'd be interested to know if it > can be made to work. > > > > > > > > For csh you put the alias in each users ~/.cshrc and for non-root > > > users edit it, changing ``#'' to ``%''. Normally, if you don't set > > > the ``prompt'' variable yourself, the shell uses % as the default > > > for non-root users and # for root. > > > > > > > In zsh I think /# sets # for superuser and % for user. How > > > > can I set the prompt up so that if I'm a superuser it > > > > uses # and if I'm a user it uses $ under sh and csh. Do I just use "#"? I > > > > tried doing > > > > PS1="`pwd`# " > > > > in sh but it printed # for the regular users. > > > > > > > > > > > > > For csh you need to alias ``cd''. If you just do a ``set prompt='' > > > > > like you tried then it is static, that is you set the variable > > > > > "prompt" to the value it was at that point in time (actually, what > > > > > you did was wrong anyway, you needed ``set prompt = "`echo $cwd`#") > > > > > > > > > > You need to update the variable "prompt" every time you ``cd''. To > > > > > get what you want, add the following to ~/.cshrc (so it applies to > > > > > all shells that you start): > > > > > > > > > > alias cd 'cd \!*;set prompt="`pwd`# "' > > > > > > > > > > % > > > > > % cd > > > > > % alias cd 'cd \!*;set prompt="`pwd`# "' > > > > > % > > > > > % > > > > > % cd > > > > > /usr/marko# cd /etc > > > > > /etc# cd /mnt > > > > > /mnt# > > > > > > > > > > HTH > > > > > > > > > > > > > > > > Thanks a lot! > > > > > > > > > > > > Bart Trzynadlowski > > > > > > > > > > > > > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > > > > with "unsubscribe freebsd-questions" in the body of the message > > > > > > > > > > > > > > > > -- > > > > > FreeBSD - The Power To Serve http://www.freebsd.org > > > > > My Webpage http://www.users.globalnet.co.uk/~markov > > > > > _______________________________________________________________ > > > > > Mark Ovens, CNC Apps Engineer, Radan Computational Ltd. Bath UK > > > > > CAD/CAM solutions for Sheetmetal Working Industry > > > > > mailto:marko@uk.radan.com http://www.radan.com > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > FreeBSD - The Power To Serve http://www.freebsd.org > > > My Webpage http://www.users.globalnet.co.uk/~markov > > > _______________________________________________________________ > > > Mark Ovens, CNC Apps Engineer, Radan Computational Ltd. Bath UK > > > CAD/CAM solutions for Sheetmetal Working Industry > > > mailto:marko@uk.radan.com http://www.radan.com > > > > > > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-questions" in the body of the message > > > > -- > FreeBSD - The Power To Serve http://www.freebsd.org > My Webpage http://www.users.globalnet.co.uk/~markov > _______________________________________________________________ > Mark Ovens, CNC Apps Engineer, Radan Computational Ltd. Bath UK > CAD/CAM solutions for Sheetmetal Working Industry > mailto:marko@uk.radan.com http://www.radan.com > > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message