In OSX Bash you could use to autocomplete file paths. You can also use My Dotfiles to get tab completion for SSH hostnames based on ~/.ssh/config and many more commands.
You need to get the .git-completion.bash
from Repository or you cand use this command in your terminal:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
Then you need to update your .bash-profile
file with:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
Now you need to restart your terminal and after you type git c
then hit TAB
key you can see all the git commands that start with c letter.
How to make it work with aliases
Let’s say you have aliases for:
alias g ='git'
alias gco = 'git checkout'
You can use __git_complete
function from git-completion.bash
which can be used to set up completion for aliases. Update your .bash-profile
file with:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
__git_complete g __git_main
__git_complete gco _git_checkout
fi