
Git info in your ZSH Prompt - duck
http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
======
aditya
I've been really digging oh-my-zsh recently for extending zsh, comes with a
great plugin architecture and all sorts of cool shit:
<http://github.com/robbyrussell/oh-my-zsh>

~~~
sudonim
Beat me to the punch... Oh-my-zsh ftw. Robby Russell has a great blog about
rails development too. <http://www.robbyonrails.com/>

------
l0stman
Note also that there's a more feature complete version that accomplishes the
same tasks in the contrib directory of git
([http://git.kernel.org/?p=git/git.git;a=blob;f=contrib/comple...](http://git.kernel.org/?p=git/git.git;a=blob;f=contrib/completion/git-
completion.bash;h=f83f019ca91a2611f5bd3474ccf6d10081320c4c;hb=HEAD)).

It's implemented in bash but I use it with almost no modification with the
Korn shell.

~~~
avar
You linked to the wrong version, given the topic of this thread.

Recently ZSH support has been added to git-completion.bash, but it's still
only in the "next" branch of git:
[http://git.kernel.org/?p=git/git.git;a=blob_plain;f=contrib/...](http://git.kernel.org/?p=git/git.git;a=blob_plain;f=contrib/completion/git-
completion.bash;hb=next)

------
avar
You can also use Git's own __git_ps1 from git-completion.bash in either bash
or in zsh (see my other comment). Here's an example of it in use:
<http://github.com/avar/dotfiles/blob/master/.bashrc#L86>

It doesn't give you info about whether you have staged files (but maybe it
should). But it gives you a bunch of other neat stuff, like whether you're in
a git-rebase or git-am operation

~~~
gruseom
It definitely can tell you whether you have staged files, because I use it for
that among other things. I don't remember how I turned that feature on, but it
wasn't hard. Perhaps someone will chime in with the details.

~~~
l0stman
Just add the following lines in your .bashrc:

    
    
        export GIT_PS1_SHOWDIRTYSTATE=yes
        export GIT_PS1_SHOWUNTRACKEDFILES=yes

~~~
avar
Thanks. I didn't know about those. I've configured them in my ~/.bashrc now:
<http://github.com/avar/dotfiles/commit/43454870>

------
silentbicycle
Wow, am I the only person who prefers a shell prompt of just "$ "?

I have a bunch of abbreviations for common git commands, though, so I guess it
balances out.

~~~
krakensden
You're not- I can't stand waiting 3-5 seconds every time I hit enter, just so
I can have a more verbose prompt that tells me things I already knew.

~~~
paulbaumgart
The one I wrote, for Bash, uses SIGALRM (via the Time::HiRes perl module) to
time out after half a second: <http://github.com/paulbaumgart/git-situational-
awareness>

~~~
bostonvaulter2
It would be cool to do the opposite as well, don't start checking the fancy
vcs stuff until 1/2 second after the prompt is loaded.

~~~
paulbaumgart
Agreed. I don't think Bash allows async function execution, though.

------
kevincolyar
I've started using the oh-my-zsh project.

<http://github.com/robbyrussell/oh-my-zsh>

Has all sorts of themes, and most have git status.

------
kree10
I love that vcs_info works with more than just git. Having my prompt tell me
what VCS I'm under (even knowing the difference between git and git-svn) and
what branch I've got checked out helps me mentally switch gears as soon as I
cd into a directory.

------
elbenshira
There are a ton of these out there nowadays. A lot of them are OK, but I use:
<http://github.com/olivierverdier/zsh-git-prompt>

~~~
bostonvaulter2
I was just about to post that. I actually made a few patches (pulled by
olivier) to make the prompt work better on Mac OSX.

