Sublime text is a proprietary cross platform source code editor with a python application programming interface. It supports many programming languages. It contains 22 different themes with the option to download additional themes. In this tutorial, we will install Sublime Text on MacOS. How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) You need a Build System for Sublime Text to invoke the compiler-command on your source file. I think Sublime Text comes with the basic system for C and C++ which works all right, but you might want to tailor your own or just find one on the interwebs.
Installing Python and Sublime Text 2 on a Windows 7 or Mac OS X Computer Python 2.7.x, the development language for this course, may already be installed in some form on your laptop. Likewise, you may already have Sublime Text 2. The instructions here are general guidelines for getting the packages onto your Windows PC or Mac OS X computer. You can also set both environments up for Linux but since I don’t have a Linux machine right now, you will have to work that out on your own. Installing Python On a Windows PC: First, check to see if you already have Python. Open up a command window.
On Windows 7, click the Start button and type cmd in the text box (for other versions of Windows, google “open command prompt windows X”). A window with a command prompt will open. In the command prompt window, type python. If you get a message saying that Python is not recognized, then you will need to install it on your computer. If Python does start, check the version. If it is 3.x, you will still need to download version 2.7.x.
Also, make sure that ‘Anaconda’ is mentioned somewhere in the starting info. If it is not, you should continue with the installation instructions.
Type quit ( ) at the prompt and Python will exit. If you do not have version 2.7.x of Python,. Anaconda includes a Python interpreter and many other helpful tools for Python programming. Click the Python 2.7 Windows 64-bit graphical installer and follow the instructions.
On a Mac (OS X): First, check to see if you already have Python. Open up Terminal. The easiest way is to open Spotlight with ⌘ + space and type terminal in the text field. Double click on Terminal under applications. In Terminal, type python.
If you get a message saying that Python is not recognized, then you will need to install it on your computer. If Python does start, check the version.
If it is 3.x, you will still need to download version 2.7.x. Also, make sure that ‘Anaconda’ is mentioned somewhere in the starting info. If it is not, you should continue with the installation instructions. Type quit( ) at the prompt and Python will exit. If you do not have version 2.7.x of Python,. Anaconda includes a Python interpreter and many other helpful tools for Python programming.
Click the Python 2.7 Mac OS X 64-bit graphical installer and follow the instructions. Installing Sublime Text 2 Sublime Text 2 is available for both Windows PCs and Macs running OS X. Click here to get Windows and OS X installers.
Testing your installation Start Sublime Text 2. Enter print ‘hello python’ in the text window. Save the file somewhere with a name like HelloPython.py It is very important to save the file with a. Py extension before the next step. On Windows, type ctrl-B. On the Mac, type ⌘ + B In both cases, your program should run and hello python should be printed at the bottom of the frame.
You can exit Sublime—all is well. If nothing happened, make sure to save your file with a. Py extension and try again.
Launch Sublime Text 2 from the Mac OS X Terminal Sublime Text 2 ships with a CLI called subl (why not 'sublime', go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk.
If this following line opens Sublime Text for you, then bingo, you're ready. Open /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl You can find more (official) details about subl here: Installation The official documentation I linked to above recommends creating a /bin folder (in your home directory).
That's weird, I don't recall ever being asked to do that on OS X since most people install binaries within /usr/local/bin which – if you're a developer – is likely to already have tons of other binaries. So contrary to the Sublime team recommendation, we're not going to create a bin folder in your home directory: ln -s /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime This will simply create a called sublime (remember, we like names that don't suck to type 500 times a day) between the subl binary stashed in the Sublime application package, and a folder where your system usually looks for binaries to execute (launch). Think of it as a wormhole of awesome.
Now let's do a check to see if everything will run smoothly. Enter this: open /.bashprofile. You should see at the top of the file a line that starts with: export PATH= This contains all the directories that will be looked into for executable binaries when you type a command in Terminal. Since we create a symlink to subl called sublime in the /usr/local/bin directory let's check if this directory is listed on that same line. If it is, perfect. Let's keep going.
If not, simply add it like this and save the file: export PATH=/usr/local/bin:(.) Note: The '(.)' in this example represents other folders that would be listed on the same line and separated by a colon. If you had to add /usr/local/bin to your PATH, run the following command before continuing: source /.bashprofile This will reload your.bashprofile with the newly added directory. Testing Open a Terminal window and run: sublime filename (replace 'filename' by an actual file name) or sublime foldername (replace 'foldername' by an actual folder name) or even sublime. (to open the entire current directory) Conclusion Now you don't need to get out of Terminal to simply open a file or a folder, you didn't have to add an 'alias' or yet another bin directory to your.bashprofile which you would have needed with the official instructions given by the Sublime team. Have fun, Sublime is a great editor showing a lot of promise.
The only 'issue' I see with putting the symlink in /usr/local versus /bin is that /usr/local is the directory used by Homebrew, and Sublime isn't installed through Homebrew. This is more philosophical than a real issue, but I guess I like the idea of having Homebrew and everything installed through Homebrew sandboxed to /usr/local. That way if I just remove that directory, I can start from scratch again for everything Homebrew-related, but still have Sublime working from the command-line since I put the symlink in /bin.
For more info on Homebrew and /usr/local see 'How do I uninstall Homebrew?' And 'Why does Homebrew insist I install to /usr/local?' You can very simply dig into the Package Contents of Sublime Text and drag and drop the subl file into terminal, which will give you the correct path for your particular version of Sublime Text. In my case, I'm using Sublime Text 3, and thus it is missing the '2' in the application title. I was using the old 'subl' method and have been happy with that for years, but just picked up a new MBPr and was going through the tedium of porting over all my development settings, including my iTerm 2 themes, my.bashprofile settings, etc.
For some reason subl was opening files just fine, but it was failing with Git and I had set up an alias to evoke it for nano commands as well. Followed these instructions and not only got it working again, but improved things as well (I wasn't a fan of 'subl' either, as well as creating an unnecessary - non-hidden - bin folder in my home directory). My theory is I must have forgotten to set up the symlink in the rush to move everything over. Thanks a bunch mate! As a result of following the instructions step-by-step, I was unable to use typical terminal commands. I am running Yosemite.
Here's what I did differently: as mentioned, include $PATH:/ and add this to your /.bashprofile export PATH=$PATH:/usr/local/bin In addition, if you're using Sublime Text 3, this is the correct command for the symlink: ln -s /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl Note: I am setting the symlink alias to subl, not sublime, as we are referring to the Unix Executable File./Contents/SharedSupport/bin/subl Although this was a great work around to avoid creating a /bin directory, the problems outmatch the solution. After spending the necessary time, I probably would've followed the Sublime Developers.