Skip to content

Instantly share code, notes, and snippets.

@imme5150
Forked from 1o1brian/gist:2919347
Last active December 20, 2015 06:09
Show Gist options
  • Save imme5150/6083600 to your computer and use it in GitHub Desktop.
Save imme5150/6083600 to your computer and use it in GitHub Desktop.
# thanks to railscasts:
# http://railscasts.com/episodes/48-console-tricks-revised?view=comments
# add this to your ~/.irbrc file
class Object
# look up source location of a method
def sl(method_name)
self.method(method_name).source_location
end
# macvim
def mvim(method_name)
file, line = sl(method_name)
`mvim #{file} +#{line}`
end
# sublime text
def subl(method_name)
file, line = sl(method_name)
`subl #{file}:#{line}`
end
# textmate
def mate(method_name)
file, line = sl(method_name)
`mate '#{file}' -l #{line}`
end
end
# examples:
# helper.sl(:link_to) # show file name and line number of the source code for the link_to helper method
# helper.mate(:link_to) # opens the link_to helper definition in textmate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment