Create a gist now

Instantly share code, notes, and snippets.

Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 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\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

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\ 2.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:

open ~/.bash_profile

(In some cases the profile file is named ~/.profile)

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:

export PATH=/usr/local/bin:(...)

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:

export PATH=/usr/local/bin:$PATH

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

source ~/.bash_profile

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

Testing

Open a Terminal window and run:

sublime filename (replace "filename" by an actual file name)

or

sublime foldername (replace "foldername" by an actual folder name)

or even

sublime . (to open the entire current directory)

Conclusion

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.

@mapkon
mapkon commented Jul 6, 2012

Awesome awesome editor - not sure how i have survived without it!

@christonog

Thanks for this, just upgraded to Mountain Lion which must've removed my sublime CLI. I go here every time I need to add sublime to the terminal and open files.

@nicolechung

This worked for me, thanks!

@britishtea

For some reason this gives me an error:

$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
$ subl --help
-bash: /Applications/Sublime: No such file or directory

Tried escaping the spaces in Sublime Text 2 with \'s, wrapping them in quotes, still get this error. Any ideas?

@DerektheDev

Worked perfectly--great!

@krv
krv commented Aug 23, 2012

For those having troubles with Mountain Lion, create a bin directory first in /usr/local.

$ sudo mkdir /usr/local/bin
$ sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
@abachuk
abachuk commented Aug 24, 2012

Works great for me!!! Thanks

@momer
momer commented Aug 28, 2012

Thank you krv

@nelsonenzo

What I really really really like about this gist is you actually explain wtf you are doing it, and why your doing it differently than posted elsewhere ::cough::docs::cough:: Very well done, wish all instructions were this well written / described. Not only did it fix the problem, but also taught me a couple nifty tricks i hadn't thought of. Thank you!!!

@ChrisChiera

I have a new Mac, Mountain Lion and it does not come with a Bash Profile by default. I created a blank one but am confused on what I should add exactly.

Do I add this:

export PATH=/usr/local/bin:(...)

or

export PATH=/usr/local/bin

or

export PATH=/usr/local/bin:sublime

or something else? And do I need anything else in my bash_profile for this to work? Thanks!

@johnnygoodman

Super helpful. Thank you.

@rachelbaker

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

export PATH=/usr/local/bin:$PATH

@edu222
edu222 commented Sep 16, 2012

This instructions were very helpful, I was getting frustrated with the original instructions at http://www.sublimetext.com/docs/2/osx_command_line.html

@sundeepgupta

Thanks, I managed to get this working on my Mac, but when not while using SSH. Its giving me:
-bash: subl: command not found

@aimango
aimango commented Sep 21, 2012

Awesome thanks!

@clickbooq

@sguptaet Make sure your bash export path has the sublime path in it. Mine looks like this:

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"
@robwierzbowski

+1. Thanks.

@DavidVII

SWEEEET!

Thanks!!!

@subfuzion

+1. Thanks!

@MattFielding

Thanks for this, it helps me work around an issue with running a compass build with rvm from within ST2 whatwedo/sublime-text-compass#6

@ButuzGOL
ButuzGOL commented Dec 2, 2012

Thanks!

@nravichandra

U can also add an alias to the bash_profile if u dont dont want to symlink and export path

alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"

and use
example:
subl filename

@LiquidNight

I have it sublime working out of the terminal, but had to use krvs helpful instructions to get it to work

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

My question out of curiosity is that after using these commands in terminal I then tried the series of tests to see if everything worked smoothly

open ~/.bash_profile .

This command does not work and terminal says that the file does not exist. I would just like to know why this is not working. I am assuming it is somehow related to the Mountain Lion configuration I set it up with?

Thanks

@cisliu
cisliu commented Dec 29, 2012

Awesome! I constantly got "No such file or directory" error when following the default method suggested by Sublime team and couldn't solve it in the past 20 mins. Found this, followed this, boom, everything worked like a charm! Thank you so much!

@klipnov
klipnov commented Jan 8, 2013

It works...Good tutorial

@hewerthomn

Thanks! This worked for me

@tonyv69
tonyv69 commented Jan 17, 2013

Thanks, works well for me, good work me friend!

@klebershimabuku

Thank you for sharing this.

@humphriesjm

awesome. simple

@rowstu
rowstu commented Feb 7, 2013

awesome

@victorhazbunanuff

@clickbooq Thanks.

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"

@tomespen

Why not just add the following to your .bash_profile?
alias subl='open -a "Sublime Text 2"'

@ArtemGordinsky

Thanks, Tom! Thats was much easier.

