Create a gist now

Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

Show comment
Hide comment
@mapkon

mapkon Jul 6, 2012

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

mapkon commented Jul 6, 2012

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

@christonog

This comment has been minimized.

Show comment
Hide comment
@christonog

christonog Aug 10, 2012

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.

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 comment has been minimized.

Show comment
Hide comment
@nicolechung

nicolechung Aug 10, 2012

This worked for me, thanks!

This worked for me, thanks!

@britishtea

This comment has been minimized.

Show comment
Hide comment
@britishtea

britishtea Aug 18, 2012

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?

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

This comment has been minimized.

Show comment
Hide comment
@DerektheDev

DerektheDev Aug 23, 2012

Worked perfectly--great!

Worked perfectly--great!

@krv

This comment has been minimized.

Show comment
Hide comment
@krv

krv 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

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

This comment has been minimized.

Show comment
Hide comment
@abachuk

abachuk Aug 24, 2012

Works great for me!!! Thanks

abachuk commented Aug 24, 2012

Works great for me!!! Thanks

@momer

This comment has been minimized.

Show comment
Hide comment
@momer

momer Aug 28, 2012

Thank you krv

momer commented Aug 28, 2012

Thank you krv

@nelsonenzo

This comment has been minimized.

Show comment
Hide comment
@nelsonenzo

nelsonenzo Sep 1, 2012

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!!!

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

This comment has been minimized.

Show comment
Hide comment
@ChrisChiera

ChrisChiera Sep 4, 2012

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!

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

This comment has been minimized.

Show comment
Hide comment
@johnnygoodman

johnnygoodman Sep 6, 2012

Super helpful. Thank you.

Super helpful. Thank you.

@rachelbaker

This comment has been minimized.

Show comment
Hide comment
@rachelbaker

rachelbaker Sep 11, 2012

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

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

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

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

@edu222

This comment has been minimized.

Show comment
Hide comment
@edu222

edu222 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

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

This comment has been minimized.

Show comment
Hide comment
@sundeepgupta

sundeepgupta Sep 17, 2012

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

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

This comment has been minimized.

Show comment
Hide comment
@aimango

aimango Sep 21, 2012

Awesome thanks!

aimango commented Sep 21, 2012

Awesome thanks!

@clickbooq

This comment has been minimized.

Show comment
Hide comment
@clickbooq

clickbooq Sep 30, 2012

@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"

@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

This comment has been minimized.

Show comment
Hide comment
@robwierzbowski

robwierzbowski Oct 23, 2012

+1. Thanks.

+1. Thanks.

@DavidVII

This comment has been minimized.

Show comment
Hide comment
@DavidVII

DavidVII Oct 25, 2012

SWEEEET!

Thanks!!!

SWEEEET!

Thanks!!!

@subfuzion

This comment has been minimized.

Show comment
Hide comment
@subfuzion

subfuzion Nov 1, 2012

+1. Thanks!

+1. Thanks!

@MattFielding

This comment has been minimized.

Show comment
Hide comment
@MattFielding

MattFielding Nov 14, 2012

Thanks for this, it helps me work around an issue with running a compass build with rvm from within ST2 WhatWeDo/Sublime-Text-2-Compass-Build-System#6

Thanks for this, it helps me work around an issue with running a compass build with rvm from within ST2 WhatWeDo/Sublime-Text-2-Compass-Build-System#6

@ButuzGOL

This comment has been minimized.

Show comment
Hide comment
@ButuzGOL

ButuzGOL Dec 2, 2012

Thanks!

ButuzGOL commented Dec 2, 2012

Thanks!

@nravichandra

This comment has been minimized.

Show comment
Hide comment
@nravichandra

nravichandra Dec 16, 2012

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

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

This comment has been minimized.

Show comment
Hide comment
@LiquidNight

LiquidNight Dec 29, 2012

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

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

This comment has been minimized.

Show comment
Hide comment
@cisliu

cisliu 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!

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

This comment has been minimized.

Show comment
Hide comment
@klipnov

klipnov Jan 8, 2013

It works...Good tutorial

klipnov commented Jan 8, 2013

It works...Good tutorial

@hewerthomn

This comment has been minimized.

