CS 279 - Week 10 Lab - 10-24-12
(OK, created this after-the-fact, based on the screen
shot of our playing with PS1 during lab.)
* you can set environment variable PS1 to change your
UNIX/Linux command prompt.
* before you start playing with it, it is advisable
to SAVE the current value for more convenient
resetting back:
SAVE_PS1=$PS1
* (change it in your current session? it only stays
in effect for the current session, because changes
to environment variables only change the current
session's copy of those variables.)
* But if you find a prompt style you like,
you can add that setting of PS1 to your .bashrc
file, so it is set whenever you start up an
interactive bash shell.
* so:
$ PS1="moo> "
moo>
...changes your command prompt to "moo> ".
* there are many special characters you can use to
insert useful values into your command prompt --
a list of these can be found in the GNU Bash Reference
Manual, at:
http://www.gnu.org/software/bash/manual/bashref.html#Printing-a-Prompt
* here are a few:
\a - causes a bell "character" to be played
(makes a distinctive "thunk" on my Mac).
\d - displays date as Day Mon DD.
\l - gives number of device.
\n - inserts a newline into prompt.
\t - inserts time in 24-hour format, HH:MM:SS.
\T - inserts time in 12 hour format, HH:MM:SS.
\v - inserts the bash version number.
\V - inserts the bash version and patch number.
\! - inserts the current history command number.
\u - inserts the username.
\h - inserts the hostname (up to the first .).
\W - inserts the basename of the current working directory.
...and you can find more at that link mentioned earlier.