| Basic Linux Operations FAQ | ||
| Part 3 of the Linux Newbie Administrator Guide | ||
3.4.2 How do I customize my shell prompt?On my machine, the prompt may look like this:[stan@marie stan]$ _ Here "stan" is my login name, "marie" is the name of the computer, the second "stan" is the name of my current working directory, and "_" represents the cursor. The prompt is set by the environmental variable called PS1. To display the current setting, I can use: echo $PS1 The system-wide setting of the prompt (for all users on the system) is in the file /etc/bashrc which on my system contains such a line: PS1="[\u@\h \W]\$ " To customize the prompt, I can edit the file /etc/bashrc (as root) and insert almost any text inside the quotation marks. Here is the meaning of some special codes I may also choose to use: \u
- username of the current user (= $LOGNAME), Here is an example on how to add colour. See the next chapter for details about colour: PS1="\[\033[1;32m\][\u@\h \W]\$\[\033[0m\] " There is also the second-level prompt, set by a variable called PS2. The shell uses the second level prompt when it expects additional input, and on my system the secondary prompt is "> ". I don't worry too much about PS2, but if I did I could set it the same way as PS1. There are even PS3 and PS4, but these are rarely seen. Next > 3.4.3 Colour on text terminal
|
||

