How to open files with Sublime Text from the MacOS terminal
How to open files with Sublime Text from the MacOS terminal
This tutorial shows you how to set up the subl command in the MacOS terminal to open files and folders with Sublime Text. This may be useful if you prefer features of Sublime Text that are lacking in vim or nano.
-
Confirm Sublime Text is installed in
/Applications/Sublime Text.app. -
Locate Sublime Text’s command-line launcher at:
/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl
- Create a symbolic link named
sublin/usr/local/bin.sudomay be necessary:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
- Test that Terminal can find the command:
which subl
- Check that Sublime Text responds correctly:
subl --version
- Usage:
# Open a file from Terminal
subl file.txt
# Open the current folder in Sublime Text
subl .