Skip to content

Instantly share code, notes, and snippets.

@evansolomon
Created July 13, 2012 23:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save evansolomon/3108240 to your computer and use it in GitHub Desktop.
Save evansolomon/3108240 to your computer and use it in GitHub Desktop.
Command line one liner to find and open function definitions in Sublime Text 2
# Alias ST2's command line tool for a shorter (easier-to-remember) name
alias st="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
# Search for an open Sublime Text to a function definition
function fx() {
ack "function &?$1\(" | awk {'print $1'} | sed 's/:$//g' | xargs st
}
# Example usage from the root of a WordPress repository
# fx wp_remote_get
# Automatically opens wp-includes/http.php to line 74 in Sublime Text 2
# If the function is defined multiple times (e.g. methods of classes) it will open all of the files
# ...but only the last one will be on the correct line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment