-
-
Save gregorynicholas/08a9c5624984ec7e0049 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
#!/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