« Software Update is dumb | Main | .bash_completion.d »

git bash completion

If you download the git tarball, you'll find a git-completion.bash script that adds shell completion to your git day-to-day usage. Look for it in the contrib/completion/ directory. (update: if you can't find it there, look for it in the $sharedir/git-completion/ directory. A recent patch by Johannes Schindelin promoted git-completion.bash to the big leagues.)

When I started using git, I just sticked the script into my ~/.bash_completion.d/ and bash picked it up after a exec bash -login.

One thing I didn't do was read the file, and I missed some cool stuff. One of them is a PS1 hack to show the branch you are on:

4) Consider changing your PS1 to also show the current branch: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

The argument to __git_ps1 will be displayed only if you are currently in a git repository. The %s token will be the name of the current branch.

Be careful to use '' and not "" in the PS1= statement.

If you have several branches active at the same time, this really helps.

Contacts

melo@simplicidade.org (XMPP/email)
+351 302 029 050 (voice)
melopt (Skype)

IronMan challenge

Iron Man badge Are you ready to be an Iron Man? Join the challenge and find out! (what is the meaning of this little man?)

Moosaico

Junta-te!

Recent Comments

Powered by Disqus
Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.2