Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Last active March 28, 2024 17:59
Show Gist options
  • Save barnes7td/3804534 to your computer and use it in GitHub Desktop.
Save barnes7td/3804534 to your computer and use it in GitHub Desktop.
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.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 %*

@gabeborges
Copy link

Thanks man! So helpful!

@nefa
Copy link

nefa commented Oct 3, 2016

10x!!!

@Johnsalzarulo
Copy link

Thanks so much. Super helpful.

@DannyFeliz
Copy link

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
Copy link

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
Copy link

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!

@0x14Rp
Copy link

0x14Rp commented Aug 15, 2019

Excellent thanks for sharing 😊

@barnes7td
Copy link
Author

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!

Much Appreciated!

@barnes7td
Copy link
Author

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)

Thanks for the fix. Updated.

@D-Shergill
Copy link

Thank You

@Sheldenshi
Copy link

Don't forget to run source ~/.bash_profile after make changes to .bash_profile

@lukyans
Copy link

lukyans commented Nov 13, 2020

Thank you!!!

@sarahlunette
Copy link

Hi, it is great and easy but at the end it says "zsh: command not found: subl".
What should I do ? Thanks

@rgammino-epower
Copy link

thank you so much for the guide!

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