From owner-freebsd-questions Sun May 28 5:20:26 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mail.inka.de (quechua.inka.de [212.227.14.2]) by hub.freebsd.org (Postfix) with ESMTP id E2DF137B976 for ; Sun, 28 May 2000 05:20:20 -0700 (PDT) (envelope-from daemon@mips.inka.de) Received: from bigeye.mips.inka.de (uucp@) by mail.inka.de with local-bsmtp id 12w232-000377-00; Sun, 28 May 2000 14:20:04 +0200 Received: (from daemon@localhost) by bigeye.mips.inka.de (8.9.3/8.9.3) id MAA99399 for freebsd-questions@freebsd.org; Sun, 28 May 2000 12:30:46 +0200 (CEST) (envelope-from daemon) From: naddy@mips.inka.de (Christian Weisgerber) Subject: Re: sh prompt Date: 28 May 2000 12:30:46 +0200 Message-ID: <8gqsgm$311u$1@bigeye.mips.inka.de> References: <001601bfc85d$9b60f680$1fdba7d1@odie> To: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Duke Normandin wrote: > I have the following prompt in ~/.shrc: > > PS1="[$(tty | cut -c9-11)]:`whoami`.`hostname | sed 's/\..*//'`@"`pwd` ^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~ hostname -s `pwd` will probably not do what you expect. This is evaluated only once when PS1 is set, so it will not keep your current working directory in your prompt. For that you'll need something along the lines of this: PROMPT=$(whoami)@$(hostname -s) cd() { command cd "$@" case ${PWD} in "${HOME}"*) PS1="${PROMPT}[~${PWD#${HOME}}] " ;; *) PS1="${PROMPT}[${PWD}] " ;; esac } > case `id -u` in > 0) PS1="${PS1}# ";; > *) PS1="${PS1}$ ";; > esac > > I want to introduce a ^J or \n in the "case" so that my prompt PS1="${PS1} \$ " However, this will screw up. sh assumes that all the characters in PS1 print as one character on the same line. Putting a newline (or terminal control sequences) there will confuse the command line editor about the length of the line, and you will get strange effects when entering and editing long lines. Basically, what you are trying to do is beyond the capabilities of sh. -- Christian "naddy" Weisgerber naddy@mips.inka.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message