Does anyone know if anything been added to the API that allows a plugin to grab the current path triggered from a sidebar folder right click context menu entry?
I'd like to be able to right click a folder and "Open Command Window Here" type thing.
import sublime, sublime_plugin
import subprocess
class OpenPromptCommand(sublime_plugin.TextCommand):
def run(self, edit):
dire = os.path.dirname(self.view.file_name())
retcode = subprocess.Popen(["cmd", "/K", "cd", dire])
def is_enabled(self):
return self.view.file_name() and len(self.view.file_name()) > 0[
{ "caption": "-", "id": "file" },
{ "command": "open_prompt", "caption": "Open Command Window Here…" }
]import sublime, sublime_plugin, subprocess, os
atomi wrote:The problem with loading this from the sidebar is that the working directory is set using self.view.file_name().
What I wanted was a way to use the folder I right clicked on as the current working directory for the command prompt.
jbrooksuk wrote:atomi wrote:The problem with loading this from the sidebar is that the working directory is set using self.view.file_name().
What I wanted was a way to use the folder I right clicked on as the current working directory for the command prompt.
I see...
Well the sidebar can pass arguments through I believe, so I'll have a play
{ "caption": "Delete Folder", "command": "delete_folder", "args": {"dirs": []} },
Traceback (most recent call last):
File ".\sublime_plugin.py", line 276, in run_
TypeError: run() got an unexpected keyword argument 'dirs'
Users browsing this forum: No registered users and 5 guests