Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.

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

@edmundojr

This comment has been minimized.

Show comment
Hide comment
@edmundojr

edmundojr Jan 30, 2012

I have encountered some erros when execute source .bash_profile, can you help me?

Marvin:~ edmundojr$ source .bash_profile 
-bash: .bash_profile: line 1: syntax error near unexpected token `('
-bash: .bash_profile: line 1: `export PATH=/usr/local:(…)'

Update:
Now I see the “note”, case solved!

edmundojr commented Jan 30, 2012

I have encountered some erros when execute source .bash_profile, can you help me?

Marvin:~ edmundojr$ source .bash_profile 
-bash: .bash_profile: line 1: syntax error near unexpected token `('
-bash: .bash_profile: line 1: `export PATH=/usr/local:(…)'

Update:
Now I see the “note”, case solved!

@stinoga

This comment has been minimized.

Show comment
Hide comment
@stinoga

stinoga Mar 2, 2012

Awesome breakdown of this. I also like that I can name the command whatever I like :)

Thanks!

stinoga commented Mar 2, 2012

Awesome breakdown of this. I also like that I can name the command whatever I like :)

Thanks!

@pedrocifuentes

This comment has been minimized.

Show comment
Hide comment
@pedrocifuentes

pedrocifuentes Mar 24, 2012

Thx mate,

I was reading the a tips&trick guide of Sublime 2 here: http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/ and I didnt feel very confortable with the bin folder, this solution it´s easier and... why not? more elegant

/clap

pedrocifuentes commented Mar 24, 2012

Thx mate,

I was reading the a tips&trick guide of Sublime 2 here: http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/ and I didnt feel very confortable with the bin folder, this solution it´s easier and... why not? more elegant

/clap

@AndrewHulbert

This comment has been minimized.

Show comment
Hide comment
@AndrewHulbert

AndrewHulbert Jul 24, 2012

I followed these steps but had to create a .bash_profile first. I lost my commands in my terminal when I did this. I am sure it is something that I did creating the .bash_profile but I don't know how to get it back. Any help would be very much appreciated.

Andrew

AndrewHulbert commented Jul 24, 2012

I followed these steps but had to create a .bash_profile first. I lost my commands in my terminal when I did this. I am sure it is something that I did creating the .bash_profile but I don't know how to get it back. Any help would be very much appreciated.

Andrew

@ChrisChiera

This comment has been minimized.

Show comment
Hide comment
@ChrisChiera

ChrisChiera Sep 4, 2012

As Andrew noted, .bash_profile is not on a Mac by default. Just followed these instructions on my Mac. I created a .bash_profile but as it's empty to start the directions here apply to people who already have one it seems. Can you provide an example file?

ChrisChiera commented Sep 4, 2012

As Andrew noted, .bash_profile is not on a Mac by default. Just followed these instructions on my Mac. I created a .bash_profile but as it's empty to start the directions here apply to people who already have one it seems. Can you provide an example file?

@raybesiga

This comment has been minimized.

Show comment
Hide comment
@raybesiga

raybesiga Sep 24, 2012

This is excellent Olivier. Kudos to you! Worked perfectly!

raybesiga commented Sep 24, 2012

This is excellent Olivier. Kudos to you! Worked perfectly!

@reescasey

This comment has been minimized.

Show comment
Hide comment
@reescasey

reescasey Oct 9, 2012

Worked great. Thank you!

reescasey commented Oct 9, 2012

Worked great. Thank you!

@sassinack

This comment has been minimized.

Show comment
Hide comment
@sassinack

sassinack commented Oct 16, 2012

Thanks!

@georgeu2000

This comment has been minimized.

Show comment
Hide comment
@georgeu2000

georgeu2000 Oct 17, 2012

Worked great. Thanks!

georgeu2000 commented Oct 17, 2012

Worked great. Thanks!

@jjperezaguinaga

This comment has been minimized.

Show comment
Hide comment
@jjperezaguinaga

jjperezaguinaga Oct 24, 2012

Just for the record, this line didn't work for me in my new Mac 10.7.4
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

