Bring color to your bash

Bring color to your bash

avatar

Clemens Kaserer

June 1, 2020

misc

If you work most of the time on the CLI like I do you might want to add a bit of color to your shell. With this customized bashrc you get a bash prompt streched over 2 line so you can easily see the user, host, path and git branch if you are in a git repository at a glance. In addition ls and grep are colorized if your system supports it. As always you can check out the sourcecode in the associated git repository on github at https://github.com/ckaserer/bash-bashrc.git.

nogit


nogit

Here is how

First we clone the git repository to your machine via

git clone https://github.com/ckaserer/bash-bashrc.git

Next we configure your ~/.bashrc to source the content of the bashrc file from the repo. We do that by adding the following line to the end of your ~/.bashrc.

if [ -f /path/to/bash-bashrc/bashrc ]; then . /path/to/bash-bashrc/bashrc; fi

What did we do just now?! By adding the line above to your ~/.bashrc we source the /path/to/bash-bashrc/bashrc file if the file exists on a new bash.

It won’t work right away since your ~/.bashrc is only read when you open a new shell. Either open a new shell by executing

bash

or source the /path/to/bash-bashrc/bashrc file manually in your current shell by executing

. /path/to/bash-bashrc/bashrc

Recent Blog Articles