opening sublime text from windows git bash opening sublime text from windows git bash git git

opening sublime text from windows git bash


I am going to answer my own question. First, I created a .bash_profile file under /Users/username directory. I have copied all my git aliases here. To access sublime text I added this alias:

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

I think the spaces after the backward slashes are important for formatting. If this doesn't work you will have to look where your sublime_text.exe file situated at and put the path after formatting as above. Now in the git bash command line just type

subl . 

to open the current directory in Sublime Text or the name of the file as

subl readme.md

to open it in Sublime Text. I also added other useful aliases in the .bash_profile file like:

alias gc="git commit -m"alias ga="git add ."alias gl="git log"alias gs="git status"

So in your git bash command prompt you can simply type

gs ##for git statusgl ##for git log, etc

I hope this will help someone.


Create .bash_profile file under C:\Users\YourUserName\ and add the following line in the file:

alias 'subl="/c/Program Files/Sublime Text 3/subl.exe"'


A Better Solution:

The updated version of sublime text 3(Build 3065) brings this feature as "subl.exe" which was "subl" in mac os.

How to use:

step 1: Update sublime text (in sublimetext --> Help -> Check for Updates)
step 2: Just navigate to your project folder through bash and type subl.exe which should open the folder in sublime text. (if you encounter "subl.exe" command not found, just add sublime's path eg: "C:\Program Files\Sublime Text 3" to your system path - Here's how to add path to environment variables)