Show comment
Hide comment
@hewerthomn

hewerthomn Jan 11, 2013

Thanks! This worked for me

Thanks! This worked for me

@tonyv69

This comment has been minimized.

Show comment
Hide comment
@tonyv69

tonyv69 Jan 17, 2013

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

tonyv69 commented Jan 17, 2013

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

@klebershimabuku

This comment has been minimized.

Show comment
Hide comment
@klebershimabuku

klebershimabuku Feb 2, 2013

Thank you for sharing this.

Thank you for sharing this.

@humphriesjm

This comment has been minimized.

Show comment
Hide comment
@humphriesjm

humphriesjm Feb 6, 2013

awesome. simple

awesome. simple

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 7, 2013

awesome

ghost commented Feb 7, 2013

awesome

@victorhazbunanuff

This comment has been minimized.

Show comment
Hide comment
@victorhazbunanuff

victorhazbunanuff Feb 10, 2013

@clickbooq Thanks.

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

@clickbooq Thanks.

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

@tomespen

This comment has been minimized.

Show comment
Hide comment
@tomespen

tomespen Feb 19, 2013

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

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

@ArtemGordinsky

This comment has been minimized.

Show comment
Hide comment
@ArtemGordinsky

ArtemGordinsky Feb 20, 2013

Thanks, Tom! Thats was much easier.

Thanks, Tom! Thats was much easier.

@rouzbeh84

This comment has been minimized.

Show comment
Hide comment
@rouzbeh84

rouzbeh84 Feb 26, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@addahlbe

addahlbe Feb 26, 2013

Thanks!!!

Thanks!!!

@kultom86

This comment has been minimized.

Show comment
Hide comment
@kultom86

kultom86 Feb 26, 2013

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".

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

This comment has been minimized.

Show comment
Hide comment
@connorsmith

connorsmith Mar 2, 2013

Thank you!

Thank you!

@Rory80Hz

This comment has been minimized.

Show comment
Hide comment
@Rory80Hz

Rory80Hz Mar 5, 2013

Cheers, useful!

Rory80Hz commented Mar 5, 2013

Cheers, useful!

@jjamison

This comment has been minimized.

Show comment
Hide comment
@jjamison

jjamison Mar 6, 2013

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

jjamison commented Mar 6, 2013

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

@lopespm

This comment has been minimized.

Show comment
Hide comment
@lopespm

lopespm Mar 6, 2013

Thank you very much, this was very helpful!

lopespm commented Mar 6, 2013

Thank you very much, this was very helpful!

@jos4uke

This comment has been minimized.

Show comment
Hide comment
@jos4uke

jos4uke Mar 8, 2013

Thank you , exactly what I needed!

jos4uke commented Mar 8, 2013

Thank you , exactly what I needed!

@chrisdigital

This comment has been minimized.

Show comment
Hide comment
@chrisdigital

chrisdigital Mar 9, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@ThomasBush

ThomasBush Mar 12, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@axelsilvaferreira

axelsilvaferreira Mar 16, 2013

Very useful. thanks! :)

Very useful. thanks! :)

@devontem

This comment has been minimized.

Show comment
Hide comment
@devontem

devontem Mar 21, 2013

Rachel thanks so much! fixed my problem!

Rachel thanks so much! fixed my problem!

@silvesthu

This comment has been minimized.

Show comment
Hide comment
@silvesthu

silvesthu Mar 24, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@kerstin

kerstin Mar 25, 2013

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

kerstin commented Mar 25, 2013

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

@mralexho

This comment has been minimized.

Show comment
Hide comment
@mralexho

mralexho Mar 27, 2013

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

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

@wswld

This comment has been minimized.

Show comment
Hide comment
@wswld

wswld 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.

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

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost 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!

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

This comment has been minimized.

Show comment
Hide comment
@bevacqua

bevacqua Apr 16, 2013

two thumbs up!

two thumbs up!

@evert

This comment has been minimized.

Show comment
Hide comment
@evert

evert 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.

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

This comment has been minimized.

Show comment
Hide comment
@textreme

textreme Apr 25, 2013

Anyone know how to do this for Sublime Text 3?

Anyone know how to do this for Sublime Text 3?

@YZSheng

