Learn
Environment
PS1 Environment Variable

PS1 is an environment variable that defines the makeup and style of the command prompt.

What happens when this is stored in ~/.bash_profile?

export PS1=">> "
  1. export PS1=">> " sets the command prompt variable and exports the variable. Here we change the default command prompt from $ to >>.
  2. After using the source command, the command line displays the new command prompt.

Let’s try it out!

Instructions

1.

Open ~/.bash_profile in nano.

2.

On a new line, beneath the last entry, set the PS1 variable equal to ">> " (make sure there is one space follow >>).

Save the file and exit nano, and press Enter into a new line in the terminal.

3.

Use source to make the changes in ~/.bash_profile available. The command prompt should now look like >>

4.

Let’s try out the new command prompt. In the terminal, type:

echo "hello"
5.

Now type:

ls -alt

In the past two commands, did you notice that the command prompt has changed and is no longer $?

Folder Icon

Sign up to start coding

Already have an account?