Sublime Text 2 Command to open User Packages - sublimetext2

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

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.

Related

at top of python program, a command "import csv" "is not accessed" where to find it

import csv
fails, alert "csv.py" is not accessed
yes, there is no file of that name in my current working directory.
Where can I locate a copy of csv.py to use in my current project.
import urllib.request, urllib.error, urllib.parse #this command works
import obo #this command works because I have obo.py in my directory
import csv # csv is underlines with white dots, csv is not accessed
where do I seek csv.ph?
running windows Visual Studio version 1.73.1
Newbie error. The warning from Visual Studio only meant that I imported a module but didn't use it in the program.

Converting python script to exe. Failed to execute script

I have made a game using pygame and now want to convert the script to an exe file. However, when doing this and starting the exe file I get an error saying "Failed to execute script (main.py)". I have tried everything from youtube videos to reading similar questions on Stack Overflow. But nothing works, I get the same error every time. How can I solve this?
Does it have to do something with my imports?
The import that I use in my script:
pygame
random
winsound
mixer (from pygame)
Avoid all of these problems and use PyInstaller (link to related question):
Download this library with pip by typing in the Command Prompt:
py -m pip install pyinstaller
Then, type cd [path to the file].
Finally, type py -m PyInstaller --onefile [script name].py.
PyInstaller will turn your code into one .exe file, in the folder dist, analyzing the modules you need.
After the installation, you can then delete all the other files, like the folder build for example.
If you need other attached files, like images, put them in the folder where the .exe file has been created.
Anyways, if you type exit() anywhere in your code, PyInstaller will raise an error. Simply import sys and type sys.exit() instead.

Ternjs package is making Sublime Text2 to hang in OS X

I have to explicitly delete this TernJS package for SublimeText to work normally
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
The issue was I couldn't use the "Package Control" to disable this package from within Sublime Text2. When I tried to it just hangs every after restarts. I previously deleted TernJs folder (step 2) and started the application without any issues. But whenever I opened Package Control the application will stop responding because it restores the deleted package. So I had to manually remove it from config as well.
Quit application first
I edited the "Package\ Control.sublime-settings" manually and removed TernJS.
$cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
$sudo vi Package\ Control.sublime-settings
Remove TernJs from the JSON settings {
"installed_packages":
[
.....
"TernJs",
....
]
}
Deleted TernJs Package
$cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
$rm -R TernJs
Opened Sublime Text2 without any issues

package development without restarting

I develop Sublime 3 packages like this:
import sublime, sublime_plugin
class RelativeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello World")
I need to reload sublime after every editing in it to see result of changing in work.
How to get working changes in plugin without exiting the sublime and reopening it?
I believe that it is possible, because for example sublime get changes on the fly without reloading when you edit key mappings.
Update1 :
When I press save after changing file, I got message in console:
Writing file /Users/maks/Library/Application Support/Sublime Text 3/Packages/relative/relative.py with encoding UTF-8 (atomic)
reloading plugin relative.relative
Update2 :
I am using symlinks to store Packages and Installed Packages in Dropbox folder.
Update3:
My os is OS X version 10.8.5
Dont know why, but after removing symlinks to Dropbox of Packages folder, it started to work as expected: after saving got message in console:
reloading plugin relative.relative
And can see new behaviour without reopen sublime3.

Open folder in Git Bash with Sublime Text 2 on Windows

I'm looking for a solution to be able to right-click on any folder in the side bar, of Sublime Text 2 on Windows, and select "Open with Git Bash" so that Git Bash opens with that folder, ready for my git commands.
I've tried the Open With functionality with the Side Bar Enhancements plugin, but no luck.
Oh, and I've tried the "Git" plugin for ST2. It's not what I need.
This worked for me on Windows 7
Create the following files under Packages/User
git_bash.py
import sublime
import sublime_plugin
class GitBashCommand(sublime_plugin.WindowCommand):
def run(self, **args):
dir = args["dirs"][0]
self.window.run_command("exec", {"cmd": ["start", "sh", "--login", "-i"], "shell": True, "working_dir": dir})
self.window.run_command("hide_panel", {"panel": "output.exec"})
def is_visible(self, **args):
return len(args["dirs"]) > 0
Side Bar.sublime-menu
[
{ "caption": "Git bash...", "command": "git_bash", "args": { "dirs": []} }
]
Make sure to add you Git Bash bin folder avaiable in the Windows PATH, on windows 8 its per default ;C:\Program Files (x86)\Git\bin\
http://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
Create a file with no extension name and put this:
#!/bin/sh
"C:\Program Files\Sublime Text 2\sublime_text.exe" $1 &
Then, open your Git folder > bin, paste it there.
Now, you can do
subl sample_directory