Skip to content

Instantly share code, notes, and snippets.

@kattrali
Created July 20, 2012 03:04
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 kattrali/3148411 to your computer and use it in GitHub Desktop.
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
#!/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