aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2014-05-12 16:01:13 +0200
committerMathias Bynens <mathias@qiwi.be>2014-05-12 16:08:07 +0200
commitbc96ac1c1e6bcf63a3283d481aea22e1b5206919 (patch)
tree0ca6f031ca56790385b4dfcca3f3b92802cb5021
parent52abe37d2f9724e1d88a85cf6181b04a8dd756c4 (diff)
downloaddotfiles-bc96ac1c1e6bcf63a3283d481aea22e1b5206919.tar.gz
dotfiles-bc96ac1c1e6bcf63a3283d481aea22e1b5206919.tar.bz2
dotfiles-bc96ac1c1e6bcf63a3283d481aea22e1b5206919.zip
.bash_profile: Enable tab completion for `git` and `g`
Closes #197.
-rw-r--r--.bash_profile13
-rwxr-xr-xBrewfile1
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