How to create a shortcut in terminal for Mac for Sublime Text

Copy and paste the code below in ~/.bash_profile. You can edit the file by typing nano ~/.bash_profile

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

For Sublime Text 2 it is

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

Restart terminal for changes to reflect

Now you can type (without the $ of course)

$ subl ~/Downloads/some_file.txt

Happy coding! – Found a mistake or a typo? Please submit a PR to my GitHub-repo.

Like this post? Follow @adriaandotcom on X