Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Forked from twerth/gist:510424
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregorynicholas/08a9c5624984ec7e0049 to your computer and use it in GitHub Desktop.
Save gregorynicholas/08a9c5624984ec7e0049 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# To use, put this in your bashrc:
# complete -C path/to/script -o default your_command_or_commands_here
# example, to complete the foo and bar commands with the foo.rb script: complete -C ~/bin/foo.rb -o default foo bar
prefix = ARGV[1]
words = `some command here, or just any array`.split.uniq
words = words.select {|w| /^#{Regexp.escape prefix}/ =~ w} if prefix
puts words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment