The caveat of keeping every little project on my hard drive in a git repo is that I often forget to commit/push when I make changes, leading to mega-commits with descriptions like “everything since last march, whatever that is”. Also, I tend to forget about topic branches, accidentally committing maintenance fixes to some radical experimental branch that’s been broken forever.

So, I rigged my bash prompt to remind my about all this:

Purple is the current branch, red files are changed but not added, green are changed and added. If the line gets too long, it starts condensing things to (31 files) or the like.

The magic behind this is the Ruby script below. To make it work, point the PROMPT_COMMAND environment variable at the script and set PS1 to whatever you want on the second line (:: in that screenshot).

Update: This has already been done in pure bash, with more features: http://volnitsky.com/project/git-prompt/

blog comments powered by Disqus