Skip to content

Instantly share code, notes, and snippets.

@vigo
Last active July 20, 2016 02:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vigo/5008330 to your computer and use it in GitHub Desktop.
Save vigo/5008330 to your computer and use it in GitHub Desktop.
Bash completion for bundle
_bundler_complete()
{
if [[ ! `which bundle` ]]; then
return
fi
local cur prev commands
commands="help install update package exec config check list show outdated console open viz init gem platform"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ "${cur}" == -* ]]; then
local bundle_options="--no-color --verbose"
COMPREPLY=( $(compgen -W "${bundle_options}" -- ${cur}) )
return 0
fi
case "${prev}" in
"rake")
if [[ ! -e Rakefile ]]; then
return
fi
local rake_options=$(bundle exec rake -T | awk '{print $2}' | xargs)
COMPREPLY=( $(compgen -W "${rake_options}" -- ${cur}) )
return 0
;;
"exec")
bin_folder=( $(find . -name 'bin' | xargs) )
executables=`command ls ${bin_folder} | xargs`
commands="${commands} rake ${executables}"
;;
esac
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
}
complete -F _bundler_complete bundle
@alexistoulotte
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment