It is quite simple to do this. Just follow the steps.
1. Open the Terminal and run ln -s “/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl ” /usr/local/bin/sublime
This will create a symlink called sublime between the subl binary stashed in Sublime application package and the folder where your system usually looks for binaries to execute(launch).
2. If the above command gives you an error saying ln: /usr/local/bin/sublime: Permission denied. execute the command again by using sudo
Quick tip here: Just run sudo !! instead of copying and pasting the entire path again. This will execute the previous command.
3. Now run open ~/.bash_profile and add /usr/local/bin if you don’t have it in the $PATH.
4. Now execute source ~/.bash_profile if you have made any changes to the file. This command reloads your .bash_profile
5. Now run sublime command in the terminal to launch the application.
run sublime . to open an entire directory with the sublime text
run sublime folder name or file name to open a specific folder or file