How do I open Sublime text from Git Bash in Windows? I tried adding the alias at the ~/.bashrc file but nothing worked. I was looking for something very easy but I could not fin
I was having some difficulty getting this to work for me as well despite all the answers listed here. I found that modifying my .bashrc file through VIM as suggested here fixed the problem for me. I'm using Git bash on windows 10.
First I opened bash to my home directory, you can use cd~ to make sure you're in the right place.
Then, I created my .bashrc file using:
touch .bashrc
Then I went to edit that file using:
vim .bashrc
press the i
key to enter insert mode
enter:
alias subl='C:/Program\ Files/Sublime\ Text\ 3/sublime_text.exe'
As noted by pretty much everyone else this will have to be the correct path to your sublime_text.exe location. A quick search of your C:\ drive for sublime_text.exe should yield this location.
now hit esc
to exit input mode
Enter :
w
q
enter
to save and exit vim
exit bash and reopen to apply the new settings
Entering subl
should open sublime text editor now.
I had tried editing my .bashrc file with wordpad and sublime text itself, but for some reason editing in vim and making sure all the forward slashes and backslashes were correct as noted above worked for me.
I had found a rogue ^M character after my file path using some of the other methods which I think might have been complicating things as well. deleting this character in vim also fixed the problem after using SawyerDoesStuff's solution.
Thanks for letting me revive an older post and I hope this helps.
I followed what Cristiano Ferro did, and if you would like to commit a message with Sublime Text 3, paste this in your git.
Assuming the program is installed in Program Files
:
export GIT_EDITOR='C:\\Program\ Files\\Sublime\ Text\ 3\\sublime_text.exe'
After this, you can run git commit
, and it will open Sublime Text 3.
Create a text file called subl (with no extension) with the following content:
#!/bin/sh
"C:\Program Files\Sublime Text 2\sublime_text.exe" $1 &
Copy it into the C:\Program Files (x86)\Git\bin folder. 32bit Copy it into the C:\Program Files\Git\usr\bin folder. 64bit
Now to open the file enter the following command on Windows Git Bash
subl text.txt
or
subl .
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"'
Locate the folder where Sublime Text is installed. Here I'am taking an example of Sublime Text 3 which is installed in C:/Program Files. For many users it is present in C:/Program Files (x86).
Run the following command (based upon your requirement):
echo 'alias subl="/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"'>> ~/.bashrc
Or
echo 'alias subl="/c/Program\ Files\ \(x86\)/Sublime\ Text\ 3/sublime_text.exe"'>> ~/.bashrc
Try Closing and Re-Opening Git-Bash. If it works, then you're done.
Otherwise, read this documentation from Udacity.