@rouzbeh84

Please excuse me as I am a brand new beginner when it comes to terminal. When trying to manually add "export PATH=/usr/local/bin:(...)" and then sourcing the .bash_profile file I know get "command not found" for anything i try including basic commands. I can also no longer open .bash_profile with any editor, even VIM in terminal. Please advice as no terminal commands work at all.

@addahlbe

Thanks!!!

@kultom86

dotRuez, "Please advice as no terminal commands work at all."

You might have solved this already but there might be others like myself who make the same mistake.

Just open the Launchpad and start Sublime Text, navigate to your home directory ( if thats not where you are currently) and you should be able to open the .bash_profile file. then just delete the content of that file. You likely do have to make sure you path to /bin as well as where you wish to create the symlink. Author might want to address this in his guide so that other OSX newbies like my self fall into this "trap".

@connorsmith

Thank you!

@Rory80Hz
Rory80Hz commented Mar 5, 2013

Cheers, useful!

@jjamison
jjamison commented Mar 6, 2013

I'm getting a Permission Denied error when I run the first line at the terminal. Any advice?

@lopespm
lopespm commented Mar 6, 2013

Thank you very much, this was very helpful!

@jos4uke
jos4uke commented Mar 8, 2013

Thank you , exactly what I needed!

@chrisdigital

Thanks @artero for posting the gist and @nravichandra for your followup. It helped me get "subl" working, now I can change the command to anything I want.

@ThomasBush

So I had this working, but just upgraded to Sublime text 3, anyone know how to change the symlink? I tried navigating to usr/local/bin
rm sublime
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

@axelsilvaferreira

Very useful. thanks! :)

@devontem

Rachel thanks so much! fixed my problem!

@silvesthu

Thanks. It works well !

And I found that after using subl a terminal window will pop up, and it is some kine annoying since I'm using iTerm2 now.
I tried a more simple way.
alias sublime="open -a /Applications/Sublime\ Text\ 2.app"
It will do the same thing.

@kerstin
kerstin commented Mar 25, 2013

Ha @silvesthu, was looking for exactly that (also on iTerm2 currently) - thanks!

@mralexho

@artero Thanks for the tip. Typing sublime makes more sense to me than subl.

@wswld
wswld commented Mar 28, 2013

Actually, subl is just shorter. Somehow the workaround described above haven't worked for me since bash profile in Mac OS X is a mess and I'm trying to avoid that, but the simpler method, suggested by @silvesthu worked like a charm. Although I used subl as the alias. My issue was regarding launching Sublime from terminal at all.

@ghost
ghost commented Apr 5, 2013

@artearo please update your instructions taking into account the following:

Some users do not have a /.bash_profile. If they need to create one, they need to add the following, otherwise they will lose the default bash commands:

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"

I also found that I had to manually create the sublime directory in /usr/local/bin/sublime

Finally, calling source ~/.bash_profile didn't enable the sublime command. I had to close the Terminal and restart it. If I knew that in the beginning it would have saved me 30 minutes of my time lol!

@bevacqua

two thumbs up!

@evert
evert commented Apr 18, 2013

I also always put my own custom stuff in a local ~/bin directory. I like the idea that anything I customize to my system happens in ~bin. Furthermore, my ~bin is versioned and shared across systems.

I let OS X and Brew mess with my global stuff, but any quick binaries I may need should remain in my home directory.

@textreme

Anyone know how to do this for Sublime Text 3?

@YZSheng
YZSheng commented Apr 27, 2013

Thanks a lot! Works like a charm! Though in my case, there is no ~/.bash_profile, it's ~/.profile instead. :)

@kul1
kul1 commented Apr 27, 2013

Thanks it worked

@daniel-zahariev

Thanks!

@pelumini

Thanks it worked. But I cant use same terminal to continue working except I kill the process.

@barnett
barnett commented May 15, 2013

Thank you!

@jcarlosmolina

Neat and to the point. Works like a breeze. Thank you!

@russoedu

@blklane, you can add a " &" after the command, so the process runs in "background" and you can continue to use your terminal.

Like this:
sudo sublime /etc/hosts &

@karna41317

worked for me toooo

@mayantech

Tks 4 share, worked for me too

@AdamGoodApp

Thanks, alias sublime="open -a /Applications/Sublime\ Text\ 2.app" worked really well. Is there any difference in using this method?

@Dhavaprathap

Thanks it worked for me too

@RonanOD
RonanOD commented Jun 27, 2013

Very useful. Thanks for the tip!

@tamzheartbeatz