This comment has been minimized.

Show comment
Hide comment
@YZSheng

YZSheng Apr 27, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@kul1

kul1 Apr 27, 2013

Thanks it worked

kul1 commented Apr 27, 2013

Thanks it worked

@daniel-zahariev

This comment has been minimized.

Show comment
Hide comment
@daniel-zahariev

daniel-zahariev Apr 30, 2013

Thanks!

Thanks!

@pelumini

This comment has been minimized.

Show comment
Hide comment
@pelumini

pelumini May 15, 2013

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

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

@barnett

This comment has been minimized.

Show comment
Hide comment
@barnett

barnett May 15, 2013

Thank you!

barnett commented May 15, 2013

Thank you!

@jcarlosmolina

This comment has been minimized.

Show comment
Hide comment
@jcarlosmolina

jcarlosmolina May 18, 2013

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

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

@russoedu

This comment has been minimized.

Show comment
Hide comment
@russoedu

russoedu May 27, 2013

@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 &

@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

This comment has been minimized.

Show comment
Hide comment
@karna41317

karna41317 Jun 10, 2013

worked for me toooo

worked for me toooo

@mayantech

This comment has been minimized.

Show comment
Hide comment
@mayantech

mayantech Jun 12, 2013

Tks 4 share, worked for me too

Tks 4 share, worked for me too

@AdamGoodApp

This comment has been minimized.

Show comment
Hide comment
@AdamGoodApp

AdamGoodApp Jun 17, 2013

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

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

@Dhavaprathap

This comment has been minimized.

Show comment
Hide comment
@Dhavaprathap

Dhavaprathap Jun 27, 2013

Thanks it worked for me too

Thanks it worked for me too

@RonanOD

This comment has been minimized.

Show comment
Hide comment
@RonanOD

RonanOD Jun 27, 2013

Very useful. Thanks for the tip!

RonanOD commented Jun 27, 2013

Very useful. Thanks for the tip!

@tamzheartbeatz

This comment has been minimized.

Show comment
Hide comment
@tamzheartbeatz

tamzheartbeatz Jul 1, 2013

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

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 comment has been minimized.

Show comment
Hide comment
@JonathanAaron

JonathanAaron Jul 3, 2013

This is a great help.

This is a great help.

@peterarnott

This comment has been minimized.

Show comment
Hide comment
@peterarnott

peterarnott Jul 4, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@pkorac

pkorac Jul 9, 2013

Works like a charm, thx

pkorac commented Jul 9, 2013

Works like a charm, thx

@michaelar

This comment has been minimized.

Show comment
Hide comment
@michaelar

michaelar Jul 9, 2013

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

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

@sgobin

This comment has been minimized.

Show comment
Hide comment
@sgobin

sgobin 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

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

This comment has been minimized.

Show comment
Hide comment
@liusashmily

liusashmily Jul 18, 2013

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!

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

This comment has been minimized.

Show comment
Hide comment
@lucasazevedonet

lucasazevedonet Aug 7, 2013

thx!

thx!

@samuel-henry

This comment has been minimized.

Show comment
Hide comment
@samuel-henry

samuel-henry Aug 8, 2013

thanks

thanks

@comcxx11

This comment has been minimized.

Show comment
Hide comment
@comcxx11

comcxx11 Aug 11, 2013

Thanks! great example.

Thanks! great example.

@thejtate

This comment has been minimized.

Show comment
Hide comment
@thejtate

thejtate Aug 15, 2013

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!

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

This comment has been minimized.

Show comment
Hide comment
@kentor

kentor 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?

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

This comment has been minimized.

Show comment
Hide comment
@Jonathan-Eyler-Werve

Jonathan-Eyler-Werve Aug 29, 2013

Well written, much thanks.

Well written, much thanks.

@bstrahija

This comment has been minimized.

Show comment
Hide comment
@bstrahija

bstrahija Sep 2, 2013

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

alias subl="sublime -n"

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

alias subl="sublime -n"
@nathanbuckley

This comment has been minimized.

Show comment
Hide comment
@nathanbuckley

nathanbuckley Sep 3, 2013

Works perfectly. Thank you so much!!

Works perfectly. Thank you so much!!

@soltrain

This comment has been minimized.

Show comment
Hide comment
@soltrain

soltrain Sep 5, 2013

Thank you for the fantastic explanation.

soltrain commented Sep 5, 2013

Thank you for the fantastic explanation.

@cuixin

This comment has been minimized.

Show comment
Hide comment
@cuixin

cuixin Sep 12, 2013

good solution, tkx so much!

cuixin commented Sep 12, 2013

good solution, tkx so much!

@unsuthee

This comment has been minimized.

Show comment
Hide comment
@unsuthee

unsuthee Sep 21, 2013

Thanks!

Thanks!

@kodamirmo

This comment has been minimized.

Show comment
Hide comment
@kodamirmo

kodamirmo Sep 25, 2013

Great, easy and awesome solution. Thanks!

Great, easy and awesome solution. Thanks!

@jeonghwan-kim

This comment has been minimized.

Show comment
Hide comment
@jeonghwan-kim

jeonghwan-kim Oct 17, 2013

Very helpful.

Very helpful.

@Showtimes

This comment has been minimized.

Show comment
Hide comment
@Showtimes

Showtimes Nov 13, 2013

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!

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

This comment has been minimized.

Show comment
Hide comment
@mnegi

mnegi Nov 16, 2013

Really cool. Worked for me too.

mnegi commented Nov 16, 2013

Really cool. Worked for me too.

@alexjamesbrown

This comment has been minimized.

Show comment
Hide comment
@alexjamesbrown

alexjamesbrown Nov 19, 2013

Decent! :)

Decent! :)

@jhebb

This comment has been minimized.

Show comment
Hide comment
@jhebb

jhebb 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!

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

This comment has been minimized.

Show comment
Hide comment
@trangtungn

trangtungn Dec 4, 2013

Thanks so much for the details instruction.

Thanks so much for the details instruction.

@jwjb

This comment has been minimized.

Show comment
Hide comment
@jwjb

jwjb 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.

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

This comment has been minimized.

Show comment
Hide comment
@maggialejandro

maggialejandro Feb 11, 2014

works great, thanks!

works great, thanks!

@rewdy

This comment has been minimized.

Show comment
Hide comment
@rewdy

rewdy Feb 13, 2014

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

rewdy commented Feb 13, 2014

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

@geoffspink

This comment has been minimized.

Show comment
Hide comment
@geoffspink

geoffspink Feb 14, 2014

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

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

@jessecarrigan

This comment has been minimized.

Show comment
Hide comment
@jessecarrigan

jessecarrigan Mar 10, 2014

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.

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

This comment has been minimized.

Show comment
Hide comment
@csrobinson86

csrobinson86 Apr 6, 2014

Thank you...great guide appreciate 100%

Thank you...great guide appreciate 100%

@letsgoduke

This comment has been minimized.

Show comment
Hide comment
@letsgoduke

letsgoduke Apr 9, 2014

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

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

@jrwalker

This comment has been minimized.

Show comment
Hide comment
@jrwalker

jrwalker Apr 22, 2014

thanks! this is awesome.

thanks! this is awesome.

@ravyg

This comment has been minimized.

Show comment
Hide comment
@ravyg

ravyg Apr 23, 2014

Nice!

ravyg commented Apr 23, 2014

Nice!

@watkins

This comment has been minimized.

Show comment
Hide comment
@watkins

watkins May 9, 2014

thanks for the help!

watkins commented May 9, 2014

thanks for the help!

@antgonzales

This comment has been minimized.

Show comment
Hide comment
@antgonzales

antgonzales May 10, 2014

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

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

@Frankhappens

This comment has been minimized.

Show comment
Hide comment
@Frankhappens

Frankhappens May 10, 2014

Thank you. It works for me.

Thank you. It works for me.

@JulienGenoud

This comment has been minimized.

Show comment
Hide comment
@JulienGenoud

JulienGenoud May 13, 2014

thanks

thanks

@tjfwalker

This comment has been minimized.

Show comment
Hide comment
@tjfwalker

tjfwalker May 19, 2014

Nifty, indeed. Thanks.

Nifty, indeed. Thanks.

@therobyouknow

This comment has been minimized.

Show comment
Hide comment
@therobyouknow

