Chet
Chet

Reputation: 19839

Sublime Text 2 Command to open User Packages

I want to make a simple command that will open all my User packages in sublime. So I created a new plugin and wrote this:

import sublime_plugin, os

class UserPackagesCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        os.system("subl ~/Library/Application Support/Sublime Text 2/Packages/User")

When I open the console and run view.run_command("user_packages") nothing happens. When I open the command pallet, this command doesn't even show up.

Thanks

Upvotes: 0

Views: 69

Answers (1)

Sergey Telshevsky
Sergey Telshevsky

Reputation: 12197

import sublime, sublime_plugin, subprocess

class UserPackagesCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        cmd = []
        cmd.append('subl')
        #cmd.append('-a')
        cmd.append(sublime.installed_packages_path())
        subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=False)

To add folders to current project (append to the sidebar) uncomment the -a argument line.

EDIT: After editing this now works independently for any OS and ST Package directory path if you have subl command available.

Upvotes: 1

Related Questions