Date: Sun, 28 May 2000 09:43:13 -0600 From: "Duke Normandin" <dnormandin@freewwweb.com> To: "Christian Weisgerber" <naddy@mips.inka.de>, <freebsd-questions@freebsd.org> Subject: Re: sh prompt Message-ID: <000201bfc8d5$3744aca0$7fdba7d1@odie>
next in thread | raw e-mail | index | archive | help
On Sunday, May 28, 2000 6:21 AM Christian Weisgerber <naddy@mips.inka.de> wrote:
>Duke Normandin <dnormandin@freewwweb.com> 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
Thanks for *all* the tops......... I tried Greg's suggestion (or what I
thought it was) and it didn't work for me. The prompt (as I have it)
gets a bit long after a while, so after reading a ksh example of a 2-line
prompt, I thought I could duplicate with sh. I suppose that I should
consider using a different shell ;)
-duke
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?000201bfc8d5$3744aca0$7fdba7d1>
