Sublime Forum

Start sublime from git command line on windows?

#1

Hey All,

I’m trying to convert from the e text editor & am right away missing the ability to open (or create a new) file from the git command line on windows Using the .bat file given in this forum post I can do so from a regular windows command prompt, but that doesn’t work from a msysgit command line. Is there an analogous shell script maybe that I could use from there?

Many thanks in advance!

-Roy

0 Likes

#2

Open global config file:

git config --global -e

and add:

[core] editor = \"C:/sublime/sublime_text.exe\" --multiinstance

Adjust path as needed.
This will open new sublime instance when git wants to trigger editor. You will have to close that instance for git to return control to the terminal.

0 Likes

#3

That is awesome cool–thanks for that!

But what I’m really after at the moment though is the ability to say:

  roy@zoidberg $ subl my_file.txt

at my git command line and have sublime open up my_file.txt so I can work on it.

I’ve got a subl.bat file on my PATH that lets me do so from a cmd window, but git’s bash doesn’t consider that a viable command I guess (even if I chmod +x it). So given that sublime doesn’t currently come w/a little .exe shim program to handle this functionality (hint, hint :wink:) I think I need an analagous subl.sh that bash will execute for me. Alas, I do not speak shell script at present–thus my request.

Thanks again for the response–I will definitely be making sublime my preferred editor for git.

0 Likes

#4

Maybe a .cmd file will work (just guessing). Worth a shot I guess.

Edit: Oops missed the part where you said git’s bash.

0 Likes

#5

You can alias subl to point to the sublime executable. You would need to add the following to your .bash_profile which is normally in your home folder (if it doesn’t exist you can create it).

alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"

You can find your home folder in msysgit by typing

echo $HOME 
0 Likes

#6

[quote=“ebruning”]You can alias subl to point to the sublime executable. You would need to add the following to your .bash_profile which is normally in your home folder (if it doesn’t exist you can create it).

alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"

[/quote]

Outstanding–many thanks! That works really well.

0 Likes

#7

[quote=“ebruning”]You can alias subl to point to the sublime executable. You would need to add the following to your .bash_profile which is normally in your home folder (if it doesn’t exist you can create it).

alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"

You can find your home folder in msysgit by typing

echo $HOME 

Thanks…I spent days looking for this Git Bash solution for using Sublime Text 2 as core editor in Win7; all others have failed.
I modified for your solution for Win7 to:
Using Sublime, I created .bash_profile in $HOME folder and added the following:
alias subl="/c/Program\ Files\ (x86)/Sublime\ Text\ 2/sublime_text.exe"

I tried a variant of this, met with failure. in the above I escaped everything, i.e., parentheses and spaces…

0 Likes