What are PS1, PS2, PS4 variables for?
Hi,
Can somebody please tell me what are the following variables for and how are these working PS1=’[\u@\h \W]\$ ‘ PS2=’> ‘ PS4=’+ ‘ In PS1, what are "\u", "\h" and "\W"? thnaks |
For \u \h and others look here
http://tldp.org/HOWTO/Bash-Prompt-HO...sequences.html For PS1, PS2, PS3 and PS4, type ni a terminal man bash when the man page comes up, hit the slash key / and type "PS2" without quotes. So it looks like this /PS2 then hit enter. PS1 describes your prompt. |
thanks, it helped. Still a little confused about PS4. Can u please help with that.
|
PS4 is the symbol that marks executed lines in a traced script. Let me give you a little example
Code:
#!/bin/bash |
Well, the terminal prompt also includes the path of the directory. This is annoying sometimes. I can set it to my choice by using PS!="my-choice", but how can I set it permanently? I mean, if I close the terminal and open it again, I should be able to see the previously set value.
|
Quote:
In it, type the command export PS1="whatever_you_want" Don't forget to put an empty line at the end of the script. That's it. |
And don't forget to check your prompt string. It is even more annoying if you forgot to escape some portion (for example if you choose to colorize the prompt).
In such cases if you use the bash, weird things may happen. For example that your prompt is suddenly only half displayed or characters of commands' outputs are misplaced and so on. |
http://en.wikipedia.org/wiki/ANSI_escape_code might be helpful in learning how to add color to prompt strings.
|
Yeah, I have done all that. Thanks. I have changed it for root too, including color.
|
All times are GMT -5. The time now is 07:17 AM. |