until I wrapped the location in quotes.
ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

jjperezaguinaga commented Oct 24, 2012

Just for the record, this line didn't work for me in my new Mac 10.7.4
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

until I wrapped the location in quotes.
ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

@mediter

This comment has been minimized.

Show comment
Hide comment
@mediter

mediter Nov 26, 2012

I did as instructed first
ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Terminal gives the prompt "ln: /usr/local/bin/sublime: No such file or directory"

so I went to check in /usr/local/, turns out there is no directory named "bin" here, but there is one in /usr

thus I changed the line to
sudo ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/bin/sublime

quit Terminal, then relaunch it
try to use sublime as a command, terminal still tells me "-bash: sublime: command not found"

echo $PATH gives the following result
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

what am I doing wrong here?

mediter commented Nov 26, 2012

I did as instructed first
ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Terminal gives the prompt "ln: /usr/local/bin/sublime: No such file or directory"

so I went to check in /usr/local/, turns out there is no directory named "bin" here, but there is one in /usr

thus I changed the line to
sudo ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/bin/sublime

quit Terminal, then relaunch it
try to use sublime as a command, terminal still tells me "-bash: sublime: command not found"

echo $PATH gives the following result
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

what am I doing wrong here?

@mediter

This comment has been minimized.

Show comment
Hide comment
@mediter

mediter Nov 26, 2012

Please ignore the last comment.

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

then relaunch Terminal worked for me

mediter commented Nov 26, 2012

Please ignore the last comment.

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

then relaunch Terminal worked for me

@paulrossman

This comment has been minimized.

Show comment
Hide comment
@paulrossman

paulrossman Dec 5, 2012

or alias:

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

paulrossman commented Dec 5, 2012

or alias:

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

@mithun-daa

This comment has been minimized.

Show comment
Hide comment
@mithun-daa

mithun-daa commented Dec 15, 2012

Thanks!

@travi5567

This comment has been minimized.

Show comment
Hide comment
@travi5567

travi5567 Dec 29, 2012

Thanks a bunch i have been looking for somethng like this.

travi5567 commented Dec 29, 2012

Thanks a bunch i have been looking for somethng like this.

@nicolashery

This comment has been minimized.

Show comment
Hide comment
@nicolashery

nicolashery Jan 10, 2013

The only "issue" I see with putting the symlink in /usr/local versus ~/bin is that /usr/local is the directory used by Homebrew, and Sublime isn't installed through Homebrew.

This is more philosophical than a real issue, but I guess I like the idea of having Homebrew and everything installed through Homebrew sandboxed to /usr/local. That way if I just remove that directory, I can start from scratch again for everything Homebrew-related, but still have Sublime working from the command-line since I put the symlink in ~/bin.

For more info on Homebrew and /usr/local see "How do I uninstall Homebrew?" and "Why does Homebrew insist I install to /usr/local?" at https://github.com/mxcl/homebrew/wiki/FAQ

nicolashery commented Jan 10, 2013

The only "issue" I see with putting the symlink in /usr/local versus ~/bin is that /usr/local is the directory used by Homebrew, and Sublime isn't installed through Homebrew.

This is more philosophical than a real issue, but I guess I like the idea of having Homebrew and everything installed through Homebrew sandboxed to /usr/local. That way if I just remove that directory, I can start from scratch again for everything Homebrew-related, but still have Sublime working from the command-line since I put the symlink in ~/bin.

For more info on Homebrew and /usr/local see "How do I uninstall Homebrew?" and "Why does Homebrew insist I install to /usr/local?" at https://github.com/mxcl/homebrew/wiki/FAQ

@vishu17

This comment has been minimized.

Show comment
Hide comment
@vishu17

vishu17 Mar 10, 2013

I was trying to get this setup on a new machine, and guess what, the sublime documentation wraps the path to subl between quotes, that was causing my symlink to not function as desired.

Saw the unquoted path in this gist, followed it and voila!

vishu17 commented Mar 10, 2013

I was trying to get this setup on a new machine, and guess what, the sublime documentation wraps the path to subl between quotes, that was causing my symlink to not function as desired.

