-
-
Save eentzel/8288678 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
# bash function | |
defcomp () { | |
local name="$1" && shift | |
local functionName="$( echo "${name}_completion" | tr - _ )" | |
source <(cat <<EOM | |
$functionName () { | |
local cur | |
_get_comp_words_by_ref -n =: cur | |
COMPREPLY=( \$(compgen -W "\$( $@ )" -- "\$cur") ) | |
} | |
EOM | |
) | |
command complete -F "$functionName" "$name" | |
} | |
# command line | |
% defcomp gemnames gem list --no-versions | |
% gemnames <tab> | |
addressable ffi highline mini_portile rb-appscript rspec-mocks text-hyphen | |
bigdecimal formatador httparty minitest rb-fsevent ruby2ruby thor | |
builder gherkin httpauth multi_json rb-inotify ruby_parser tins | |
bundler github io-console multi_test rb-kqueue safe_yaml tty | |
coderay github_api json multi_xml rdoc sexp_processor vcr | |
colorize github_cli json_pure multipart-post reek simplecov webmock | |
coveralls growl jwt nokogiri rest-client simplecov-html | |
crack growl_notify launchy oauth2 ripper_ruby_parser slop | |
cucumber guard listen pry roodi spruz | |
descendants_tracker guard-cucumber lumberjack psych rspec term-ansicolor | |
diff-lcs guard-rspec method_source rack rspec-core test-unit | |
faraday hashie mime-types rake rspec-expectations text-format | |
% gemnames f<tab> | |
faraday ffi formatador |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment