How to integrate vcprompt with bash shell to show git information in Ubuntu

If you are using git in Linux then you might have hit command ‘git status’ to find out in which branch are we currently on, whether there are any changed contents or any uncommitted changes. Wouldn’t be nice if we can get those git information easily so that we need not hit that command frequently. ‘vcprompt’ is the solution here. You can easily integrate vcprompt in bash prompt so that we can see git information from the prompt itself. Lets discuss some steps to integrate vcprompt in bash. I am using Ubuntu 12.10 here. It should also work in other similar Linux variations.

vcprompt is a script to show version control information in the command prompt. This script is written by djl. vcprompt is heavily inspired by Greg Ward’s original implementation in C.


Requirements: Python 2.4 or later

You can check Python version from following command.

python --version

If curl is not installed in your systemm then you have to install curl first.

sudo apt-get install curl

How to do?

Download vcprompt script and make it executable.

sudo curl -sL https://github.com/djl/vcprompt/raw/master/bin/vcprompt > ~/bin/vcprompt

sudo chmod 755 ~/bin/vcprompt

Now we have to setup bash to use vcprompt.For this you we need to modify .bashrc file

gedit ~/.bashrc

Copy the following code and paste it in the end of the file.

PS1='n�33[0;34mu@h:�33[0;31mw �33[01;35m $(vcprompt -f '[%b%m%u%a]')�33[00m n> '

Save the file and close the editor. Enter following command.

source ~/.bashrc

Hmm…now you get nice looking prompt. If you are in the git working folder then you will see current branch and other git informations.

Dont forget to check README file of vcprompt for more customization options.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.