therobyouknow Jun 2, 2014

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.

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

This comment has been minimized.

Show comment
Hide comment
@piplayan

piplayan Jun 2, 2014

Thanks . works perfect for me

piplayan commented Jun 2, 2014

Thanks . works perfect for me

@tejbirwason

This comment has been minimized.

Show comment
Hide comment
@tejbirwason

tejbirwason Jun 11, 2014

Great! Saves me a lot of misery.

Great! Saves me a lot of misery.

@kmccoan

This comment has been minimized.

Show comment
Hide comment
@kmccoan

kmccoan Jun 14, 2014

Awesome.. thanks a bunch

kmccoan commented Jun 14, 2014

Awesome.. thanks a bunch

@jheg

This comment has been minimized.

Show comment
Hide comment
@jheg

jheg Jun 18, 2014

Thanks for this!

jheg commented Jun 18, 2014

Thanks for this!

@emma1994

This comment has been minimized.

Show comment
Hide comment
@emma1994

emma1994 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.

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

This comment has been minimized.

Show comment
Hide comment
@jonairey

jonairey Jul 15, 2014

Very helpful, thank you!

Very helpful, thank you!

@methodik

This comment has been minimized.

Show comment
Hide comment
@methodik

methodik Jul 18, 2014

Worked great - thanks!

Worked great - thanks!

@apkkadam

This comment has been minimized.

Show comment
Hide comment
@apkkadam

apkkadam Jul 25, 2014

Awesome, that worked for me. Cheers.

Awesome, that worked for me. Cheers.

@paulquappe

This comment has been minimized.

Show comment
Hide comment
@paulquappe

paulquappe Aug 26, 2014

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

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

@mludi

This comment has been minimized.

Show comment
Hide comment
@mludi

mludi Sep 3, 2014

Thank you so much! Works like a charm

mludi commented Sep 3, 2014

Thank you so much! Works like a charm

@fguisso

This comment has been minimized.

Show comment
Hide comment
@fguisso

fguisso Sep 9, 2014

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"

fguisso commented Sep 9, 2014

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

This comment has been minimized.

Show comment
Hide comment
@samuelkobe

samuelkobe Sep 23, 2014

@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).

@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

This comment has been minimized.

Show comment
Hide comment
@ysyfff

ysyfff Oct 14, 2014

awesome!!!

ysyfff commented Oct 14, 2014

awesome!!!

@funkytaco

This comment has been minimized.

Show comment
Hide comment
@funkytaco

funkytaco Nov 3, 2014

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. 😀

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

This comment has been minimized.

Show comment
Hide comment
@balanza

balanza 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

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

This comment has been minimized.

Show comment
Hide comment
@aasierra

aasierra Nov 21, 2014

Beautiful !

Beautiful !

@rrrutledge

This comment has been minimized.

Show comment
Hide comment
@rrrutledge

rrrutledge Nov 21, 2014

Thanks!

Thanks!

@GesJeremie

This comment has been minimized.

Show comment
Hide comment
@GesJeremie

GesJeremie Dec 8, 2014

Awesome bro, thanks !

Awesome bro, thanks !

@trevorjh02

This comment has been minimized.

Show comment
Hide comment
@trevorjh02

trevorjh02 Jan 5, 2015

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.

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

This comment has been minimized.

Show comment
Hide comment
@joelfuentes

joelfuentes Jan 12, 2015

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

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

@andreahull

This comment has been minimized.

Show comment
Hide comment
@andreahull

andreahull Jan 26, 2015

worked perfectly. thank you!

worked perfectly. thank you!

@igor972

This comment has been minimized.

Show comment
Hide comment
@igor972

igor972 Jan 27, 2015

Works like a charm
<3

igor972 commented Jan 27, 2015

Works like a charm
<3

@chrishenzie

This comment has been minimized.

Show comment
Hide comment
@chrishenzie

chrishenzie Feb 10, 2015

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!

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

This comment has been minimized.

Show comment
Hide comment
@JennySwift

JennySwift Feb 13, 2015

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

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

@duranmla

This comment has been minimized.

Show comment
Hide comment
@duranmla

duranmla Feb 13, 2015

Thanks!

Thanks!

@RohinBhargava

