-
-
Save fred/aee82fdb3dea0180b6e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment