O'Reilly logo

The Linux Command Line by William E. Shotts Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Trying Some Alternative Prompt Designs

With this list of special characters, we can change the prompt to see the effect. First, we’ll back up the existing string so we can restore it later. To do this, we will copy the existing string into another shell variable that we create ourselves:

[me@linuxbox ˜]$ ps1_old="$PS1"

We create a new variable called ps1_old and assign the value of PS1 to it. We can verify that the string has been copied by using the echo command:

[me@linuxbox ˜]$ echo $ps1_old
[\u@\h \W]\$

We can restore the original prompt at any time during our terminal session by simply reversing the process:

[me@linuxbox ˜]$ PS1="$ps1_old"

Now that we are ready to proceed, let’s see what happens if we have an empty prompt string:

[me@linuxbox ˜]$ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required