Surprisingly, one of my more popular articles last year was a short, very basic walk-thru detailing how to install Sublime Text 2 on Ubuntu-based machines (this includes Linux Mint).
Now that beta version of Sublime Text 3 has become more and more stable, I am going to post an updated walk-thru for the new version, since the commands differ in a few places, and I have learned a few things in the intervening months (slowly – baby steps here . . .).
Image by Nick Ares / Some Rights Reserved
As noted in the previous article regarding Sublime Text 2, Sublime Text 3 is not currently part of the Synaptic Package Management system on Linux Mint (or Ubuntu). Therefore, there is no magical apt-get install command as you might use to install other software on your Linux system, so we have to do a little more work.
You can manually download the latest build (Build 3047 as of this writing) of Sublime Text 3 for either 32 bit or 64 bit architectures from the Sublime Text 3 page, unpack, and locate in the directory of your choice. This can be done manually, or from the terminal as described below.
If you are less-than-familiar with the Bash command line, be sure to visit my previous posts. While these were originally part of a series on using Git for Windows developers, the basic Bash commands required for this install are clearly explained:
This method is described on the Sublime Text Site/Support/Linux/Installation page. Simply open a terminal in the directory you use for applications, and enter the following command (use the appropriate version fro your machine):
Note: As of this writing, Sublime Text 3 build 3059 is the most recent beta release. If the release is updated, the URL's in the links below will change, and you will need to copy the updated URL from the Sublime Text site.
Download the Linux 32-Bit Version of Sublime Text 3:
$ wget http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x32.tar.bz2
Download the Linux 64-Bit Version of Sublime Text 3:
Extract the "Sublime Text 2.0.1.tar.bz2" file (this will be sublime_text_3_build_3059_x64.tar.bz2 for the 64 bit version):
Extract the Sublime Text .tar file:
tar vxjf "sublime_text_3_build_3059_x32.tar.bz2"
It is common to locate 3rd-party applications in the /opt/ directory, so move the extracted files there:
Move Extracted Sublime Text 3 Files to Opt Directory:
$ sudo mv Sublime_text_3 /opt/
Now that we have located the files in an appropriate directory, let's make a Bash script which will allow us to execute Sublime Text 3 with a simple command. To do this, we are going to stay in our terminal, and perform a very simple edit using vi.
First, change to the /opt/sublime_text_3/ directory:
Move into the Sublime Text 3 directory in /opt/
$ cd /opt/sublime_text_3
Next, open vi into a new file named subl3 (this is a convenient shortcut to use from the terminal):
Open Vi Into New File suble3:
$ vi subl3
If you are new to editing text from the terminal, don't panic, this is not too bad, and also is something you should learn how to do, if only for occasions like this). There are a few key things to know about vi:
- vi opens in Command Mode – you cant type any text yet. To enter Insert Mode, type the asterisk character followed by capital I ( *I ). This will allow text entry on the current line.
- To return to command mode, hit the <escape> key.
- to save the current file, from command mode, type the Colon character, followed by lower-case w and lower case q, then hit enter ( :wq <enter> ).
Now, you should be looking at a blank screen in vi. Enter Insert Mode ( *I ) and type the following two lines:
Type Bash Script Into Vi that Creates an Alias for Sublime Text 3
exec /opt/sublime_text/sublime_text "$@"
Then exit Insert Mode ( <esc> ) and save the file ( :qw ).
Congratulations. You have now created a Bash script. Now, let's make sure the access permissions on our script are appropriate. Set the access permissions as follows:
Set Access Permissions on new Bash Script:
$ sudo chmod 755 subl3
This allows anyone to read or execute the script, but only the owner can write to it.
Now, we need to move the script file to the /usr/bin/ directory, so that it can properly respond to Bash commands:
Move Script to Proper Directory:
$ sudo mv subl3 /usr/bin/
Now, having done all that, let's look at the easier way to accomplish all of the above steps.
This is what I consider the better way to do this.
Canonical, the company which supports Ubuntu, has created the Launchpad.net site which, among other things, hosts a repository for Personal Package Archives (PPA's). Here, individuals and teams can upload their own software and installation packages, and it is possible to find deployment packages for software that is not included in the Ubuntu or Linux Mint Synaptic Package Manager for your specific distribution. It is also possible to add the PPA to your Synaptic catalog, so that you can then run apt-get install, apt-get update and the like to keep your package up to date.
Or, at least as up to date as the package maintainer at Launchpad keeps theirs.
The WebUpd8team at Launchpad has created (among other things) a PPA for Sublime Text 3 (currently still in beta as of this writing). To add Sublime Text 3 to your Synaptic catalog, and install according to the install script published with the PPA, follow these steps:
Add the Sublime Text 3 Repository to your Synaptic Package Manager:
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
Install Sublime Text:
sudo apt-get install sublime-text-installer
Next, check the usr/bin directory. You should see a file named subl. This is the alias you can use to invoke Sublime Text 3 from the command line, just like we created manually above.
There you have it. You can now use Sublime Text 3 from you command line. Also, you should see it available in your GUI in the applications menu.
This has been a long post about a relatively simple operation. My goal has been to explain the concepts as fully as possible, under the assumption that there are those out there, like myself, new enough to Linux to need the extra handholding.
In addition, if you first followed the manual instructions, you may have learned a few more of the basics in working with Linux (an vi).
Thanks for reading!
Other Topics of Interest
John on Google CodeProject