Sublime Text Command Line Tool in Windows
There’s a command to setup a command line tool for Sublime Text that allows you to open Sublime Text from the command line by calling subl. Such as
subl README.txt #opens README.txt in Sublime Text
subl . #opens the current directory in Sublime Text
You can find the setup instructions of Mac OS X here. However, I could not find the analagous command to set something like that up in Windows.
Sublime Text is one of my favorite text editors. Often, when I’m checking out a new code project, I open it in Sublime Text to get a lay of the land where it has a sidebar to navigate the directory, open multiple tabs, place tabs side by side, and syntax highlighting. It also has a very powerful package manager.
So when I do development on Windows, I miss being able to navigate and quickly open Sublime Text from my console window. But setting up the Sublime Text command line is simple: the original instructions simply made a symlink in a directory that is included in your path.
So let’s first make the symlink for Sublime Text 2. (Note: I have not tried with Sublime Text 3)
cmd /c mklink /H "$env:programw6432\Sublime Text 2\subl.exe" "$env:programw6432\Sublime Text 2\sublime_text.exe"
which outputs
"Hardlink created for C:\Program Files\Sublime Text 2\subl.exe <<===>> C:\Program Files\Sublime Text 2\sublime_text.exe"
then add the Sublime Text program files folder to the PATH environment variable
PS C:\Users\Ethan> [Environment]::SetEnvironmentVariable("Path", "$Env:Path;$env:programw6432\Sublime Text 2\", "User")
If your restart your console session, you should be able to open Sublime Text by just typing four characters into your console: subl
comments powered by Disqus