really appreciate it, thanks krv! I was trying to figure this out and kept getting an error with other directions. this worked perfectly!

@JonathanAaron

This is a great help.

@peterarnott

My Mountain Lion Install did not include a /usr/local/bin file, instead it just had a /usr/bin. By using that instead it all worked.
Thanks for the great tutorial :D

@pkorac
pkorac commented Jul 9, 2013

Works like a charm, thx

@michaelar

Thanks for the quick guide. I didn't realize that subl was hidden inside the app bundle... Good work! :)

@sgobin
sgobin commented Jul 10, 2013

Thanks!

Sublime 3

For Sublime Text 3 the subl path is different so the command is:

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

Hey, Neither export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH" nor export PATH=/usr/local/bin:$PATH work for me.

So I ended up with put alias sublime="open -a /Applications/Sublime\ Text\ 2.app" into the ~/.profile, and it works great!

YEAH!

Thanks!

@lucasazevedonet

thx!

@samuel-henry

thanks

@comcxx11

Thanks! great example.

@thejtate

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

Worked like a charm in Mountain Lion. Thanks so much for the great tutorial!

@kentor
kentor commented Aug 28, 2013

on mac, recently, opening sublime from terminal has been acting weirdly. i'm using iTerm, and when i open a file using sublime the bar on top still says iTerm even if I have sublime focused. also, typing in sublime isn't typing in sublime, the keys show up in iTerm.

anyone else have this problem?

@Jonathan-Eyler-Werve

Well written, much thanks.

@bstrahija

I personally like it better to open my files in a new windows, therefore a simple little alias ;)

alias subl="sublime -n"
@nathanbuckley

Works perfectly. Thank you so much!!

@soltrain
soltrain commented Sep 5, 2013

Thank you for the fantastic explanation.

@cuixin
cuixin commented Sep 12, 2013

good solution, tkx so much!

@unsuthee

Thanks!

@kodamirmo

Great, easy and awesome solution. Thanks!

@jeonghwan-kim

Very helpful.

@Showtimes

Was really confused when I kept getting:

FSPathMakeRef(/Applications/Sublime Text 2.app) failed with error -43.

While using:

alias sublime="open -a /Applications/Sublime\ Text\ 2.app"

From a recent download of sublime. I guess new downloads of sublime are not denoted as versioned? So using:

alias sublime="open -a /Applications/Sublime\ Text\.app"

worked fine.

Thanks for the awesome write up!

@mnegi
mnegi commented Nov 16, 2013

Really cool. Worked for me too.

@alexjamesbrown

Decent! :)

@jhebb
jhebb commented Dec 2, 2013

Instructions from krv worked for me in osx 10.9 which didn't have a /usr/local/bin folder by default.

Thanks!

@trangtungn

Thanks so much for the details instruction.

@jwjb
jwjb commented Dec 28, 2013

@silvesthu, I am running Sublime Text 3 on OS X 10.9.1 Build 13B42 and found your instructions simple and easy and added "alias sublime="open -a /Applications/Sublime\ Text.app" to my /users/your_user_name/.bash_profile with no problem.

@maggialejandro

works great, thanks!

@rewdy
rewdy commented Feb 13, 2014

Thank you! This was so much more helpful than the official documentation version.

@geoffspink

Great guide, but I used the alias trick as the symlink never worked.

@jessecarrigan

Really fantastic instructions. I could never get the official version to work correctly and this only took a few minutes. Thanks for putting this together.

@csrobinson86

Thank you...great guide appreciate 100%

@letsgoduke

Is there a way to do this using either Git Bash or Cygwin?

@jrwalker

thanks! this is awesome.

@ravyg
ravyg commented Apr 23, 2014

Nice!

@watkins
watkins commented May 9, 2014

thanks for the help!

@antgonzales

Worked like a charm. I was going crazy trying to get "subl" command working. Thank you!

@Frankhappens

Thank you. It works for me.

@JulienGenoud

thanks

@tjfwalker

Nifty, indeed. Thanks.

@therobyouknow

Thank you very much, I found also your instructions to work perfectly.

Surprised that Sublime themselves couldn't provide this for their own tool which I supported by paying to be a registered user.

@piplayan
piplayan commented Jun 2, 2014

Thanks . works perfect for me

@tejbirwason

Great! Saves me a lot of misery.

@kmccoan
kmccoan commented Jun 14, 2014

Awesome.. thanks a bunch

@jheg
jheg commented Jun 18, 2014

Thanks for this!

@emma1994
emma1994 commented Jul 1, 2014

@clickbooq, Your comment really helped me open sublime in Iterm2.

