9
Jul
2008
 

A git quickie

by Marcus Zarra

After reading Fraser Speirs’ excellent write-up on his conversion over to git, I followed a few of the links to find a bash script to display your current git branch in the command prompt. Following yet another link from that post showed how to convert the bash script to zsh.

Here is my contribution to move that from the prompt to the right side of the screen.

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function precmd() { RPS1="%~$(parse_git_branch)" }
export PS1='> '

Note that the last line just gives me a very short left hand prompt which I prefer.

GitBranchDisplay
Uploaded with plasq‘s Skitch!

Comments

jagipson says:

Thank you for your informative article. I was a Windows programmer until .NET was rolled out. Disgusted by the prospect of having to relearn everything after all the time I had invested in learning Win32/COM/ActiveX I turned away from GUI programming and banished myself to the land of various scripting and shell languages. For the last couple of years I’ve been trying to get a handle on Cocoa but I keep stumbling on the MVC architecture (And since I have Rails experience one wouldn’t expect it).

My questions are more philosophical in nature. The tone of most MVC programmers is from the core assumption that everyone understands and agrees with the virtues of MVC. From my ragged attempts at Cocoa, I found most of my code goes in Controllers. If the purpose of MVC is to provide the ability to recycle View code and Model code, but 90% of my code goes in the Controller which has to be thrown away (or modified) if either the Model or View change, then why use MVC? I’m obviously missing something about MVC. What is it?

And please don’t flame me for putting my cards on the table. What good is the public forum if everyone that appeals to it risks a flogging. If people lazily dismiss me as dense, then I shall have to retreat back to my Unix Ivory tower and will never learn to love Cocoa. Thanks.

Matt Long says:

This is a good comment, but it looks like you posted it in the wrong place. Feel free to repost it in the Windows OOP vs Cocoa MVC comments section.

Thanks.

-Matt