20090522 binbash or usrbinbash prompt configuration - plembo/onemoretech GitHub Wiki

title: /bin/bash (or /usr/bin/bash) prompt configuration link: https://onemoretech.wordpress.com/2009/05/22/binbash-or-usrbinbash-prompt-configuration/ author: lembobro description: post_id: 318 created: 2009/05/22 15:09:25 created_gmt: 2009/05/22 15:09:25 comment_status: open post_name: binbash-or-usrbinbash-prompt-configuration status: publish post_type: post

/bin/bash (or /usr/bin/bash) prompt configuration

OK, so this is just for reference because I’m tired of looking it up in other places.

To get a nice prompt from bash like this:

[myuser@myhost /u01/apps]$

where your user account is in a directory named “tmp”, what you need to do is put the following in .bash_profile or .bashrc:

`

PS1="[u@h w]$ "

`

The variables here are pretty self-explainatory.

u is your Unix user ID, h is the machine hostname up to the first “.”, w is the the current working directory, with $HOME replaced by a tilde (~), the $ followed by whitespace just echoes to show this is a non-root shell.

(if you wanted just the “basename” of the current working directory, e.g. “apps” instead of “/u01/apps”, you would use the W escape code).

There are a lot of variations possible here.

See the man page for more.

Copyright 2004-2019 Phil Lembo