Date: 28 May 2000 17:07:39 +0200 From: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-questions@freebsd.org Subject: Re: sh prompt Message-ID: <8grcnr$mu8$1@bigeye.mips.inka.de> References: <8gqsgm$311u$1@bigeye.mips.inka.de> <20000528134732.CURV22611.mail.rdc1.va.home.com@john.baldwin.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin <jhb@FreeBSD.ORG> wrote:
> >> PS1="[$(tty | cut -c9-11)]:`whoami`.`hostname | sed 's/\..*//'`@"`pwd`
>
> You can get the prompt you want rather easily in tcsh using the following:
>
> set prompt='[%l]:%n.%m@%~\n%# '
That's actually not quite the same. %l gives all of the basename
of the tty, rather than only the last two characters. Also, %/
would give the unsubstituted working directory like pwd does,
although %~ is arguably preferable.
BTW, your suggestion is
PS1='[\l]:\u.\h@\w\n\$ '
in bash. Substitute ${PWD} for \w to get the unsubstituted directory.
Getting the final two characters of the tty name requires some
contortions, as it probably does in tcsh, e.g.:
TTY=$(tty)
PS1="[${TTY#/dev/tty}]:"'\u.\h@${PWD}\n\$ '
--
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8grcnr$mu8$1>
