From 9fdcb0ccb6be88e4ab358d8298acc59dea21338d Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Thu, 16 Aug 2012 10:03:24 +0200 Subject: [PATCH] better bash completion compatibility with non-brew --- bash/completion | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bash/completion b/bash/completion index 4e0196d..2309e5b 100644 --- a/bash/completion +++ b/bash/completion @@ -1,6 +1,10 @@ -# homebrew bash autocompletion -if [ -f `brew --prefix`/etc/bash_completion ]; then - source `brew --prefix`/etc/bash_completion +# default bash autocompletion +bash_completion_file="/etc/bash_completion" +if which brew >/dev/null; then + bash_completion_file="`brew --prefix`$bash_completion_file" fi +[[ -f $bash_completion_file ]] || unset bash_completion_file +[[ -n "$bash_completion_file" ]] && source "$bash_completion_file" +unset bash_completion_file # vim: ft=sh