From owner-freebsd-questions Thu Jan 6 16: 8:59 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mx.cti.gr (kronos.cti.gr [150.140.1.25]) by hub.freebsd.org (Postfix) with SMTP id 4C268156A2 for ; Thu, 6 Jan 2000 16:08:52 -0800 (PST) (envelope-from keramida@diogenis.ceid.upatras.gr) Received: (qmail 242 invoked from network); 7 Jan 2000 00:07:04 -0000 Received: from unknown (HELO localhost.hell.gr) (150.140.30.38) by kronos.cti.gr with SMTP; 7 Jan 2000 00:07:04 -0000 Received: (qmail 7341 invoked by uid 1001); 6 Jan 2000 15:57:04 -0000 Date: Thu, 6 Jan 2000 17:57:04 +0200 From: Giorgos Keramidas To: R Joseph Wright Cc: freebsd-questions@FreeBSD.ORG Subject: Bash prompt (Was: window manager question) Message-ID: <20000106175704.A7246@hades.hell.gr> Reply-To: keramida@ceid.upatras.gr References: <200001052224.XAA37273@dorifer.heim3.tu-clausthal.de> <387435D1.7E20347D@nwlink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: <387435D1.7E20347D@nwlink.com> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Jan 05, 2000 at 10:27:30PM -0800, R Joseph Wright wrote: > There is only one problem. My .rc files have this setup, as you > described, but modified for bash: > > if [[ $EUID -eq 0 ]]; then > PS1="root@\h\w\$" > else > PS1="joseph@\h\w\$" > fi > According to the man page on bash, the "$" is supposed to show up as "#" > if uid is 0, otherwise it will show as "$". It doesn't do this, > however. It always shows up as "$", regardless of uid. Actually, when you use "\$" enclosed in double quotes, as shown above, then bash will try and expand shell variables in the string. The dollar sign is used to start shell variable substitutions. This would make a prompt like "($UID) " work fine, replacing $UID with the current UID. However, using a backslash, you can escape a `$' character, and force bash to insert a literal `$' in that place (always speaking of double quotes, here). If you don't want shell-variable substitution in the prompt value (which happens at the time the PS1 value is evaluated, *before* it gets assigned to PS1), then you are better off using single quotes. Try: PS1='\u@\h:\w\$ ' # note the single quotes! Ciao. -- Giorgos Keramidas, < keramida @ ceid . upatras . gr > "What we have to learn to do, we learn by doing." [Aristotle] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message