Wednesday, December 9, 2009

My shortcut to open any gem in TextMate with 1 command

Using the implementation from @peepcode's blog on shell method missing as a base.
I've added another action (code snippet below) to open a gem library in TextMate by typing in the name of the gem followed by ".mate".

when /^[A-Za-z0-9_\-\/]+\.mate$/
  # Open the gem in textmate
  # @example
  #   haml.mate
  gem_to_open = command.first.gsub(/\.mate$/, '')
  run "gem which #{gem_to_open} | tail -1 | xargs dirname | sed -e's/$/\\/../' | xargs mate"