Change those command-line colors

The default BASH colors are bearable but maybe you want something else. Myself, I prefer oranges and reds with a little bit of blue mixed in for good measure. Fortunately, in BASH, it’s easy to customize the colours of your shell.

When starting a terminal, BASH reads the .bashrc file to configure how it will display. The .bashrc file is located in your home directory, so within a terminal go home.


Now, rather than define colors within the .bashrc, I prefer to create another file to hold my color configuration.

If you do

touch .$USER\TerminalTweak

then you’ll get a hidden file in your current (home) directory named .UsernameTerminalTweak (Username will be your username).

Open that up with your favorite text editor (I like to use nano for my editing).

nano .UsernameTerminalTweak

And paste the following into it.

function prompt
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local RED="\[\033[0;31m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
local BLACK="\[\033[0;30m\]"
export PS1="
$ "

Save the file and then open up your .bashrc

Paste the following at the end of the file.

if [ -f ~/.bashrc ]; then
        source ~/.UsernameTerminalTweak

Now restart your terminal (close and reopen it).

You’ll end up with something like:

Username@PCName ~

If you don’t like my color scheme then change the color code in .UsernameTerminalTweak to whatever you like.

Leave a Reply

Staypressed theme by Themocracy