Saw the unquoted path in this gist, followed it and voila!

@MHMDhub

This comment has been minimized.

Show comment
Hide comment
@MHMDhub

MHMDhub Mar 18, 2013

Nice! I thought 'sublime' was better than 'subl' too.

MHMDhub commented Mar 18, 2013

Nice! I thought 'sublime' was better than 'subl' too.

@swadhinbharat

This comment has been minimized.

Show comment
Hide comment
@swadhinbharat

swadhinbharat commented May 19, 2013

Good One

@ryanmtaylor

This comment has been minimized.

Show comment
Hide comment
@ryanmtaylor

ryanmtaylor Jun 1, 2013

Homebrew is usually installed to /usr/local/Cellar. I like the alias approach the best, then you don't have a symlink lying around. Just add this to your ~/.profile (or ~/.bash_profile or ~/.bash_rc)

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

by typing this line:

echo "alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'" >> ~/.profile
source ~/.profile

ryanmtaylor commented Jun 1, 2013

Homebrew is usually installed to /usr/local/Cellar. I like the alias approach the best, then you don't have a symlink lying around. Just add this to your ~/.profile (or ~/.bash_profile or ~/.bash_rc)

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

by typing this line:

echo "alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'" >> ~/.profile
source ~/.profile

@ashwinmuthiah

This comment has been minimized.

Show comment
Hide comment
@ashwinmuthiah

ashwinmuthiah Jul 16, 2013

When I type this: ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
I get this error: ln: /usr/local/bin/sublime: Permission denied
Help?

ashwinmuthiah commented Jul 16, 2013

When I type this: ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
I get this error: ln: /usr/local/bin/sublime: Permission denied
Help?

@hellobrian

This comment has been minimized.

Show comment
Hide comment
@hellobrian

hellobrian Aug 2, 2013

@mediter & @paulrossman,

Thanks, the alias code and the sudo code worked for me.

hellobrian commented Aug 2, 2013

@mediter & @paulrossman,

Thanks, the alias code and the sudo code worked for me.

@07151129

This comment has been minimized.

Show comment
Hide comment
@07151129

07151129 Aug 10, 2013

You can also add "export EDITOR='sublime -w'" to your ~/.bash_profile to have ST as your default editor (for commenting git commits, using fc etc)

07151129 commented Aug 10, 2013

You can also add "export EDITOR='sublime -w'" to your ~/.bash_profile to have ST as your default editor (for commenting git commits, using fc etc)

@MarkBTomlinson

This comment has been minimized.

Show comment
Hide comment
@MarkBTomlinson

MarkBTomlinson Aug 21, 2013

Everything works great on Mac here but if you create a Bash profile you may find you loose Bash or the commands in your terminal.
I didn't need to do it and if you created an empty one and you are having problems delete and relaunch the terminal app.
I think it is due to a missing or incorrect path directive in the head of the profile file.

MarkBTomlinson commented Aug 21, 2013

Everything works great on Mac here but if you create a Bash profile you may find you loose Bash or the commands in your terminal.
I didn't need to do it and if you created an empty one and you are having problems delete and relaunch the terminal app.
I think it is due to a missing or incorrect path directive in the head of the profile file.

@monners

This comment has been minimized.

Show comment
Hide comment
@monners

monners Oct 13, 2013

Great worth, thanks a bunch.

monners commented Oct 13, 2013

Great worth, thanks a bunch.

@konamax123

This comment has been minimized.

Show comment
Hide comment
@konamax123

konamax123 Nov 5, 2013

I looked at so many websites and forums trying to get this to work and this is the only thing that helped. Thank you so much!

konamax123 commented Nov 5, 2013

I looked at so many websites and forums trying to get this to work and this is the only thing that helped. Thank you so much!

@waystilos

This comment has been minimized.

Show comment
Hide comment
@waystilos

waystilos Nov 16, 2013

Thank you so much for this! I spent a whole day trying to figure it out.

waystilos commented Nov 16, 2013

Thank you so much for this! I spent a whole day trying to figure it out.

@Coinhunter

