Date: 21 Apr 2000 04:17:02 +0200 From: naddy@mips.rhein-neckar.de (Christian Weisgerber) To: freebsd-questions@freebsd.org Subject: Re: /bin/sh question Message-ID: <8dodmu$tb$1@bigeye.rhein-neckar.de> References: <200004201611.MAA01664@rac4.wam.umd.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
James Howard <howardjp@wam.umd.edu> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8dodmu$tb$1>