I find myself relying more and more on Sublime Text for my coding needs and as such I’m always on the lookout for a shortcut for my everyday Mac needs (as you guys know from my AppleScript shortcuts a while back).
Here’s a quick way to launch your files/folders from Terminal in Sublime.
Assuming you’ve installed Sublime Text 3 correctly on your Mac, this following command should open the app from Terminal :
$ open /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
If that works, you’re good to go.
Step 1 : Create a symlink called sublime
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
Step 2 : Check that your system profile can find the symlink you just created.
$ open ~/.bash_profile
Step 3 : Add both these lines in if they’re not already in here & then save the file :
alias sublime="open -a /Applications/Sublime\ Text.app" export PATH=/usr/local/bin:$PATH
Step 4 : Reload your bash_profile :
$ source ~/.bash_profile
Done ! You can now navigate to any of your code/script folders in Terminal and open them in Sublime with the following commands :
sublime . sublime trial.js sublime foldername