Created
July 20, 2012 03:04
-
-
Save kattrali/3148411 to your computer and use it in GitHub Desktop.
How to enable bash completion for Cocoa classes, methods, and property names for use with the `cocoadex` gem
This file contains hidden or 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 sh | |
# | |
# cocoadex_completion.sh | |
# | |
# Bash completion for Cocoa classes | |
# Install by saving this file and adding the following to your .bash_profile: | |
# | |
# complete -C /path/to/cocoadex_completion.sh -o default cocoadex | |
/usr/bin/env ruby <<-EORUBY | |
require 'cocoadex' | |
class TagCompletion | |
def initialize(command) | |
@command = command | |
end | |
def matches | |
tags.select do |tag| | |
tag[0, typed.length] == typed | |
end | |
end | |
def typed | |
@command[/\s(.+?)$/, 1] || '' | |
end | |
def tags | |
@tags ||= Cocoadex::Keyword.tags | |
end | |
end | |
puts TagCompletion.new(ENV["COMP_LINE"]).matches | |
EORUBY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment