trevmex's tumblings

JavaScripter, Rubyist, Functional Programmer, Agile Practitioner.

Adding git rebase info to your bash prompt

The Script

The Screenshot

The Explanation

I use git and gerrit at work, and I find it very important to quickly be able to see some basic information about the code I am working on. Mainly:

  • What branch I am on.
  • If my branch is dirty.
  • If I am in the middle of a rebase.

That last one is really important. There are lots of other versions of git prompts out there, but none of them included rebasing information.

I can’t tell you how many times I have been in the middle of fixing a rebase merge conflict, got distracted, and then forgot I was doing it. Later I would try and commit and my changes would be in limbo. Very annoying.

If you add the above code snippet to your ~/.bashrc file (in Mac OS X or any other *NIX) and then type:

source ~/.bashrc

you should see your bash prompt change if you are in a git repository. It has made my life a LOT easier. I hope it helps you, too.

If you want to see my full bash setup, check out my dotfiles on github.

Notes

  1. trevmex posted this