This comment has been minimized.

Show comment
Hide comment
@RohinBhargava

RohinBhargava Mar 4, 2015

Thanks so much!

Thanks so much!

@eladrianovalle

This comment has been minimized.

Show comment
Hide comment
@eladrianovalle

eladrianovalle Mar 7, 2015

This was a game changer for me! Awesome!

This was a game changer for me! Awesome!

@bolatk

This comment has been minimized.

Show comment
Hide comment
@bolatk

bolatk Mar 17, 2015

Thanks!

bolatk commented Mar 17, 2015

Thanks!

@reedflinch

This comment has been minimized.

Show comment
Hide comment
@reedflinch

reedflinch Apr 1, 2015

many thanks, very easy to follow

many thanks, very easy to follow

@danny-allen

This comment has been minimized.

Show comment
Hide comment
@danny-allen

danny-allen Apr 3, 2015

Awesome, cheers!

Awesome, cheers!

@argen

This comment has been minimized.

Show comment
Hide comment
@argen

argen Apr 10, 2015

Thanks for the tutorial!

argen commented Apr 10, 2015

Thanks for the tutorial!

@donald-s

This comment has been minimized.

Show comment
Hide comment
@donald-s

donald-s Apr 13, 2015

Awesome. Thanks!

Awesome. Thanks!

@ashishtibrewal

This comment has been minimized.

Show comment
Hide comment
@ashishtibrewal

ashishtibrewal Apr 25, 2015

Works perfectly ! :D Thank you !

Works perfectly ! :D Thank you !

@piplayan

This comment has been minimized.

Show comment
Hide comment
@piplayan

piplayan Apr 26, 2015

works perfectly. thanks!

works perfectly. thanks!

@sudodoki

This comment has been minimized.

Show comment
Hide comment
@sudodoki

sudodoki May 11, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@DrShpongle

DrShpongle Jun 8, 2015

Thanks, man!

Thanks, man!

@ganesharulanantham

This comment has been minimized.

Show comment
Hide comment
@ganesharulanantham

ganesharulanantham Jun 21, 2015

It worked for me super cool! thank you

It worked for me super cool! thank you

@justMrWhite

This comment has been minimized.

Show comment
Hide comment
@justMrWhite

justMrWhite Jun 27, 2015

Thanks! I'm a happier person now.

Thanks! I'm a happier person now.

@cjliu49

This comment has been minimized.

Show comment
Hide comment
@cjliu49

cjliu49 Jun 28, 2015

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

cjliu49 commented Jun 28, 2015

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost 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!

ghost 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

This comment has been minimized.

Show comment
Hide comment
@blac3kman

blac3kman Aug 4, 2015

Thanks; It works =)

Thanks; It works =)

@livercake

This comment has been minimized.

Show comment
Hide comment
@livercake

livercake Aug 7, 2015

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 :)

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

This comment has been minimized.

Show comment
Hide comment
@echoyangyang

echoyangyang Aug 15, 2015

Thank you very much!

Thank you very much!

@Deanzie

This comment has been minimized.

Show comment
Hide comment
@Deanzie

Deanzie Sep 4, 2015

great!

Deanzie commented Sep 4, 2015

great!

@RIGALSAN

This comment has been minimized.

Show comment
Hide comment
@RIGALSAN

RIGALSAN Sep 20, 2015

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

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

@brian8128

This comment has been minimized.

Show comment
Hide comment
@brian8128

brian8128 Oct 5, 2015

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

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

@nkshah

This comment has been minimized.

Show comment
Hide comment
@nkshah

nkshah Oct 8, 2015

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

nkshah commented Oct 8, 2015

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

@chenawu2

This comment has been minimized.

Show comment
Hide comment
@chenawu2

chenawu2 Oct 13, 2015

What do we do about El Captain? We can't edit /bin 😢

What do we do about El Captain? We can't edit /bin 😢

@practicous

This comment has been minimized.

Show comment
Hide comment
@practicous

practicous Oct 29, 2015

A life saver, thank you !!

A life saver, thank you !!

@johndavidhunt

This comment has been minimized.

Show comment
Hide comment
@johndavidhunt

johndavidhunt Dec 3, 2015

