Is it possible to add a folder to the sidebar from a plugin? If I pass a folder to the open_file command, will it open in the sidebar?
Thanks.
Is it possible to add a folder to the sidebar from a plugin? If I pass a folder to the open_file command, will it open in the sidebar?
Thanks.
I just spent a few minutes digging through the Default package looking for a solution to this. I would also approve of such a feature!
Alternatively a way to open a folder without a prompt, or opening a project without a prompt would work also.
You can kind of cheat by running this system command. This is how I always do it, i just keep a terminal open and add stuff through that.
/path/to/sublime_text.exe -a /path/to/file_or_folder
[quote=“impeached”]You can kind of cheat by running this system command. This is how I always do it, i just keep a terminal open and add stuff through that.
/path/to/sublime_text.exe -a /path/to/file_or_folder
I was going to attempt this, however with the limited amount of time I spent on it, I could not think of a good way to programatically determine the path to the command line program. Perhaps I am overlooking a simple solution?
[pre=#0C1021]>>> import sys
sys.executable
‘C:\Program Files\Sublime Text 2\sublime_text.exe’[/pre]
Though, now I think about it, iirc that won’t work on OSX as you’ll get the system python executable.
[pre=#0C1021]>>> open(’/proc/self/cmdline’).read().split(chr(0))0]
‘/usr/lib/sublime-text-2/sublime_text’[/pre]
For *nix ( not osx it seems)
I think sys.executable may be good enough since OS X users are unlikely to install Sublime in a non-standard location, whereas Linux users have no standard and Windows users could be using the portable installation.
So, I think the best solution (until we get an API method) is:
import sublime
import sys
import subprocess
def get_sublime_path():
if sublime.platform() == 'osx':
return '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'
if sublime.platform() == 'linux':
return open('/proc/self/cmdline').read().split(chr(0))[0]
return sys.executable
def sublime_command_line(args):
args.insert(0, get_sublime_path())
return subprocess.Popen(args)
Usage for adding a folder to the sidebar would be:
sublime_command_line('-a', '/path/to/folder'])
sys.executable didn’t work on linux on my ubuntu 10.04 vm at least
it just returned an empty string
[quote=“castles_made_of_sand”]sys.executable didn’t work on linux on my ubuntu 10.04 vm at least
it just returned an empty string[/quote]
I was wondering why you had talked about reading /proc for Linux. It worked for me, but clearly it is not consistent across different distros.
Odd eh? Apparently /proc is only on linux. There’s no real equivalent on OSX. Not even a generic *nix thing. I’m a windows loser. Don’t really know shit about osx and only a little of linux.
Might be some ctypes hack for OSX? Jon would know. For that 1 guy who walked under a ladder taking his black cat to the vet after installing to a non default location. Actually, fuck that guy, he brought it on himself!