Open sublime text 2 from command line on windows

In Mac, you can open sublime text 2 from terminal, and it’s really handy.

I wanted to replicate the same thing on windows, so wrote a simple script that enables it.
Once you run this script, you can do the following things from command line.

subl // this will open sublime text 2
subl . // open sublime text 2 with folder side bar.

For example, if you do it in c:\dev\trunk, sublime text will open with folder that is based on c:\dev\trunk.

To run the script, copy the below, and in the command prompt (not powershell prompt), right click and paste it. You must have powershell installed if you are not on windows 7 or Vista

 
 
REM Begin Copy
powershell
Set-Content "C:\Program Files\Sublime Text 2\subl.bat" "@echo off"
Add-Content "C:\Program Files\Sublime Text 2\subl.bat" "start sublime_text.exe %1"
if (!($Env:Path.Contains("Sublime"))) {[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Program Files\Sublime Text 2", "Machine")}
exit
REM End Copy

You will have to close the command prompt as the path change would take effect when a new command prompt starts.

Open sublime text 2 from command line on windows

7 thoughts on “Open sublime text 2 from command line on windows

  1. I did this on win7 and powershell and got this error:

    The term ‘REM’ is not recognized as the name of a cmdlet, f
    g of the name, or if a path was included, verify that the p
    At line:1 char:6
    + REM <<<< Begin CopypowershellSet-Content "C:\Program F
    gram Files\Sublime Text 2\subl.bat" "sublime_text.exe %1"if
    etEnvironmentVariable("PATH", $Env:Path + ";C:\Program File
    + CategoryInfo : ObjectNotFound: (REM:String)
    + FullyQualifiedErrorId : CommandNotFoundException

  2. sorry for the error. you have to paste it in “command prompt” window, not powershell. In the script, “powershell” will start powershell session within the command prompt.

  3. The design and engineering process may include blueprints and drawings
    that can be done by you; others will require professional assistance from fire extinguishers a licensed fire sprinkler
    companies or fire protection contractors. Perhaps among fire protection equipment are attempting to address the issue of competency, if
    not put it out completely. Passive Fire Protection for
    structural steel identifies couple of different types of smoke
    and crawling is the best blaze protection device usually use in emergency situations.
    This allows the fire safety engineers in San Francisco, San Jose, Santa Rosa, Oakland, Hayward & Fremont.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s