Thank You, just what I was looking for!

Thank You, just what I was looking for!

@pedramteymoori

This comment has been minimized.

Show comment
Hide comment
@pedramteymoori

pedramteymoori Dec 13, 2015

Thank you man, it's great !

Thank you man, it's great !

@sumedhav

This comment has been minimized.

Show comment
Hide comment
@sumedhav

sumedhav Dec 20, 2015

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

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

@sriharsha-sammeta

This comment has been minimized.

Show comment
Hide comment
@sriharsha-sammeta

sriharsha-sammeta Dec 26, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@ggrrll

ggrrll Jan 19, 2016

thanks to @tomespen

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

ggrrll commented Jan 19, 2016

thanks to @tomespen

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

@tutley

This comment has been minimized.

Show comment
Hide comment
@tutley

tutley Jan 19, 2016

This is great!

tutley commented Jan 19, 2016

This is great!

@RanHaoCheng

This comment has been minimized.

Show comment
Hide comment
@RanHaoCheng

RanHaoCheng Jan 25, 2016

It's worked perfectly! Thanks a lot!

It's worked perfectly! Thanks a lot!

@benallamar

This comment has been minimized.

Show comment
Hide comment
@benallamar

benallamar Jan 27, 2016

Thank you so much 👍

Thank you so much 👍

@JoxieMedina

This comment has been minimized.

Show comment
Hide comment
@JoxieMedina

JoxieMedina Jan 30, 2016

Thanks, save to 🔖

Thanks, save to 🔖

@dhercher

This comment has been minimized.

Show comment
Hide comment
@dhercher

dhercher Jan 31, 2016

Awesome!

Awesome!

@rogamoore

This comment has been minimized.

Show comment
Hide comment
@rogamoore

rogamoore Feb 2, 2016

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.

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

This comment has been minimized.

Show comment
Hide comment
@qetennyson

qetennyson Feb 5, 2016

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

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

@shanshahed

This comment has been minimized.

Show comment
Hide comment
@shanshahed

shanshahed Feb 14, 2016

awesome.... Thanks.....

awesome.... Thanks.....

@szberko

This comment has been minimized.

Show comment
Hide comment
@szberko

szberko Feb 25, 2016

awesome and simple! Thank you!

szberko commented Feb 25, 2016

awesome and simple! Thank you!

@erav

This comment has been minimized.

Show comment
Hide comment
@erav

erav 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 -

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

This comment has been minimized.

Show comment
Hide comment
@thinkyhead

thinkyhead Mar 23, 2016

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 -.

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

This comment has been minimized.

Show comment
Hide comment
@neo108

neo108 Apr 7, 2016

brilliant! Thank you!

neo108 commented Apr 7, 2016

brilliant! Thank you!

@aks0

This comment has been minimized.

Show comment
Hide comment
@aks0

aks0 Jun 10, 2016

thanks!

aks0 commented Jun 10, 2016

thanks!

@maelsan

This comment has been minimized.

Show comment
Hide comment
@maelsan

maelsan Jun 27, 2016

You saved my day. 👍

maelsan commented Jun 27, 2016

You saved my day. 👍

@ishanbakshi

This comment has been minimized.

Show comment
Hide comment
@ishanbakshi

ishanbakshi Jul 6, 2016

Worked like a charm ... thanks

Worked like a charm ... thanks

@danyim

This comment has been minimized.

Show comment
Hide comment
@danyim

danyim 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

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

This comment has been minimized.

Show comment
Hide comment
@GNJM

GNJM Jul 24, 2016

Thanks!

GNJM commented Jul 24, 2016

Thanks!

@ccostel

This comment has been minimized.

Show comment
Hide comment
@ccostel

ccostel Aug 17, 2016

Thanks! Really awesome stuff.

ccostel commented Aug 17, 2016

Thanks! Really awesome stuff.

@vikas027

This comment has been minimized.

Show comment
Hide comment
@vikas027

vikas027 Aug 25, 2016

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'
~$

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

This comment has been minimized.

Show comment
Hide comment
@3pns

3pns Sep 4, 2016

Awesome ! Thank you

3pns commented Sep 4, 2016

Awesome ! Thank you

@LehmannN

This comment has been minimized.

