- 1 Hyper-V 2012 R2: Pros and Cons of Generation 1 vs. Generation 2 VMs
- 2 Harnessing the Power of Hyper-V Network Virtual Switches
- 3 Working with SSH and Secure FTP Servers in Windows
- 4 Discover Windows 8's Hidden Server Features
- 5 Server Virtualization Customer Reviews: VMware, Hyper-V, XenServer and More
The Various bash Prompts
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?Tip of the Trade: 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
export PS1="u@h w$ "
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 -> "so it looks like:
juliet@glade:~ $ very-long-command-here more -> -with -lots -of -options
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:
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+ '
All of these can be made to be permanent changes by setting them in your ~/.bash_profile or ~/.bashrc file. (Note that this probably makes little sense to do for PS3, which is better to set per-script.)