Sublime Forum

Possible to launch git-bash from current repository?

#1

Hello,

Is is possible to launch git-bash from the directory that contains the current repository in Sublime Merge?

I find that I occasionally want to do tasks that Sublime Merge does not support (though I use it heavily for those that it does), or want to manipulate the git logs with command line tools. I find it minorly annoying to have to re-navigate the file tree in my shell when I already have the repo open in a program. Is it possible to launch a shell in the current repo from Sublime Merge? Specifically git-bash on Windows 10?

If not, does Sublime Merge have the same sort of scripting capabilities as ST3? Could anyone point me towards how I might achieve this?

Thanks

0 Likes

#2

I don’t think there’s any direct single-step way to do something like this without having to fiddle things around a little bit or take a couple of extra steps. Merge doesn’t support plugins at the moment so it doesn’t have the ability to execute arbitrary external programs in the same manner that Text does (but see below).

One way to go about something like this would be to choose Repository > Open Containing Folder... from the main menu to open a file explorer in the git repository.

  • If you selected the appropriate options when you installed Git Bash you can right click and choose Git Bash Here to open a git bash window in that folder directly.

  • If you click in the “address bar” portion of a native file explorer, it will show you the complete path to the folder being displayed and select it. While it’s selected you can enter cmd or git-bash (assuming it’s in your PATH) and press enter to have Windows open a command prompt or git-bash directly inside that folder.

Either of those options requires you to also open an explorer window though. You could bind that menu command to a key binding to make the operation a bit smoother, perhaps.

Aside of that, Merge can execute arbitrary git commands, so another way to go would be to do something as outlined in the below forum post. The general idea is that you set up a git alias in your global git configuration that executes some external program (in your case a git bash window that opens in a particular folder) and then create a key binding or menu entry that executes that alias.

0 Likes

#3

Wow, thanks for all of that!

Your first solution is probably efficient enough for me. The other ones are really neat though, thanks for sharing!

0 Likes