Skip to content
Browse files

bash: Make some completion loading and aliasing conditional

  • Loading branch information...
1 parent d3b1e1d commit f67f95965af7246fd1570c068093e76957771c72 @ches committed Feb 2, 2013
Showing with 34 additions and 10 deletions.
  1. +14 −2 .bash.d/aliases.sh
  2. +4 −1 .bash.d/completion.sh
  3. +9 −0 .bash.d/functions.sh
  4. +7 −7 .bashrc
View
16 .bash.d/aliases.sh
@@ -47,10 +47,22 @@ alias myip='curl ifconfig.me'
#
# Version Control
#
-alias mq='hg -R $(hg root)/.hg/patches'
+if installed hg; then
+ alias mq='hg -R $(hg root)/.hg/patches'
+fi
+
+if installed hub; then
+ alias git=hub
+fi
# Create a simple .rvmrc in the current dir using the current Ruby and gemset
-alias mkrvmrc='echo "rvm `rvm-prompt i v g`" > .rvmrc'
+if installed rvm; then
+ alias mkrvmrc='echo "rvm `rvm-prompt i v g`" > .rvmrc'
+fi
+
+if installed bundle; then
+ alias be='bundle exec'
+fi
#
# OS X
View
5 .bash.d/completion.sh
@@ -13,7 +13,10 @@ source ~/.bash.d/completion-knife.sh
source ~/.bash.d/completion-git.sh
source ~/.bash.d/completion-hg.sh
source ~/.bash.d/completion-VBoxManage.sh
-complete -W "$(sake -T | awk {'print $2'})" sake
+
+if installed sake; then
+ complete -W "$(sake -T | awk {'print $2'})" sake
+fi
#
# Rake
View
9 .bash.d/functions.sh
@@ -1,3 +1,11 @@
+# Check if a command is installed. For some reason that I can't remember, this
+# is deemed superior to `which`.
+function installed {
+ local cmd=$1
+ command -v ${cmd} >/dev/null
+}
+
+
#
# OS X
#
@@ -75,3 +83,4 @@ if [ "$(uname -s)" == "Darwin" ]; then
fi
}
fi
+
View
14 .bashrc
@@ -58,24 +58,24 @@ export LESS="-R"
export LESSOPEN="|lesspipe.sh %s"
#
-# Completion
+# Functions for great justice
#
-if [ -f ~/.bash.d/completion.sh ]; then
- . ~/.bash.d/completion.sh
+if [ -f ~/.bash.d/functions.sh ]; then
+ . ~/.bash.d/functions.sh
fi
#
-# Aliases for great justice
+# And aliases for all mankind
#
if [ -f ~/.bash.d/aliases.sh ]; then
. ~/.bash.d/aliases.sh
fi
#
-# And functions for all mankind
+# Completion
#
-if [ -f ~/.bash.d/functions.sh ]; then
- . ~/.bash.d/functions.sh
+if [ -f ~/.bash.d/completion.sh ]; then
+ . ~/.bash.d/completion.sh
fi
# ====================================================

0 comments on commit f67f959

Please sign in to comment.
Something went wrong with that request. Please try again.