Open folder in Git Bash with Sublime Text 2 on Windows - sublimetext2

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

Related

Sublime 3 HTML Build Linux

I'm trying to do a custom build for Sublime 3 so that it opens chromium and the .html document that I'm working on. I'm able to launch Chromium with this:
"shell_cmd": "/usr/bin/chromium-browser"
How do I also open the file I'm working on?
You should use the $file build system variable to refer to the full path of the current file:
"shell_cmd": "/usr/bin/chromium-browser $file"
On linux:
{
"cmd": ["google-chrome", "$file"]
}
Save your file as ViewInChrome.sublime-build (path is selected as ~/.config/sublime-text-3/Packages/User by default, if not select this path)

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

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
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.

Sublime Text Build in an external window

Is there a way to create a build command in Sublime Text that opens a new external window (terminal/cmd.exe)? Everything I try gets captured to the built-in output window.
I tried:
{
"cmd": ["ruby", "$file"],
"target": "cmd.exe",
"file_regex": "rb$",
"selector": "source.rb"
}
But nothing happened
The following works for Windows (I've tested it on XP and 7):
{
"cmd": ["start", "cmd", "/k", "c:/ruby193/ruby.exe", "$file"],
"selector": "source.ruby",
"shell": true,
"working_dir": "$file_dir"
}
Save it as Packages/User/Ruby_cmd.sublime-build (you may need to alter the path to the Ruby executable depending on your system), select Tools -> Build System -> Ruby_cmd, and build with CtrlB.
start does what it says it does, start a new process independent of Sublime Text. cmd is cmd.exe, the Windows command-line interpreter. The /k flag keeps the window open (at a new command prompt) after your program has run, allowing you to examine its output, look at tracebacks, run additional commands, etc.
May be you will find this solution helpful:
https://github.com/rctay/sublime-text-2-buildview
(transfers build output in the separate sublime tab, you can then do with it whatever you want)

Building Gnuplot from Sublime2 OSX

I am struggling to execute gnuplot scripts from Sublime2.
Gnuplot is installed and I can execute it from Terminal (OSX).
My build configuration in Sublime 2 looks like this:
{
"cmd": ["gnuplot"]
}
when Building it get the following result:
[Errno 2] No such file or directory
[cmd: [u'gnuplot']]
[dir: /Users/macuser/Documents/Gnuplot]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
How to I set up the build instructions in sublime so the script will be send to gnuplot with the current path as a working directory?
Thanks
I'm using Sublime Text 3 on OS X 10.9, and I solve the problem with the following procedure:
Open terminal and navigate to the Installed Packages on Sublime Text:
$ cd ~/Library/Application Support/Sublime Text 3/Installed Packages
Copy the file Gnuplot.sublime-package and paste in Desktop.
$ cp Gnuplot.sublime-package ~/Desktop
Rename the file to Gnuplot.zip and extract the content to a folder, ex. Gnuplot.
$ cd ~/Desktop
$ mv Gnuplot.sublime-package Gnuplot.zip
$ unzip Gnuplot.zip -d Gnuplot
Navigate to the folder, Gnuplot, open the file gnuplot.sublime-build with any text editor, like vim or, even, sublime text. Don't close the terminal window.
$ subl gnuplot.sublime-build
Onterminal type:
$ which gnuplot
Copy the path and with the file gnuplot.sublime-build opened previously in step 4, append the following line path like this:
{
"cmd": ["gnuplot", "$file"],
"path": "$PATH:/usr/texbin:/usr/local/bin:/opt/local/bin:",
"working_dir": "${project_path:${folder}}",
"selector": "source.gnuplot"
}
Save the file, and open terminal again. Type the following commands:
$ cd ~/Desktop/Gnuplot/
$ zip Gnuplot.sublime-package *
$ mv Gnuplot.sublime-package ~/Library/Application Support/Sublime Text 3/Installed Packages\
Restart sublime text 3, and it will work fine. Sorry with my bad english. LOL
In your case, a minimum build system should look something like this:
{
"cmd": ["/full/path/to/gnuplot"],
"working_dir": "${project_path:${folder}}"
}
You can also set "working_dir" to any specific directory. Check this page out for further info on constructing a build file:
Build system reference