The environment variable for the bash prompt is called PS1 (usually set in ~/.bashrc). What does PS1 stand for? Is there a PS2?


PS1 stands for "Prompt String One" or "Prompt Statement One", the first prompt string (that you see at a command line).

Yes, there is a PS2 and more! Please read this article and the Arch wiki and of course The Bash Reference Manual.

| improve this answer | |
  • 28
    Briefly, PS2 is for continued commands (those taking more than one line), PS3 is for input into a running script, and PS4 is for tracing/debugging. – Ansgar Esztermann Feb 19 '12 at 14:12
  • 3
    @AnsgarEsztermann, your comment could be an answer as well (which I would vote up). – maxschlepzig Feb 19 '12 at 17:19
  • 1
    Re: $PS3. An example of its use is to change the prompt of the select command by first setting PS3, eg. PS3="Select by typing the number: " – Peter.O Feb 20 '12 at 0:03

from slightly paraphrased from The Bash Reference Manual

PS1 The primary prompt string. The default value is ‘\s-\v\$ ’.

PS2 The secondary prompt string. ie for continued commands (those taking more than one line). The default value is ‘> ’.

PS3 The value of this variable is used as the prompt for the select command. ie for input into a running script. If this variable is not set, the select command prompts with ‘#? ’.

PS4 The value is the prompt printed before the command line is echoed when the -x option is set. The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection. The default is ‘+ ’.

PS1 and PS2 are from the original sh, PS3 and PS4 were added as part of bash

See examples here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.