You might be interested in the Bash-Prompt-HOWTO.  It goes into much more
detail than I can/will here, and should be available in /usr/doc/HOWTO or
if you didn't install the documentation, at
http://metalab.unc.edu/LDP/HOWTO/Bash-Prompt-HOWTO.html

Basically, the prompt is stored in the PS1 environment variable.  This can
include environment variables, and special backslash-escaped variables
including the following (`man bash` for an exhaustive list):

    \h     the hostname up to the first `.'
    \H     the hostname
    \u     the username of the current user
    \w     the current working directory
    \W     the  basename  of the current working directory
    \$     if the effective UID is 0, a #, otherwise a $

Thus, the default prompt is PS1="[\u@\h \W]\$ ".  you can see this by
typing `set`, which shows a list of all environment variables.  The way to
set the prompt on login is to put this command in one of the scripts that
bash runs when it starts.  According to the bash man page, bash will
execute /etc/profile first, then one of ~/.bash_profile,  ~/.bash_login,
or  ~/.profile, whichever comes first.  ~/.bash_profile should exist, and
should tell bash to run ~/.bashrc if it exists.  ~/.bashrc should be
telling bash to run /etc/bashrc.  Thus, if you put the PS1 command in
/etc/bashrc, it will be run for all users, and will overwrite the prompt
setting in /etc/profile, but each user still has the option to overwrite
your prompt by appending their own PS1 command to ~/.bashrc.

In the above paragraph, ~ stands for the user's home directory (same as
$HOME).  I hope this gives you something to start from.  Remember that the
HOWTO goes into much more depth on the subject, including colors and
running commands inside the prompt!

     -Matt

Reply via email to