It feels so good when this article guides you through what you are doing. Many other sources just give you a bunch of commands and those commands lead you to nowhere.

@jonairey

Very helpful, thank you!

@methodik

Worked great - thanks!

@apkkadam

Awesome, that worked for me. Cheers.

@paulquappe

pretty nice, i also used
alias sublime="open -a /Applications/Sublime\ Text\ 2.app"
and it worked fine for me.

@mludi
mludi commented Sep 3, 2014

Thank you so much! Works like a charm

@fernandoGuisso

i did so:
create /usr/local/bin
sudo mkdir /usr/local/bin
symlink
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
add export PATH
open ~/.bash_profile

export PATH="/usr/local/bin/sublime:$PATH"

Its worked with "sublime" command

changing for "subl"
mv /usr/local/bin/sublime /usr/local/bin/subl

export PATH="/usr/local/bin/subl:$PATH"
@samuelkobe

@fernandoGuisso thanks for the suggestion of adding the shortcut:
mv /usr/local/bin/sublime /usr/local/bin/subl

I like this way more and it was not working before with just sublime (saved my sanity).

@ysyfff
ysyfff commented Oct 14, 2014

awesome!!!

@funkytaco

The cli app is called subl for brevity, in my opinion. Look at your command history and see how short most of the command names are in /bin. He's probably saved developers thousands of seconds. ๐Ÿ˜€

@balanza
balanza commented Nov 8, 2014

Just a little UPDATE for Sublime Text 3 (Mac OSX Yosemite)
The ST's folder is Sublime Text.app instead of Sublime Text 2.app, thus the command to be run slightly changes into:

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

@aasierra

Beautiful !

@rrrutledge

Thanks!

@GesJeremie

Awesome bro, thanks !

@trevorjh02

I screwed up. Not sure how to fix it now. I did..

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

sub1 instead of subl

now I have no idea how to fix it. Help would be much appreciated.

@joelfuentes

man U are awesome, the best and easier way to do it, thanks a lot.

@andreahull

worked perfectly. thank you!

@igor972
igor972 commented Jan 27, 2015

Works like a charm
<3

@chrishenzie

Thank you for these instructions.

In case anyone is struggling to run this line posted ON SUBLIME'S DOCUMENTATION (wtf guys)

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

be sure to first remove the quotations around the first arg!

@JennySwift

Thanks! I was struggling for ages trying to get this to work then I followed your tutorial and finally, it worked!

@duranmla

Thanks!

@RohinBhargava

Thanks so much!

@eladrianovalle

This was a game changer for me! Awesome!

@bolatkazybayev

Thanks!

@reedflinch

many thanks, very easy to follow

@danny-allen

Awesome, cheers!

@argen
argen commented Apr 10, 2015

Thanks for the tutorial!

@donald-s

Awesome. Thanks!

@ashishtibrewal

Works perfectly ! :D Thank you !

@piplayan

works perfectly. thanks!

@sudodoki

Thanks!
Btw, ST3 seems to have dropped the digit from the app name, so bin is in /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

@DrShpongle

Thanks, man!

@ganesharulanantham

It worked for me super cool! thank you

@justMrWhite

Thanks! I'm a happier person now.

@cjliu49
cjliu49 commented Jun 28, 2015

I did this and now I keep getting: "-bash: open: command not found". Uhoh. Any help?

@andygco
andygco commented Jul 19, 2015

I just did the same for Sublime Text 3. It's nearly the same except,

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

instead for the symlink

Thanks!

@blac3kman

Thanks; It works =)

@livercake

thanks a bunch for this. each time i get a new puter, i forget to do this, then curse when it doesn't work.
you, sir, are one rad motherbleeper :)

@echoyangyang

Thank you very much!

@Deanzie
Deanzie commented Sep 4, 2015

great!

@RIGALSAN

Hello,

Can someone please help me out, I cant get this to work properly. I am able to open sublime from my terminal but cant open specific files. I've tried opening up bash_profile but I've had no luck. picture attached.

Thank you,

screen shot 2015-09-20 at 1 16 47 am

@datamath28

I'm using iTerm2. The command works but it also opens a regular terminal window. Is there any way to prevent this?

@nkshah
nkshah commented Oct 8, 2015

great! was able to use terminal to use subl path and folder / file name

@chenawu2

What do we do about El Captain? We can't edit /bin ๐Ÿ˜ข

@practicous

A life saver, thank you !!

@johndavidhunt

Thank You, just what I was looking for!

@pedramteymoori

Thank you man, it's great !

@sumedhav

