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 ++++++++++--- Brewfile | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) 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 diff --git a/Brewfile b/Brewfile index 6ddcdc6..b7c1748 100755 --- a/Brewfile +++ b/Brewfile @@ -18,6 +18,7 @@ install findutils install gnu-sed --default-names # Install Bash 4 install bash +install bash-completion # Install wget with IRI support install wget --enable-iri -- cgit v1.2.3