This comment has been minimized.

Show comment
Hide comment
@Coinhunter

Coinhunter Nov 19, 2013

So helpful!

Coinhunter commented Nov 19, 2013

So helpful!

@swieder227

This comment has been minimized.

Show comment
Hide comment
@swieder227

swieder227 Nov 20, 2013

Greatly appreciated. Thank you sir!

swieder227 commented Nov 20, 2013

Greatly appreciated. Thank you sir!

@thm-design

This comment has been minimized.

Show comment
Hide comment
@thm-design

thm-design Dec 17, 2013

Woo just found this! Thanks!

thm-design commented Dec 17, 2013

Woo just found this! Thanks!

@bartonding

This comment has been minimized.

Show comment
Hide comment
@bartonding

bartonding commented Dec 29, 2013

nice

@dacook

This comment has been minimized.

Show comment
Hide comment
@dacook

dacook Jan 16, 2014

Easy to follow write up, thanks.

dacook commented Jan 16, 2014

Easy to follow write up, thanks.

@Sillson

This comment has been minimized.

Show comment
Hide comment
@Sillson

Sillson Jan 18, 2014

Best breakdown of this issue I've found yet, thanks!

Sillson commented Jan 18, 2014

Best breakdown of this issue I've found yet, thanks!

@siwka

This comment has been minimized.

Show comment
Hide comment
@siwka

siwka Jan 21, 2014

I can't find subl, open it, not sure what to look for. In /Applications/Sublime Text.app/Contents/SharedSupport/bin/ I have
drwxr-xr-x 2 ks admin 68 Jan 19 11:22 .
drwxr-xr-x 3 ks admin 102 Dec 16 21:25 ..

$ open subl
The file /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl does not exist.
$ subl --help
-bash: subl: command not found

