From bc96ac1c1e6bcf63a3283d481aea22e1b5206919 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 12 May 2014 16:01:13 +0200 Subject: .bash_profile: Enable tab completion for `git` and `g` Closes #197. --- .bash_profile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to '.bash_profile') diff --git a/.bash_profile b/.bash_profile index 0d8af54..ba564c9 100644 --- a/.bash_profile +++ b/.bash_profile @@ -25,6 +25,16 @@ for option in autocd globstar; do shopt -s "$option" 2> /dev/null done +# Add tab completion for many Bash commands +if which brew > /dev/null && [ -f "$(brew --prefix)/etc/bash_completion" ]; then + source "$(brew --prefix)/etc/bash_completion" +fi + +# Enable tab completion for `g` by marking it as an alias for `git` +if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then + complete -o default -o nospace -F _git g +fi + # Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards [ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh @@ -34,6 +44,3 @@ complete -W "NSGlobalDomain" defaults # Add `killall` tab completion for common apps complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall - -# If possible, add tab completion for many more commands -[ -f /etc/bash_completion ] && source /etc/bash_completion -- cgit v1.2.3