Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 33 down vote accepted

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.

share|improve this answer
16  
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
1  
@AnsgarEsztermann, your comment could be an answer as well (which I would vote up). –  maxschlepzig Feb 19 '12 at 17:19
    
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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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