Could it be as per ST (http://www.sublimetext.com/docs/2/osx_command_line.html) MacPorts are responsible for not allowing it work correctly?

siwka commented Jan 21, 2014

I can't find subl, open it, not sure what to look for. In /Applications/Sublime Text.app/Contents/SharedSupport/bin/ I have
drwxr-xr-x 2 ks admin 68 Jan 19 11:22 .
drwxr-xr-x 3 ks admin 102 Dec 16 21:25 ..

$ open subl
The file /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl does not exist.
$ subl --help
-bash: subl: command not found

Could it be as per ST (http://www.sublimetext.com/docs/2/osx_command_line.html) MacPorts are responsible for not allowing it work correctly?

@isaacalves

This comment has been minimized.

Show comment
Hide comment
@isaacalves

isaacalves Jan 22, 2014

I created a symlink on the /bin folder to Sublime Text 2.
Then I added the line "export PATH=
/bin" to .bashrc and runned it.

Now I cannot run any command (not even "ls") except for "sublime [filename]". I get always "-bash: [command name]: command not found"

Why is that? Sorry, I'm a noob on this topic.
thanks

isaacalves commented Jan 22, 2014

I created a symlink on the /bin folder to Sublime Text 2.
Then I added the line "export PATH=
/bin" to .bashrc and runned it.

Now I cannot run any command (not even "ls") except for "sublime [filename]". I get always "-bash: [command name]: command not found"

Why is that? Sorry, I'm a noob on this topic.
thanks

@lemonzi

This comment has been minimized.

Show comment
Hide comment
@lemonzi

lemonzi Mar 15, 2014

The line you provided replaces the whole PATH chain with only the sublime folder; what you want to do is append it to the folders it already has, which contain all the system utilities:

export PATH=$PATH:~/bin

lemonzi commented Mar 15, 2014

The line you provided replaces the whole PATH chain with only the sublime folder; what you want to do is append it to the folders it already has, which contain all the system utilities:

export PATH=$PATH:~/bin
@gwithian

This comment has been minimized.

Show comment
Hide comment
@gwithian

gwithian Mar 19, 2014

Removing the quotes around the path worked for me too, as per vishu17's comment above.

gwithian commented Mar 19, 2014

Removing the quotes around the path worked for me too, as per vishu17's comment above.

@samtalks

This comment has been minimized.

Show comment
Hide comment
@samtalks

samtalks Apr 19, 2014

The entire post is premised on this working okay: open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

But what if the above does not work at all?

samtalks commented Apr 19, 2014

The entire post is premised on this working okay: open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

But what if the above does not work at all?

@tarikguney

This comment has been minimized.

Show comment
Hide comment
@tarikguney

tarikguney Apr 28, 2014

Thanks! It worked like a charm.

tarikguney commented Apr 28, 2014

Thanks! It worked like a charm.

@aquilinux1

This comment has been minimized.

Show comment
Hide comment
@aquilinux1

aquilinux1 May 17, 2014

open ~/.bash_profile

This didn't work on my machine, it says that the file doesn't exist. But actually when i try to open a file with

"sublime 'filename' "

it works just fine for me!

Will I ever get in trouble if I don't do the other steps as you described?

It doesn't seem to me like i changed something in my PATH ...

Thanks anyway, best How-To I've found!

aquilinux1 commented May 17, 2014

open ~/.bash_profile

This didn't work on my machine, it says that the file doesn't exist. But actually when i try to open a file with

"sublime 'filename' "

it works just fine for me!

Will I ever get in trouble if I don't do the other steps as you described?

It doesn't seem to me like i changed something in my PATH ...

Thanks anyway, best How-To I've found!

@silverjerk

This comment has been minimized.

Show comment
Hide comment
@silverjerk

silverjerk May 24, 2014

@samtalks You can very simply dig into the Package Contents of Sublime Text and drag and drop the subl file into terminal, which will give you the correct path for your particular version of Sublime Text. In my case, I'm using Sublime Text 3, and thus it is missing the "2" in the application title.

I was using the old "subl" method and have been happy with that for years, but just picked up a new MBPr and was going through the tedium of porting over all my development settings, including my iTerm 2 themes, my .bash_profile settings, etc. For some reason subl was opening files just fine, but it was failing with Git and I had set up an alias to evoke it for nano commands as well. Followed these instructions and not only got it working again, but improved things as well (I wasn't a fan of "subl" either, as well as creating an unnecessary -- non-hidden -- bin folder in my home directory). My theory is I must have forgotten to set up the symlink in the rush to move everything over.

Thanks a bunch mate!

silverjerk commented May 24, 2014

@samtalks You can very simply dig into the Package Contents of Sublime Text and drag and drop the subl file into terminal, which will give you the correct path for your particular version of Sublime Text. In my case, I'm using Sublime Text 3, and thus it is missing the "2" in the application title.

I was using the old "subl" method and have been happy with that for years, but just picked up a new MBPr and was going through the tedium of porting over all my development settings, including my iTerm 2 themes, my .bash_profile settings, etc. For some reason subl was opening files just fine, but it was failing with Git and I had set up an alias to evoke it for nano commands as well. Followed these instructions and not only got it working again, but improved things as well (I wasn't a fan of "subl" either, as well as creating an unnecessary -- non-hidden -- bin folder in my home directory). My theory is I must have forgotten to set up the symlink in the rush to move everything over.

Thanks a bunch mate!

@alankhoury

This comment has been minimized.

Show comment
Hide comment
@alankhoury

alankhoury Jun 2, 2014

great stuff man! thanks

alankhoury commented Jun 2, 2014

great stuff man! thanks

@margaretmoser

This comment has been minimized.

Show comment
Hide comment
@margaretmoser

margaretmoser Jun 2, 2014

Done in about a minute, and it's much cleaner than the official instructions. Many thanks.

margaretmoser commented Jun 2, 2014

Done in about a minute, and it's much cleaner than the official instructions. Many thanks.

@lindsayo

This comment has been minimized.

Show comment
Hide comment
@lindsayo

lindsayo Jun 6, 2014

olivierlacan++

lindsayo commented Jun 6, 2014

olivierlacan++

@ferdousalamtaz

This comment has been minimized.

Show comment
Hide comment
@ferdousalamtaz

ferdousalamtaz Jun 12, 2014

Worked perfect! Thanks.

ferdousalamtaz commented Jun 12, 2014

Worked perfect! Thanks.

@cmocha

This comment has been minimized.

Show comment
Hide comment
@cmocha

cmocha Jul 3, 2014

Nice easy instructions! Many Thanks!

cmocha commented Jul 3, 2014

Nice easy instructions! Many Thanks!

@killerkiara

This comment has been minimized.

Show comment
Hide comment
@killerkiara

killerkiara Jul 8, 2014

Thanks for the very clear explanation, it helped a lot! 👍 🙇

killerkiara commented Jul 8, 2014

Thanks for the very clear explanation, it helped a lot! 👍 🙇

@TZ2016

This comment has been minimized.

Show comment
Hide comment
@TZ2016

TZ2016 Jul 27, 2014

Thanks a lot! But it seems on my mac $ subl <anyfilename> only opens the sublime without loading any file. Does anyone know what the issue is?

TZ2016 commented Jul 27, 2014

Thanks a lot! But it seems on my mac $ subl <anyfilename> only opens the sublime without loading any file. Does anyone know what the issue is?

@loganrice

This comment has been minimized.

Show comment
Hide comment
@loganrice

loganrice Jul 28, 2014

This was the fix I was looking for. Thanks I really appreciate the help.

loganrice commented Jul 28, 2014

This was the fix I was looking for. Thanks I really appreciate the help.

@kmjungersen

This comment has been minimized.

Show comment
Hide comment
@kmjungersen

kmjungersen commented Jul 31, 2014

👍

@luka22

This comment has been minimized.

Show comment
Hide comment
@luka22

luka22 Oct 7, 2014

thank you, really helpful, especially 'sublime foldername'.

luka22 commented Oct 7, 2014

thank you, really helpful, especially 'sublime foldername'.

@ltfschoen

This comment has been minimized.

Show comment
Hide comment
@ltfschoen

ltfschoen Oct 10, 2014

thanks, this was a great help!

ltfschoen commented Oct 10, 2014

thanks, this was a great help!

@tonygaetani

This comment has been minimized.

Show comment
Hide comment
@tonygaetani

tonygaetani Nov 6, 2014

Can someone explain to me why I can't use stdin for filename?

for example

sublime -n file.txt

works fine, but

echo file.txt | sublime -n

opens a new file with stdin as the contents. What am I doing wrong?

tonygaetani commented Nov 6, 2014

Can someone explain to me why I can't use stdin for filename?

for example

sublime -n file.txt

works fine, but

echo file.txt | sublime -n

opens a new file with stdin as the contents. What am I doing wrong?

@gusk

This comment has been minimized.

Show comment
Hide comment
@gusk

gusk Nov 13, 2014

As a result of following the instructions step-by-step, I was unable to use typical terminal commands. I am running Yosemite.

Here's what I did differently:

as @lemonzi mentioned, include $PATH:~/ and add this to your ~/.bash_profile

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

In addition, if you're using Sublime Text 3, this is the correct command for the symlink:

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

Note: I am setting the symlink alias to subl, not sublime, as we are referring to the Unix Executable File: .../Contents/SharedSupport/bin/subl

Although this was a great work around to avoid creating a ~/bin directory, the problems outmatch the solution. After spending the necessary time, I probably would've followed the Sublime Developers suggestion.

gusk commented Nov 13, 2014

As a result of following the instructions step-by-step, I was unable to use typical terminal commands. I am running Yosemite.

Here's what I did differently:

as @lemonzi mentioned, include $PATH:~/ and add this to your ~/.bash_profile

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

In addition, if you're using Sublime Text 3, this is the correct command for the symlink:

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

Note: I am setting the symlink alias to subl, not sublime, as we are referring to the Unix Executable File: .../Contents/SharedSupport/bin/subl

Although this was a great work around to avoid creating a ~/bin directory, the problems outmatch the solution. After spending the necessary time, I probably would've followed the Sublime Developers suggestion.

@tonygaetani

This comment has been minimized.

Show comment
Hide comment
@tonygaetani

tonygaetani Nov 19, 2014

@gusk are you sure the application name is "Sublime Text" (/Applications/Sublime\ Text.app) and not "Sublime Text 3" or something like this?

tonygaetani commented Nov 19, 2014

@gusk are you sure the application name is "Sublime Text" (/Applications/Sublime\ Text.app) and not "Sublime Text 3" or something like this?

@sineld

This comment has been minimized.

Show comment
Hide comment
@sineld

sineld Dec 2, 2014

worked for me. thanks.

sineld commented Dec 2, 2014

worked for me. thanks.

@Ducain

This comment has been minimized.

Show comment
Hide comment
@Ducain

Ducain Mar 6, 2015

Perfect - thank you.

Ducain commented Mar 6, 2015

Perfect - thank you.

@EuniceP

This comment has been minimized.

Show comment
Hide comment
@EuniceP

EuniceP Mar 9, 2015

Wonderful! As suggested, adding alias and export commands in .bash_profile works like a charm! Thanks!

EuniceP commented Mar 9, 2015

Wonderful! As suggested, adding alias and export commands in .bash_profile works like a charm! Thanks!

@EricMentele

This comment has been minimized.

Show comment
Hide comment
@EricMentele

EricMentele Mar 13, 2015

This solution worked great. I had to step through it carefully having just done a wipe/fresh install of Yosemite. No usr/local/bin or .bash_profile when you have a fresh setup. Gratitude to you good sir! ;)

EricMentele commented Mar 13, 2015

This solution worked great. I had to step through it carefully having just done a wipe/fresh install of Yosemite. No usr/local/bin or .bash_profile when you have a fresh setup. Gratitude to you good sir! ;)

@famartel

This comment has been minimized.

Show comment
Hide comment
@famartel

famartel Mar 16, 2015

It worked perfectly. Stay awesome!

famartel commented Mar 16, 2015

It worked perfectly. Stay awesome!

@fabritw

This comment has been minimized.

Show comment
Hide comment
@fabritw

fabritw Apr 4, 2015

The bash_profile edit caused me to loose all bash commands!
i.e. export PATH="/usr/local/bin:(...)"

Had to fix it using this...
http://stackoverflow.com/questions/12396161/how-to-fix-bash-profile-when-terminal-wont-work

"Pressing Cmd-Shift-. in the file open dialog of TextEdit (or a real editor) should display dot-files in the dialog."

fabritw commented Apr 4, 2015

The bash_profile edit caused me to loose all bash commands!
i.e. export PATH="/usr/local/bin:(...)"

Had to fix it using this...
http://stackoverflow.com/questions/12396161/how-to-fix-bash-profile-when-terminal-wont-work

"Pressing Cmd-Shift-. in the file open dialog of TextEdit (or a real editor) should display dot-files in the dialog."

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented Apr 13, 2015

Thankyou @gusk

@RedSoxFan22

This comment has been minimized.

Show comment
Hide comment
@RedSoxFan22

RedSoxFan22 Apr 15, 2015

Perfection! Thank you!

RedSoxFan22 commented Apr 15, 2015

Perfection! Thank you!

@iamazik

This comment has been minimized.

Show comment
Hide comment
@iamazik

iamazik May 8, 2015

A perfect explanation of everything. I didn't want to create a bin directory at my home directory as all the other binaries place it /usr/local/bin/. 😄

iamazik commented May 8, 2015

A perfect explanation of everything. I didn't want to create a bin directory at my home directory as all the other binaries place it /usr/local/bin/. 😄

@kevglynn

This comment has been minimized.

Show comment
Hide comment
@kevglynn

kevglynn Aug 9, 2015

Great lesson.

kevglynn commented Aug 9, 2015

Great lesson.

@walter211

This comment has been minimized.

Show comment
Hide comment
@walter211

walter211 Aug 12, 2015

where can i find all command for subl such like --command with what kinde of args

walter211 commented Aug 12, 2015

where can i find all command for subl such like --command with what kinde of args

@annrayc

This comment has been minimized.

Show comment
Hide comment
@annrayc

annrayc Aug 16, 2015

thanks worked great!

annrayc commented Aug 16, 2015

thanks worked great!

@hankcouture

This comment has been minimized.

Show comment
Hide comment
@hankcouture

hankcouture Sep 14, 2015

Thank you! After much searching online, this one worked great for me.

hankcouture commented Sep 14, 2015

Thank you! After much searching online, this one worked great for me.

@saposki

This comment has been minimized.

Show comment
Hide comment
@saposki

saposki Oct 10, 2015

This was very straight forward
Thank you.

saposki commented Oct 10, 2015

This was very straight forward
Thank you.

@Atlas7

This comment has been minimized.

Show comment
Hide comment
@Atlas7

Atlas7 Nov 4, 2015

Awesome. Worked for me. I like this very much :)

Atlas7 commented Nov 4, 2015

Awesome. Worked for me. I like this very much :)

