tput command
tput is a command that provides the terminal dependent information to the shell .tput command queries the term info database for the information. Now let’s see how we can use the tput command to change the prompt color. Now let’s see how to change the color of the background and foreground of the prompt.
export PS1=”\[$(tput setaf 1)\]\[$(tput setab 7)\]\u@\h:\w $ \[$(tput sgr0)\]”
Following are the options that can be used with the tput command:
- tput bold –To apply the bold effect
- tput rev – To display inverse color
- tput sgr0 – To reset everything
- tput setaf {code}– To set the foreground color. See the table below to know the value of {code}
- tput setab {code}– To set background color, See the table below to know value of {code}
Color codes that are used with tput command:
Color {code} | Color |
---|---|
0 | Black |
1 | Red |
2 | Green |
3 | Yellow |
4 | Blue |
5 | Magenta |
6 | Cyan |
7 | White |
How to Customize Bash Colors and Content in Linux Terminal Prompt
If you are using the Linux operating system, that means you use the CLI most of the time. And do more work on the terminal. By default, most Linux Operating systems provide you the bash shell. Shell provides the interface between the user and kernel and executes commands. In this article, we are going to see how to customize the bash shell prompt