Set up Sublime Text in Mac/Apple; Fix "zsh: command not found: subl" Error

Sublime Text is a popular cross-platform source code editor. You can download it from here and install it.

As a developer, you may have tried to edit or create a file in Sublime Text or simply launch it in the lines of Nano or Vim by typing the following command into the terminal

				
					subl 
				
			

and most likely have encountered the following an error message: zsh: command not found: subl.

strava

This is because some soft link commands still need to be executed. But before that, remove any existing /subl directory inside /usr/local/bin

				
				sudo su -
				rm /usr/local/bin/subl
				
			

Next go to /Applications directory and check which version of Sublime Text you installed.

				
				cd /Applications
				ls
				
			

If it is Sublime Text version 3, do

				
				ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
				exit;
				
			

else if it is version 2, do

				
				ln -sv "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
				exit;
				
			

Close the terminal and start it again. Type

				
					subl 
				
			

into the terminal and press ENTER. Sublime Text will now be launched.