Sublime Text 2? The editor that developers, developers, developers like to use. At the very least, Sublime is a common text editor for the everyday programmer. How can you use Sublime on your terminal? If you’re any programmer, you’re maneuvering through the terminal left and right, all day everyday, so you need to have an easy way to use sublime from the terminal!
By default, for Mac OS X, you don’t have Sublime binded to a command on the terminal! Let’s do show you how to do that.
You can install the stable version of Sublime on their website.
How to Set-up
We want to be able to type in:
and open files.
Open a new terminal. First, we will bind the newly installed Sublime 2 (you can also do this for Sublime 3) as the subl command. We’re using a symbolic link from the binary within the Application to what we will make as globally accessible.
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
OR you can bind sublime to a sublime command for clarity instead of the abbreviation.
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
The symbolic link will create an accessible
subl command to open sublime and use it to open files or folders.
We will open
~/.bash_profile with a text editor and make sure that this new sublime command will be ready whenever we open the terminal.
open -a TextEdit ~/.bash_profile
.bash_profile, we will set the PATH variable to look inside the /usr/local/bin folder where we created the sublime link. Type the following if it is not in your
By exporting the path,
~/.bash_profile will refresh and export the folder for accessible binary commands whenever we open a new terminal.
Now save and exit. The first time we do this, we will not have access to the sublime command immediately. We first need to source, which means to reload the
~/.bash_profile in order to have access to our sublime command!
How to Use
Open a terminal and use any of the variations of the command:
Open a file
Open a folder
Open the current directory
Enjoy your new sublime command! Makes things much more convenient if you enjoy using sublime!