From owner-freebsd-questions Wed Mar 29 14:32:41 2000 Delivered-To: freebsd-questions@freebsd.org Received: from news-ma.rhein-neckar.de (news-ma.rhein-neckar.de [193.197.90.3]) by hub.freebsd.org (Postfix) with ESMTP id 1108037BA3C for ; Wed, 29 Mar 2000 14:32:37 -0800 (PST) (envelope-from daemon@bigeye.rhein-neckar.de) Received: from bigeye.rhein-neckar.de (uucp@localhost) by news-ma.rhein-neckar.de (8.8.8/8.8.8) with bsmtp id AAA12924 for freebsd-questions@freebsd.org; Thu, 30 Mar 2000 00:32:35 +0200 (CEST) (envelope-from daemon@bigeye.rhein-neckar.de) Received: (from daemon@localhost) by bigeye.rhein-neckar.de (8.9.3/8.9.3) id AAA58851 for freebsd-questions@freebsd.org; Thu, 30 Mar 2000 00:03:32 +0200 (CEST) (envelope-from daemon) From: naddy@mips.rhein-neckar.de (Christian Weisgerber) Subject: Re: Prompt and Path questions Date: 30 Mar 2000 00:03:31 +0200 Message-ID: <8btujj$1peq$1@bigeye.rhein-neckar.de> References: <200003290559.AA228787102@mail.ev1.net> To: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Vodyanoi wrote: > PS1="`whoami`@`hostname | sed 's/\..*//'`" ^^^^^^^^^^^^^^^^^^^^^^^^ Simpler: hostname -s > case `id -u` in > 0) PS1="${PS1}|`pwd`# ";; > *) PS1="${PS1}|`pwd`$ ";; > esac This doesn't work because `pwd` is expanded at the time you assign this value to PS1. Also, contrary to for instance ksh, sh will not expand variables when evaluating PS1. > I searched the archives for the mailing list and found somethig > about using CD insteadof PS1 but not sure what CD is or how to set > that up. prompt1="$(whoami)@$(hostname -s)|" case $(id -u) in 0) prompt2='# ' ;; *) prompt2='$ ' ;; esac cd() { command cd "$@" PS1="${prompt1}${PWD}${prompt2}" } cd "${PWD}" # initialize prompt -- Christian "naddy" Weisgerber naddy@mips.rhein-neckar.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message