It's fairly likely that you already have a personalized setting for PS1, the default bash interaction prompt. But what about the others available: PS2, PS3, and PS4?

Most likely, you already have a personalized setting for PS1, the default bash interaction prompt. Here's what to do with PS2, PS3 and PS4.

PS1 is the default interaction prompt. To set it to give you

username@host:directory$

export PS1="u@h w$ "

~/.bash_rc

u

h

w

usein youris the current username,the current host, andthe working directory. There's a list of escape codes you can use in the bash man page, or in the Bash Prompt HOWTO

PS2 is the prompt you get when you extend a command over multiple lines by putting at the end of a line and hitting return. By default it's just > , but you can make this a little more obvious with:

export PS2="more -> "

juliet@glade:~ $ very-long-command-here more -> -with -lots -of -options

so it looks like:

PS3 governs the prompt that shows up if you use the select statement in a shell script. The default is #?, so if you do nothing to change that, the select statement will print out the options and then just leave that prompt. Alternatively, use this:

PS3="Choose an option: " select i in yes maybe no do # code to handle reply done

1) yes 2) maybe 3) no Choose an option:

which will output:Far more readable for the user!

Finally, PS4 is the prompt shown when you set the debug mode on a shell script using set -x at the top of the script. This echoes each line of the script to STDOUT before executing it. The default prompt is ++ . More usefully, you can set it to display the line number, with:

export PS4='$LINENO+ '