Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chan-dev/61fc8b7769c57b9bd85f6e25428cdada to your computer and use it in GitHub Desktop.
Save chan-dev/61fc8b7769c57b9bd85f6e25428cdada to your computer and use it in GitHub Desktop.
Sublime Text 3 - Open in Command Line (Windows)
You can open sublime text from command line with subl.exe and subl. The second one has a problem. If sublime text is not open already,
when you open sublime text with subl, the command prompt will wait until sublime text is closed. So, you cannot do anything else in
terminal, unless you open another terminal. This is useful in some cases. But sometimes its a pain.
Method 1: Open with subl.exe
1. Go to Control Panel > Advanced System Settings -> Advanced -> Environment Variables
2. Create a new system variable called SUBLIME that will point to the folder of your Sublime installation.
Variable Name: SUBLIME
Variable Value: C:\Program Files\Sublime Text 3
3. Edit User variables Path
At the end of the existing text in the Variable value, add a semicolon and %SUBLIME%
4. If terminal is open, restart it and execute subl.exe
5. It will open sublime text
Note 1:
1. Executing subl.exe will open sublime text
2. Executing subl.exe . will open the current directoy with sublime text
3. Executing subl.exe filename will open the file with filename with sublime text
Note 2:
You will notice that the command prompt will not wait for sublime text to close
Method 2: Open with subl (in Git bash)
1. Go to home directory using cd ~
2. Create a .bash_profile using touch .bash_profile
3. Insert the following text in .bash_profile and save:
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
4. Create a .bashrc using touch .bashrc
5. Insert the following text in .bashrc and save:
alias subl="C:/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"
6. Restart git bash and close sublime text if it is open
7. Execute subl
8. It will open sublime text
Note 1:
1. Executing subl will open sublime text
2. Executing subl . will open the current directoy with sublime text
3. Executing subl filename will open the file with filename with sublime text
Note 2:
If the sublime text is not open before you execute the above commands, You will notice that the command prompt will wait
for sublime text to close.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment