Most people who have some experience with git are using, or at least have heard of, the git completion bash script. If you have not, I highly recommend you source this into your .bash_profile.
Right off the bat, you’re going to get auto-completion for just about every git command you can think of. Not only will you be able to auto-complete file paths, but also repository names. Not bad.
A lot of you are probably using aliases for your git commands as well. Using bash’s “complete”, you can get aliases to play nicely with git’s completion script. Here’s an example of how:
1 2 3 4 5 6 7 8
Now your aliases will be auto-completable, too.
How’s this work? The git completion script defines a corresponding function for each one of git’s commands, so mapping complete to each one of these is easy. If you’re curious, take a look at the function “__gitcomp” defined in the script, as well as all of the other functions that correspond with git commands.
You’ll also note that there’s a function in there named “__git_ps1”. If you know anything about bash, you can probably guess what that does. Try throwing this into your .bash_profile:
These are two really cool ways to take advantage of the git completion script and boost your productivity with bash.