Home Download Buy Blog Forum Support

start sublime from git command line on windows?

start sublime from git command line on windows?

Postby roy on Fri Jan 06, 2012 9:57 pm

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
roy
 
Posts: 4
Joined: Sat Dec 24, 2011 12:40 am

Re: start sublime from git command line on windows?

Postby rchl on Fri Jan 06, 2012 10:10 pm

Open global config file:
Code: Select all
git config --global -e


and add:

Code: Select all
[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.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

Re: start sublime from git command line on windows?

Postby roy on Fri Jan 06, 2012 10:27 pm

That is awesome cool--thanks for that!

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

Code: Select all
  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 ;-)) 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.
roy
 
Posts: 4
Joined: Sat Dec 24, 2011 12:40 am

Re: start sublime from git command line on windows?

Postby atomi on Fri Jan 06, 2012 10:56 pm

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

Edit: Oops missed the part where you said git's bash.
Last edited by atomi on Sat Jan 07, 2012 2:51 am, edited 1 time in total.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: start sublime from git command line on windows?

Postby ebruning on Sat Jan 07, 2012 12:00 am

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

Code: Select all
alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"


You can find your home folder in msysgit by typing

Code: Select all
echo $HOME
ebruning
 
Posts: 1
Joined: Thu Nov 19, 2009 4:32 pm

Re: start sublime from git command line on windows?

Postby roy on Mon Jan 09, 2012 3:30 pm

ebruning wrote: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).

Code: Select all
alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"




Outstanding--many thanks! That works really well.
roy
 
Posts: 4
Joined: Sat Dec 24, 2011 12:40 am

Re: start sublime from git command line on windows?

Postby igmuska on Sun Dec 30, 2012 8:42 pm

ebruning wrote: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).

Code: Select all
alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"


You can find your home folder in msysgit by typing

Code: Select all
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...
igmuska
 
Posts: 1
Joined: Sun Dec 30, 2012 8:13 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests