Skip to content

Instantly share code, notes, and snippets.

@zerodogg
Created October 12, 2009 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerodogg/208248 to your computer and use it in GitHub Desktop.
Save zerodogg/208248 to your computer and use it in GitHub Desktop.
Dynamically load git bash completion
# Dynamically load git bash completion
function __LoadGitBashCompl ()
{
# Remove the existing placeholder completion
complete -r git
# Load the full completion if it exists
if [ -e "/etc/bash_completion.d/git" ]; then
source "/etc/bash_completion.d/git"
_git "$@"
else
# Fall back to some basic completion if the full one does not exist
complete -W "add blame checkout commit diff help merge mkdir move stat status branch push pull clean log rebase reset tag clone cherry-pick" -A file git
fi
}
# Calls __LoadGitBashCompl the first time git completion is accessed
complete -o default -o nospace -F __LoadGitBashCompl git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment