...

/

The Prompt

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.

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:

Press + to interact
bash
PS1='My super prompt>>>> '
ls
exit
Terminal 1
Terminal
Loading...

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

Press + to interact
bash
PS2='I am in the middle of something!>>> '
cat > /dev/null << END
some text
END
exit

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.

PS4

...
Access this course and 1400+ top-rated courses and projects.