Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sublime Terminal Setup

Setup Terminal for Sublime Shorcut "subl":

Open terminal and type:

1. Create a directory at ~/bin:

mkdir ~/bin

2. Copy sublime executable to your ~/bin directory:

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

BASH (Mac OS default) - use these instructions unless you know you have zsh

3a. If using bash (Mac OS default) add line to ~/.bash_profile file:

echo 'export PATH=$PATH:$HOME/bin' >> ~/.bash_profile

4a. Set sublime as your default editor

echo "export EDITOR='subl' -w">> ~/.bash_profile

or

ZSH - if you don't know what zsh is you don't have it

3b. If using zsh add line to ~/.zshrc file:

echo 'export PATH=$PATH:$HOME/bin' >> ~/.zshrc

4b. Set sublime as your default editor

echo "export EDITOR='subl' -w" >> ~/.zshrc

5. Restart terminal and type:

subl .

Sublime should open up in the current directory.

6. Check unix commands:

ls

You should get a directory listing.


Windows

Put the C:\Program Files\Sublime Text 2 in your PATH.

Create a subl.bat file and save it in the directory: C:\Program Files\Sublime Text 2

Inside the file put: start sublime_text.exe %*


If you have questions email me:

barnes7td@gmail.com

@kjprince

This comment has been minimized.

Copy link

commented Jul 10, 2015

Just gave this a shot but not liking the -w flag
/Users/administrator/.zshrc:export:86: not valid in this context: -w

I removed the -w flag and all is well. Thanks.

@imoby

This comment has been minimized.

Copy link

commented Sep 20, 2015

I'd update this (which is very useful) to include the application name change for sublime text three which doesn't include the number at the end of the file name.

@kenju254

This comment has been minimized.

Copy link

commented Dec 20, 2015

Also got the same /Users/username/.zshrc:export:108: not valid in this context: -w kindly update

@bergerd1

This comment has been minimized.

Copy link

commented Jan 27, 2016

Thanks, this helped a lot!
Had to open the .zshrc file then remove the -w flag, save, restart terminal.

@herbiewalker

This comment has been minimized.

Copy link

commented Mar 20, 2016

bash file

before i learned to change the filename with Git i set the default app to sublime.... how do i change it back to the unknown file like it normally is?

@AakashL

This comment has been minimized.

Copy link

commented Apr 20, 2016

Thanks for the guide!
Got the subl command working on Babun shell for Windows.

@cbgabe

This comment has been minimized.

Copy link

commented Sep 6, 2016

Thanks man! So helpful!

@nefa

This comment has been minimized.

Copy link

commented Oct 3, 2016

10x!!!

@Johnsalzarulo

This comment has been minimized.

Copy link

commented Oct 29, 2016

Thanks so much. Super helpful.

@DannyFeliz

This comment has been minimized.

Copy link

commented Jan 9, 2017

Note:

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

The lastest versions of Sublime Text do not have the version number, so you should modify this line to

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

Thank you very much for this guide 🚀

@ConfusedVorlon

This comment has been minimized.

Copy link

commented Sep 25, 2018

the -w should be within the apostrophe's

echo "export EDITOR='subl -w'">> ~/.bash_profile

(assuming you want the shell to wait while you edit)

@CHENzeman

This comment has been minimized.

Copy link

commented Jul 17, 2019

Note:

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

The lastest versions of Sublime Text do not have the version number, so you should modify this line to

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

Thank you very much for this guide 🚀

Thanks for the tip!

@RafaelPuerta

This comment has been minimized.

Copy link

commented Aug 15, 2019

Excellent thanks for sharing 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.