@Faline10

This comment has been minimized.

Show comment
Hide comment
@Faline10

Faline10 Jan 7, 2016

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl worked for me on my new El Capitan OSX. Note: this allows me to use "subl" rather than "sublime" as a command.

Faline10 commented Jan 7, 2016

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl worked for me on my new El Capitan OSX. Note: this allows me to use "subl" rather than "sublime" as a command.

@arzmir

This comment has been minimized.

Show comment
Hide comment
@arzmir

arzmir Apr 12, 2016

As some have mentioned you might lose access to the normal terminal commands when doing it like this.
This is because you overwrite the standard PATH-variable with the one you have in your .bash_profile when you source it.

The way to avoid it is to extend the PATH-variable instead.

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

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

This way you append '/usr/local/bin' to the already existing path. :)

arzmir commented Apr 12, 2016

As some have mentioned you might lose access to the normal terminal commands when doing it like this.
This is because you overwrite the standard PATH-variable with the one you have in your .bash_profile when you source it.

The way to avoid it is to extend the PATH-variable instead.

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

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

This way you append '/usr/local/bin' to the already existing path. :)

@jnuc093

This comment has been minimized.

Show comment
Hide comment
@jnuc093

jnuc093 May 9, 2016

OSX EICaption with Sublime Text 3

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