Show comment
Hide comment
@LehmannN

LehmannN Sep 12, 2016

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

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

@briandjerf

This comment has been minimized.

Show comment
Hide comment
@briandjerf

briandjerf Sep 21, 2016

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

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 30, 2016

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.

ghost commented Sep 30, 2016

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

This comment has been minimized.

Show comment
Hide comment
@flummingbird

flummingbird Oct 5, 2016

Woot! thanks for this

Woot! thanks for this

@buluxan

This comment has been minimized.

Show comment
Hide comment
@buluxan

buluxan Oct 6, 2016

working for me thx @vikas027

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

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

This comment has been minimized.

Show comment
Hide comment
@alyssaneub11

alyssaneub11 Oct 11, 2016

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

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

@mladenp

This comment has been minimized.

Show comment
Hide comment
@mladenp

mladenp 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' "

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

This comment has been minimized.

Show comment
Hide comment
@WelchCompositions

WelchCompositions Nov 30, 2016

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!

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

This comment has been minimized.

Show comment
Hide comment
@pooley999

pooley999 Jan 4, 2017

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!

pooley999 commented Jan 4, 2017

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!

@tokra

This comment has been minimized.

Show comment
Hide comment
@tokra

tokra 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

tokra 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

This comment has been minimized.

Show comment
Hide comment
@trnt2110

trnt2110 Feb 2, 2017

Works for me, thanks!

trnt2110 commented Feb 2, 2017

Works for me, thanks!

@tallglassofmike

This comment has been minimized.

Show comment
Hide comment
@tallglassofmike

tallglassofmike Feb 11, 2017

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

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

@aminqp

This comment has been minimized.

Show comment
Hide comment
@aminqp

aminqp Feb 12, 2017

Awesome ! Thank you

aminqp commented Feb 12, 2017

Awesome ! Thank you

@whalemare

This comment has been minimized.

Show comment
Hide comment
@whalemare

whalemare May 13, 2017

Russian translate below
Перевод на русский, кому надо, быстрее и проще
https://gist.github.com/whalemare/eb28ea4e4f45afeda33a9258c088504a

Russian translate below
Перевод на русский, кому надо, быстрее и проще
https://gist.github.com/whalemare/eb28ea4e4f45afeda33a9258c088504a

@LaurenQED

This comment has been minimized.

Show comment
Hide comment
@LaurenQED

LaurenQED Jun 23, 2017

Thanks tomaspen!

Steps I took to get it to work for Sierra 10.12.5

$open ~/.bash
add to top of bash profile: alias subl='open -a "Sublime Text"'
save bash_profile
$source ~/.bash_profile
$subl .

Thanks tomaspen!

Steps I took to get it to work for Sierra 10.12.5

$open ~/.bash
add to top of bash profile: alias subl='open -a "Sublime Text"'
save bash_profile
$source ~/.bash_profile
$subl .

@tonhwk

This comment has been minimized.

Show comment
Hide comment
@tonhwk

tonhwk Jul 30, 2017

I dont know how but it works! thank you!

tonhwk commented Jul 30, 2017

I dont know how but it works! thank you!

@fr6nco

This comment has been minimized.

Show comment
Hide comment
@fr6nco

fr6nco Sep 28, 2017

Verrrry fucking useful!! thank you very much

fr6nco commented Sep 28, 2017

Verrrry fucking useful!! thank you very much

@quantumproducer

This comment has been minimized.

Show comment
Hide comment
@quantumproducer

quantumproducer Oct 14, 2017

@tomespen that won't work with doing subl ~/folder.

@tomespen that won't work with doing subl ~/folder.

@lnshi

This comment has been minimized.

Show comment
Hide comment
@lnshi

lnshi Dec 31, 2017

Really no need to be this complex, just add one line alias into your .bash_profile, then you are done:

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

subl [YOUR_FILE_PATH]

lnshi commented Dec 31, 2017

Really no need to be this complex, just add one line alias into your .bash_profile, then you are done:

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

subl [YOUR_FILE_PATH]

@whimsycwd

This comment has been minimized.

Show comment
Hide comment
@whimsycwd

whimsycwd Jun 19, 2018

Thank you!~

Thank you!~

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