Mac os sublime from terminal

Open Sublime Text 3 from Terminal in macOS Mojave Linux

Start or Launch Sublime Text 3 from terminal by subl or sublime in Linux command line

Jul 7, 2019 · 2 min read

1- Mac OS:

First of all, test this command:

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

Then run this command:

Checking in terminal by

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

Sublime Text 3 ships with a CLI called subl which is loca t ed 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:

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:

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

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:

Источник

Launch Sublime Text 2 or 3 from the Mac OSX Terminal

As I’m working in the OSX Terminal more and more these days, I’m always on the lookout for time saving shortcuts.

A really useful tip that I picked up recently from Zander Martineau is how to open up Sublime Text straight from the Terminal. This is done by hooking into a CLI utility that Sublime provides called subl.

The following instructions are based largely on the original gist on Github by Artero, so credit for this solution should be directed to them and not myself.

Читайте также:  Htc windows phone все смартфоны

It’s a slightly different installation depending on whether you’re using Sublime Text 2 or 3, so I’ll split the two out below in the installaton; simply refer to the instructions that are relevant to you.

Installation

Assuming you installed Sublime in the Applications folder, the following command should open up the editor when you type it into the Terminal:

For Sublime Text 2:

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

For Sublime Text 3:

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

If that worked, you’re good to go.

You now need to create a symlink called sublime which links the subl CLI to a folder where your system usually looks to execute these binaries. To do this, type in:

For Sublime Text 2:

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

For Sublime Text 3:

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

Check your profile

The final thing you need to do, is to check that your system profile is looking in the right place to see the symlink you have just created.

Enter the following command into your Terminal:

Note that in some cases the profile may be called

This should open up your profile in a text editor. What you’re looking for is a line towards the top of the file that starts with export PATH= . Your PATH contains all the directories that will be checked for executable binaries when you type a command into your Terminal. Since we created a symlink in the /usr/local/bin folder, we want to make sure that that folder is being checked too.

Hopefully, you’ll be able to see something similar to this:

If not, simply add this folder to your PATH and save the file.

Note: The (. ) in this example represents other folders that would be listed on the same line and separated by a colon.

If you don’t already have a PATH set in your bash_profile you can type the following on a new line:

Finally, if you did have to add /usr/local/bin to your PATH , run the following command before continuing:

This will reload your .bash_profile with the newly added directory in your PATH .

Test it works!

In your Terminal, the following commands should now work:

  • sublime . – opens the current directory in Sublime
  • sublime filename – opens a file where filename is the file to be opened
  • sublime foldername – opens a folder where foldername is the folder to be opened

And there you have it – you can now open any file or folder in Sublime straight from the Terminal.

Thanks and credit for this great solution again goes to Artero. If you have any problems getting it working, let me know and I’ll do my best to help you out.

Article posted on the 17th February 2014

I’m Ashley Watson-Nolan, a Principal UI Engineer at Just Eat. Do take a look around, or contact me in any of the usual ways – it’d be great to hear from you.

Читайте также:  Kali linux iso rus

Источник

jasperf / launch_sublime_from_terminal.markdown

Launch Sublime Text 3 from the Mac OS X Terminal