Thank you so much! This is exactly what I was looking for.

@sriharsha-sammeta

Awesome! Thanks! opening a file or directory using sublime text from terminal has now become super easy :D I will forget VI forever now

@ggrrll
ggrrll commented Jan 19, 2016

thanks to @tomespen

for some reason ARTERO's suggestion was not woking for me...

@tutley
tutley commented Jan 19, 2016

This is great!

@RanHaoCheng

It's worked perfectly! Thanks a lot!

@benallamar

Thank you so much ๐Ÿ‘

@JoxieMedina

Thanks, save to ๐Ÿ”–

@dhercher

Awesome!

@rogamoore

For ST3 use
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

Note that I removed the backslash from above and now the symlink will work.

@qetennyson

Thanks for putting this together! Finally able to start working on a project in a far more convenient manner.

@shanshahed

awesome.... Thanks.....

@szberko
szberko commented Feb 25, 2016

awesome and simple! Thank you!

@erav
erav commented Mar 20, 2016

the official documentation lists a very useful little option which creates a file from whatever you type into stdin:
subl -
this can be used for instance to write to a file the output of any command you type at the terminal (for instance ls):
ls | subl -

@thinkyhead

For some reason the version of subl included in the "Sublime Text 2" application bundle isn't working for me on OS X 10.11.2 El Capitan. So I ended up writing a shell script to replace it which actually works:

#!/bin/bash

for FN in "$@"; do
  if [ "$FN" = "-" ]; then
    TF=$(mktemp -t "subl stdin").txt
    cat - >"$TF"
    "$0" "$TF"
  else
    if [[ ! "$FN" =~ ^/ ]]; then
      FN="$PWD/$FN"
    fi
    FN=${FN/\"/\\\"}
    FN=${FN%/.}
    eval "osascript -e 'tell application \"Sublime Text 2\"' -e 'activate' -e 'open POSIX file \"$FN\"' -e 'end tell' -e 'return'"
  fi
done

While making an alias to open -a /path/to/Sublime Text 2 works for many cases, it doesn't work for subl -.

@neo108
neo108 commented Apr 7, 2016

brilliant! Thank you!

@aks0
aks0 commented Jun 10, 2016

thanks!

@maelsan
maelsan commented Jun 27, 2016

You saved my day. ๐Ÿ‘

@ishanbakshi

Worked like a charm ... thanks

@danyim
danyim commented Jul 17, 2016

For Sublime Text 3 users, this worked for me
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

@GNJM
GNJM commented Jul 24, 2016

Thanks!

@ccostel
ccostel commented Aug 17, 2016

Thanks! Really awesome stuff.

@vikas027

Thanks for sharing this. However, I like to play with aliases

~$ grep -i sublime ~/.bash_profile
alias sl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
~$
@3pns
3pns commented Sep 4, 2016

Awesome ! Thank you

@NathalieLehmann

Hi ! I'm getting "permission denied" from the first step. How can I get rid of this ? Thanks a lot :)

@briandjerf

@NathaLalou simply enter "sudo !!" after you get "permission denied"

@cdierdorff

sudo !! is not a fix for the permission denied problem. does anyone have a legitimate solution for getting a permission denied message? i am an admin user.

@flummingbird

Woot! thanks for this

@buluxan
buluxan commented Oct 6, 2016

working for me thx @vikas027

~$ grep -i sublime ~/.bash_profile
alias sl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
~$

@alyssaneub11

Getting the permission denied after the first step! Please help!

@mladenp
mladenp commented Nov 1, 2016

This is crazy complex and not working.
So i just added alias in .bash_profile like so:
alias = "open -a 'sublime text' "

@WelchCompositions

In case anyone is having trouble this instruction is for Sublime Text 2. If your app doesnt have a number at the end of the file name change the following:

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

To:

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

in hindsight it seems obvious but caught me up for a bit!

@pooley999
pooley999 commented Jan 4, 2017 edited

MacOS sierra Method:

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

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

echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile

source ~/.bash_profile

done!

@to-kra
to-kra commented Jan 12, 2017

On macOs you can simply define alias in .bash_profile e.g.: alias sublime='open -a "Sublime Text"'
everytime you open terminal, .bash_profile is sourced, and you simply can use sublime command. No need to make symlinks or export it to path. This solution is simples I ever saw. Thx

@trnt2110
trnt2110 commented Feb 2, 2017

Works for me, thanks!

@tallglassofmike

@krv Exactly what I needed, 5 years later. Thanks!

@aminqp
aminqp commented Feb 12, 2017

Awesome ! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment