From owner-freebsd-questions Thu Apr 20 21:31: 8 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 2B07337B53A for ; Thu, 20 Apr 2000 21:31:04 -0700 (PDT) (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 GAA24909 for freebsd-questions@freebsd.org; Fri, 21 Apr 2000 06:31:01 +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 EAA00953 for freebsd-questions@freebsd.org; Fri, 21 Apr 2000 04:17:02 +0200 (CEST) (envelope-from daemon) From: naddy@mips.rhein-neckar.de (Christian Weisgerber) Subject: Re: /bin/sh question Date: 21 Apr 2000 04:17:02 +0200 Message-ID: <8dodmu$tb$1@bigeye.rhein-neckar.de> References: <200004201611.MAA01664@rac4.wam.umd.edu> To: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG James Howard wrote: > However, I have recently noticed that FreeBSD's sh does nearly everything > I need except for one thing. My bash prompt is set to "\u@\h:\w\$ " and > typically my prompt is then shown as "howardjp@byzantine:~$ ". Is there > anyway to get something similar from sh? Yes. The key is to define a function cd() that, when called, also sets PS1 in addition to performing the actual "cd". (This approach can also be used for the Korn shell.) I have adapted the following snippet for $ENV without testing: PROMPT="$(whoami)@$(hostname -s):" cd() { command cd "$@" case ${PWD} in "${HOME}"*) PS1="${PROMPT}~${PWD#${HOME}}\$ " ;; *) PS1="${PROMPT}${PWD}\$ " ;; esac } 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