Created
October 18, 2012 15:11
-
-
Save jturcotte/3912465 to your computer and use it in GitHub Desktop.
Terminator plugin to open paths in Sublime Text
This file contains 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
import re | |
import terminatorlib.plugin as plugin | |
import subprocess | |
# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE' | |
AVAILABLE = ['FileURLHandler'] | |
class FileURLHandler(plugin.URLHandler): | |
capabilities = ['url_handler'] | |
handler_name = 'file_path' | |
# Match any non-space string starting with an alnum or a slash and ending with a line number | |
match = r'[a-zA-Z0-9\/][^ ]+:[[:digit:]]+|[a-zA-Z0-9\/][^ ]+\([[:digit:]]+\)' | |
def callback(self, url): | |
p = subprocess.Popen(["xclip", "-selection", "clipboard"], stdin=subprocess.PIPE) | |
p.communicate(input=url) | |
p.wait() | |
subprocess.call(["subl", "--command", "open_clipboard_path"]) | |
return "some_random_string_just_so_that_opening_the_resulting_url_will_fail" |
The callback can be simplified:
def callback(self, url):
subprocess.call(["subl", url])
return ""
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same for Emacs: https://gist.github.com/nofxx/fa0647722365f5a4b2ad
Thanks @jturcotte