Created
December 9, 2008 21:04
-
-
Save agile/34088 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 | |
# Complete rake tasks script for bash | |
# Save it somewhere and then add | |
# complete -C path/to/script -o default rake | |
# to your ~/.bashrc | |
# Nicholas Seckar <[email protected]> | |
exit 0 unless File.file?(File.join(Dir.pwd, 'Rakefile')) | |
exit 0 unless /^rake(?:\s+([-\w]+))?\s*$/ =~ ENV["COMP_LINE"] | |
task_prefix = $1 | |
tasks = `rake --tasks`.split("\n")[1..-1].collect {|line| line.split[1]} | |
tasks = tasks.select {|t| /^#{Regexp.escape task_prefix}/ =~ t} if task_prefix | |
puts tasks | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment