freeBSD How to you set the prompt

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Jul 29 07:32:18 PDT 2004


On Thu, Jul 29, 2004 at 01:29:30PM -0000, Dan wrote:
> Where and how do you set the prompt to show what user name that  your  on IE ROOT or user johndoe.
> Eample of what the end results I would like to see.
> 
> # router1.pdx/chatusa.com user johndoe.

Depends on what shell you're using.  Assuming that you meant to type
'router1.pdx.chatusa.com' as the fully qualified hostname, then for
tcsh(1):

    set prompt="# %M user %n "

For bash(1):

    PS1="# \H user \u "

For zsh(1):

    prompt="# %M user %n "

For sh(1), which doesn't have any sort of escape character support for
its prompts, you'ld have to do something like:

    PS1="# $(hostname) user $(id -un)"

which just uses the regular string substition features supplied by the
shell. [The difference is immaterial here, but if you wanted, say, to
display the current working directory in your shell prompt, the
%-escape or \-escape style would do it without any fuss.  The sh(1)
style means you'ld have to arrange to reset the prompt each time you
changed directory.]

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040729/b42185d2/attachment.bin


More information about the freebsd-questions mailing list