➜ ~ vi ~/.bash_profile

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

➜ ~ source ~/.bash_profile
➜ ~ subl

it works fine!

jnuc093 commented May 9, 2016

OSX EICaption with Sublime Text 3

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

➜ ~ vi ~/.bash_profile

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

➜ ~ source ~/.bash_profile
➜ ~ subl

it works fine!

@adamwlev

This comment has been minimized.

Show comment
Hide comment
@adamwlev

adamwlev May 10, 2016

Your the best 💯

adamwlev commented May 10, 2016

Your the best 💯

@iMagesh

This comment has been minimized.

Show comment
Hide comment
@iMagesh

iMagesh Jun 28, 2016

Cool. Thanks.

iMagesh commented Jun 28, 2016

Cool. Thanks.

@pilgrim2go

This comment has been minimized.

Show comment
Hide comment
@pilgrim2go

pilgrim2go Apr 15, 2017

Cools. Thanks

pilgrim2go commented Apr 15, 2017

Cools. Thanks

@desmond132518

This comment has been minimized.

Show comment
Hide comment
@desmond132518

desmond132518 Aug 3, 2017

@jnuc093 It works in MacOSX Sierra too, thanks!

desmond132518 commented Aug 3, 2017

@jnuc093 It works in MacOSX Sierra too, thanks!

@siwka

This comment has been minimized.

Show comment
Hide comment
@siwka

siwka Mar 21, 2018

In new macOS High Sierra it did not work. I had to use "sudo" command that I do not like to use on Mac.
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

siwka commented Mar 21, 2018

In new macOS High Sierra it did not work. I had to use "sudo" command that I do not like to use on Mac.
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

@KASEM007

This comment has been minimized.

Show comment
Hide comment
@KASEM007

KASEM007 Mar 27, 2018

Awsome question also
For Sublime Text 3 :
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

KASEM007 commented Mar 27, 2018

Awsome question also
For Sublime Text 3 :
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

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