Open Sublime Text 3 from Terminal in macOS Mojave Linux

1- Mac OS:

Step 1:

First of all, test this command:

open /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

If that worked, you’re good to go step 2:

Step 2:

Then run this command:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Step 3:

Checking in terminal by

subl .orsublime ~/Desktop

It will open the current directory or Desktop in Sublime Text! That’s it.

Explanation:

Sublime Text 3 ships with a CLI called subl which is located at (/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl).
We want to create a symlink (symbolic link — or shortcut) of this “subl CLI utility” in the directory /usr/local/bin which is by default in the load path on OS X, and this work allows us to run the subl utility from our Terminal.

If you check your own $PATH by running:

echo $PATH

You will see something like what mine returns:

As you can see the /usr/local/bin path is included by default on OS X.

If you want to name the symlink sublime instead of subl you can do this:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

You should never have to type the full word anyway. Typing sub + Tab should auto-complete the full name of the symlink.

For having super and sub tabs refer to the Tip 2 at the end of this article.

2- Linux:

Before any thing, be sure that there is not already a symlink in /usr/bin/since in current versions of ST3 there is no need to any settings.

Just do this in terminal

subl .

But if it does not work, you just need to make a symlink by the following commands.

Depending on what you prefer you should choose one of these:

sudo ln -s /opt/sublime_text/sublime_text /usr/bin/sublime

or

sudo ln -s /opt/sublime_text/sublime_text /usr/bin/subl

Then go to a folder and do:

subl .
or
sublime .

Posting about Python and Laravel

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Normal oxygen levels are anything above 90%, and I have seen patients come with levels as low as…

Generating Swift Types with Sourcery

EVENT|BitCherry Christmas Giveaway Event

Fast And Easy Prisma Service Deployment With Prisma Cloud And Heroku

Cloud Deployment Models : Technically understand how

Why I completely switched to VS Code

Automation Using Python — AWS CLI, Docker, Linux Basics, Hadoop, Partitions…

CSS Grids Templates : Making Life Easier

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Panjeh

Panjeh

Posting about Python and Laravel

More from Medium

Screen Recording with Internal Audio in macOS

How-To: Open Terminal Tabs & Execute Commands via your CLI

Stop Starting your Commands with Dollar Signs

OverTheWire:~$ Bandit Level 6 → 7