Archive for -
VCS in Shell Prompt

Jesus Rodriguez recently posted about putting git information into his shell prompt with the mention that bash is the one and only shell ("In bash (is there really any other shell?)…"). I'd like to present my prompt as proof that bash is not the end-all-be-all shell. I have been using zsh for a while now and have had information on the VCS for the repository I'm currently browsing for a while. For git it usually looks like this:

Wed May 19 15:32:07: ~/code/stater/src

boeckb@waddledoo %
(git)-[master]

while for Mercurial it looks like this:

Wed May 19 15:34:55: ~/code/lugaru/src

boeckb@waddledoo %
(hg)-[default]

and for Subversion:

Wed May 19 16:04:11: ~/code/kross/src

boeckb@waddledoo %
(svn)-[kross:1128640]

This is all possible due to the awesome vcs_info plug-in that zsh has available. It includes support for all of the version control systems I use (git, cvs, svn) as well as those I encounter in other projects (hg, darcs) that I have checkouts of laying around.

I also like to have my prompt start at a consistent spot in the shell, so I put the date and current directory on the line before the actual prompt. Currently the vcs_info is set as RPROMPT since I've tried and failed to get it to right align on the first line (I wish zsh had %= as a filler space similar to screen).

Git bisect

Recently I had the joy of using git bisect to find a bug that I had introduced in a repository. Honestly, the beauty of it almost makes me want to make more mistakes when coding. I first tell git that some thing is broken and that it used to work:

git bisect start
git bisect bad
git bisect good <some revision from yesterday>

After this, git will then start walking me through the history to determine where the code went wrong. I tell git whether the current commit is good (git bisect good) or bad (git bisect bad). Some of the commits are untestable (due to a failure to compile with commits that dealt with an API change being propagated through the code base) which I tell git to skip (git bisect skip).

Unfortunately the code base was not as uniform as I usually like it to be so I missed an opportunity to have git do everything for me. Build failures destroy this since they have to be skipped and are neither good nor bad (though reading the documentation, using 125 as the exit code has git skip that revision). With a script that tested each revision, git could have done the testing for me (git bisect run ./my_script arg1 arg2).

I'm glad git bisect exists. Anyone else ever used it?

Done!

So I'm finally done with schoolwork. Woo! I had my last final yesterday and the irony of it is that the final class I have here is an introductory course in a field with little to no relation to my major (at the very least my concentration). The Introduction to Biology course here is required of all those who are in the School of Science and that includes computer science majors.