Created
January 22, 2014 08:26
-
-
Save DisposaBoy/8555297 to your computer and use it in GitHub Desktop.
a sublime text plugin example to open the file path that's in the clipboard
This file contains hidden or 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
# this plugin creates a command `open_from_clipboard` that opens the path that's currently in the clipboard | |
# save this file at Packages/User/openclipboard.py | |
# then add the follow key binding if you like via the menu Preferences > Key Bindings - User | |
# { "keys": ["ctrl+shift+o"], "command": "open_from_clipboard" } | |
import sublime | |
import sublime_plugin | |
class OpenFromClipboardCommand(sublime_plugin.WindowCommand): | |
def run(self): | |
fn = sublime.get_clipboard() | |
if fn: | |
sublime.active_window().open_file(fn) | |
else: | |
sublime.status_message("Nothing to open. The clipboard is empty.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not good at Python and Sublime API, so this is probably far from idiomatic, but it works: