简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM