Skip to content

Instantly share code, notes, and snippets.

@ptim
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptim/9505770 to your computer and use it in GitHub Desktop.
Save ptim/9505770 to your computer and use it in GitHub Desktop.
ST3: Paste the current file's Relative Path From Project (Encoded). Requires https://github.com/titoBouzout/SideBarEnhancements be installed
import sublime, sublime_plugin
'''
Paste the current file's Relative Path From Project (Encoded).
Requires https://github.com/titoBouzout/SideBarEnhancements to be installed
First save this file as:
~/Library/Application Support/Sublime Text 3/Packages/User/paste-path.py
More details about writing plugins: http://docs.sublimetext.info/en/latest/reference/plugins.html
To trigger the command with 'Command Option Shift p',
add the following to your Sublime Text > Preferences > Keybindings - User
[
{ "keys": ["super+option+shift+p"], "command": "paste_path"}
]
'''
class PastePathCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("side_bar_copy_path_relative_from_project_encoded", {"paths": []})
self.window.run_command("paste")
@alex-cory
Copy link

I really want this but when I copy the command you provided into my Keybindings - User file, it doesn't work. What is up with the code import sublime, sublime plugin before and the class getting called at the end?

@alex-cory
Copy link

And I do have SidebarEnhancements intalled. (just to clarify)

@ptim
Copy link
Author

ptim commented May 1, 2014

Sorry, I left out some salient details!

You need to save this file as something like:

~/Library/Application Support/Sublime Text 3/Packages/User/paste-path.py

More information: http://docs.sublimetext.info/en/latest/reference/plugins.html

I've update the answer at http://stackoverflow.com/questions/22349600/st3-how-to-use-a-plugins-commands-in-a-macro/22351353#22351353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment