Customizing and colorizing Linux bash prompt

62 views

bash

Overview

Sometimes you get bored with the way the bash prompt looks like and you want to customize it by adding some useful features or changing colors. The default Bash prompt usually ends with a dollar sign $. Bash itself will show its major and minor version (\s-\v\$), for example, bash-3.00$. Most Linux distributions redefine the prompt to include additional information, such as your current login and computer, which is useful when you’re moving between accounts and computers. In order to customize the bash prompt we need to modify the $PS1 and $PS2 environment variables by our desire.

Bash will use the value of the $PS1 variable for your main prompt. If you include variable names in the string, Bash will substitute the value of the variables into your prompt. Bash has a PS2 (prompt string 2) variable, which is the prompt for incomplete command lines such as when you use a multiline quotation. By default, this prompt is a greater-than sign (>).

Continue reading…