Sublime Text from Command Line

mehulkar picture mehulkar · Feb 25, 2012 · Viewed 201.7k times · Source

I installed Sublime Text and wanted to know how to open rb files in it from the terminal. I saw What is the command to make Sublime Text my core editor? and I see that I can make Sublime my core editor, but I want to be able to type

sublime file.rb

How do I do this in Windows?

Answer

pjumble picture pjumble · Feb 25, 2012

Windows Command Prompt

For Windows cmd.exe you could just add the sublime text installation directory to your PATH environment variable, this would allow you to type:

sublime_text file.rb

Personally, I add a doskey (in a .bat file set to autorun with cmd) so I can type subl file.rb:

> doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*

Cygwin

For the default bash shell add an alias to your ~/.bashrc file, e.g:

$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc