Created
August 5, 2010 21:40
-
-
Save twerth/510424 to your computer and use it in GitHub Desktop.
Skeleton for bash completion ruby script
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