Play video

I’m a heavy terminal user, so much so these days that I almost always prefer the terminal over the GUI finder for navigating folder structures. On a day-to-day basis, most of my code mangement is done within the terminal - with the exception being my IDE which I still prefer to be Sublime. Clearly there is a gap needing to be bridged here and thankfully there is an easy, albeit, little known solution to this problem.

The Sublime CLI

Sublime Text actually ships with a command line tool (CLI) right out of the box. This means, it’s only a matter of sym-linking that executable to one of the directories specified by the $PATH environment variable so that it can be accessed universally within the terminal.

Assuming that you’re on OSX, and installed Sublime to your Applications folder, you can run the below command to symlink it into your ~/bin folder. By linking the executable to a folder in your $PATH like this, you’ll be able to execute the command from anywhere within the terminal, not just the folder in which the command resides.

  ln -s "/Applications/Sublime" ~/bin/subl

Note: If the above command doesn’t work for you, check out the video above. I go into more detail about locating the subl executable and figuring out where the symlink destination folder should be.

That’s it! You can now launch Sublime from within the terminal. Below are a few basic usage examples:

  # Launch Sublime

  # Launch Sublime with the current directory targeted
  subl . 

  # Launch Sublime to edit a specific file
  subl my_file.txt

Going further

The Sublime Text online docs has a great page on the OSX CLI, and goes into depth on the various other options available.