Thanks! Parsing git information without using git has always been mildly interesting to me :)
This is most definitely for zsh, FWIW; I choked slightly on `echo $var[1,12]` for a minute there. That's not a problem - you wrote this for your shell prompt, you use zsh, it makes sense to use zsh features - I'm just noting that others might need to do a bit of porting.
(I personally use bash by choice myself because it's the most widely installed shell and I don't want to switch until I fully know how to make the most concise and least surprising use of it.)