Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening sublime text from windows git bash

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 find in the internet.

like image 389
Pranay Aryal Avatar asked Aug 29 '15 04:08

Pranay Aryal


People also ask

How do I open sublime from terminal in Windows?

Type 'Terminus' and select it. Wait for it to Complete installation and Restart sublime text. And save it. Note: The above code is for Linux users for Windows users you have to enter “cmd.exe” in place of “bash”, also here we kept the shortcut key as “alt+1” you can use your own key.

How do I run Sublime Text on Windows?

Step 1: Open the downloaded .exe file from the downloads folder and begin with the installation process. Step 3: If you want Sublime Text 3 to appear in your right-click menu, then mark the checkbox and click on the Next button. Step 4: Press the install button. Step 5: Finish with the installation process.


2 Answers

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 status gl ##for git log, etc 

I hope this will help someone.

like image 96
Pranay Aryal Avatar answered Sep 21 '22 10:09

Pranay Aryal


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"' 
like image 24
tehDeveloper Avatar answered Sep 22 '22 10:09

tehDeveloper