git ready

learn git one commit at a time
by Nick Quaranto

zsh git status

committed 28 Jan 2009

Sure, you could have status shown in your bash prompt but that’s not your only option for shells! zsh, or Z Shell is another popular command line interface that is in use by plenty of programmers, and there’s quite a few scripts that will get your repo’s status shown easily and quickly.

Joshua Corbin has thrown together a fantastic set of scripts dubbed zsh-git that provides a great mix of colors and information about your repository. The basics are explained on the project page but images are a lot more fun.

This is what the shell looks by default. Plenty of colors, and even using both sides of the screen! In a repository with no changes, it shows the branch name and where HEAD is currently pointing:

Once a change is made, a ! appears (git status is run since the author can’t break habits easily) If untracked files are created, it adds ? to the prompt, and adding files causes a + to be printed to the prompt. Also, if you’re tracking the branch, it will alert you and let you know when you’re ahead in commits.

If you’re looking for a more DIY version, Bart Trojanowski has a great tutorial on adding branch status that can be easily extended. If you’re looking for another nice and easy zsh setup, zshkit and its various forks are fun to use and come packaged with plenty of helper commands.

Of course, if you have other zsh scripts or different shells that deserve their own tip, submit one!