Improving your shell – GCC and command line colors
In this recipe, we are going learn how a user can improve the shell. We will do this using the PS1 bash environment variable.
Getting ready
Besides a terminal, you need basic knowledge of PS1.
Â
How to do it...
The terminal appearance is taken by the PS1
shell variable. The content allowed in PS1
will contain backslash-escape special characters.
First, we will see what PS1's current contents in the system. For that, run the following command:
$ echo $PS1
![](https://static.packt-cdn.com/products/9781788629362/graphics/c3c849e1-61c2-4f88-9403-1a8f82dcf3a1.jpg)
Here are the backslash-escape special characters:
\u
: Current username\h
: Hostname\W
: Current working directory\$
: Will display#
if the user is root; otherwise it will display $ only\@
: Current time in 12-hour AM/PM format
Now, we will modify our Bash. Run the following command:
$ PS1="[\\u@\\h \\W \\@]\\$"
![](https://static.packt-cdn.com/products/9781788629362/graphics/e121f791-5b98-42e7-99ce-1a616040810c.jpg)
Now, we will write a command to change the colors.
To make the text color blue, run the following command:
$ PS1="[\\u@\\h \\W \\@]\\$\\e[0;34m"
![](https://static.packt-cdn.com/products/9781788629362/graphics/03a71b3e-e505-454e-b374-35a6d6d5bd52.jpg)
Â
Â
Now we, will see the tput
command. Run the following...