The Prompt
In this lesson, you will learn how to set up your main prompt, as well as other types of prompts and related shell variables.
We'll cover the following...
Now that you’ve learned about escapes and special characters you are in a position to understand how the bash prompt can be set up and controlled.
How Important is this Lesson?
This lesson is not essential, but most people find it interesting and maybe fun to learn about.
The PS1
Variable
Type this:
bashPS1='My super prompt>>>> 'lsexit
As you’ll remember, there are some shell variables that are set
within bash that are used for various purposes. One of these is PS1
, which is
the prompt you see after each command is completed.
The PS2
Variable
bashPS2='I am in the middle of something!>>> 'cat > /dev/null << ENDsome textENDexit
The PS2 variable is the ‘other’ prompt that the shell uses to indicate that you
are being prompted for input to a program that is running. By default, this is
set to >
, which is why you see that as the prompt when you normally type the
cat
command above in.
PS3
PS3
is used by the select
looping structure. We don’t cover that in this
book as I’ve barely ever seen it used.