Sublime Text 3 ships with a CLI called subl (why not «sublime», go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you’re ready.

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

The official documentation I linked to above recommends creating a

/bin folder (in your home directory). That’s weird, I don’t recall ever being asked to do that on OS X since most people install binaries within /usr/local/bin which – if you’re a developer – is likely to already have tons of other binaries.

So contrary to the Sublime team recommendation, we’re not going to create a bin folder in your home directory:

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

This will simply create a symlink called sublime (remember, we like names that don’t suck to type 500 times a day) between the subl binary stashed in the Sublime application package, and a folder where your system usually looks for binaries to execute (launch). Think of it as a wormhole of awesome.

Now let’s do a check to see if everything will run smoothly. Enter this:

(In some cases the profile file is named

You should see at the top of the file a line that starts with: export PATH=

This contains all the directories that will be looked into for executable binaries when you type a command in Terminal. Since we create a symlink to subl called sublime in the /usr/local/bin directory let’s check if this directory is listed on that same line.

If it is, perfect. Let’s keep going. If not, simply add it like this and save the file:

Note: The ‘(. )’ in this example represents other folders that would be listed on the same line and separated by a colon.

If you don’t already have a PATH set in your bash_profile you can type:

If you had to add /usr/local/bin to your PATH, run the following command before continuing:

This will reload your .bash_profile with the newly added directory.

Open a Terminal window and run:

sublime filename (replace «filename» by an actual file name)

sublime foldername (replace «foldername» by an actual folder name)

sublime . (to open the entire current directory)

Now you don’t need to get out of Terminal to simply open a file or a folder, you didn’t have to add an «alias» or yet another bin directory to your .bash_profile which you would have needed with the official instructions given by the Sublime team.

Have fun, Sublime is a great editor showing a lot of promise.

Источник

Как запускать Sublime Text из терминала на Mac OS

Когда приходится запускать веб сервер или систему сборки проекта из терминала, то хочется сразу иметь возможность запустить оттуда же и редактор. В Интернете хватает инструкций для этого, одна из которых была опубликована Artero в виде gist на Github.

Порядок настройки быстрого запуска будет следующим:

  1. Проверяем полный путь по которому установлен Sublime Text.
  2. Создаем Symlink для запуска программы из usr/bin.
  3. Проверяем, что sublime можно запустить из терминала.
Читайте также:  To repair при установки windows

1. Проверка полного пути

Чтобы убедиться, что путь до Sublime Text правильный, нужно выполнить в терминале следующий код:

Для Sublime Text 2:

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

Для Sublime Text 3:

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

Если выполнив этот код у вас запустился Sublime Text нужной версии — переходим к следующему шагу.

Для Sublime Text 2:

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

Для Sublime Text 3:

ln -s «/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl» /usr/local/bin/subl

Теперь вы можете запустить Sublime Text из терминала с помощью команды subl. Если это не работает, то добавляем директорию в профиль bash на следующем шаге.

3. Проверяем

Возможно у вас еще не была добавлена директория /usr/local/bin для запуска программ оттуда. Добавить этот путь для запуска программ можно следующим образом.

Открываем в терминале файл .bash_profile:

В этом файле добавьте строку:

Чтобы обновить профиль терминала без его закрытия и повторного запуска выполните команду:

Для проверки работы — попробуйте выполнить следующие команды:

sublime . — для открытия редактора с загруженной текущей директорией.

sublime somefile — открывает редактирование somefile.

sublime somefolder — открывает sublime с открытием somefolder.

Для большего ускорения работы и быстрого запуска Sublime Text в текущей директории можно добавить alias в файл .bash_profile:

Источник

jackilyn / launch-sublime-from-terminal.md

Launch Sublime Text from the Mac OS X Terminal

Create a symlink called sublime: ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

Check to see if /usr/local/bin is in your PATH: open

Make sure it says: export PATH=/usr/local/bin:/example/other/dirs/

Back in the terminal enter this to refresh the file: source

Now you can type sublime to open up Sublime Text, sublime . to open the current directory or sublime some-file.txt to open the directory/file in Sublime Text.

Now, to set Sublime Text as the default editor set the EDITOR environment variable: export EDITOR=’sublime’

This comment has been minimized.

Copy link Quote reply

pierrecholhot commented Apr 19, 2013

April 19th, 2013 > Sublime Text 2 version 2.0.1, Build 2217 on OSX 10.8.3

The -w doesn’t seem to be needed anymore; Actually adding it now inverses the way it worked.
Adding it, makes the terminal command exit before editing the file in sublime
Removing it, will properly make the sublime command to not exit until the file is closed.

Can someone confirm this ? Tested on 3 different «new» macs. Default installations.

This comment has been minimized.

Copy link Quote reply

tamzheartbeatz commented Jul 2, 2013

Totally works without -w. Thanks a ton!

This comment has been minimized.

Copy link Quote reply

samdutton commented Jul 29, 2013

Can just use this now (with no Sublime version):

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

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Оцените статью