Friday, 3 May 2013

Install Sublime Text 2

Hi
today I am going to show how to install sublime text 2 in your computer. Yes, sublime text 2 is one of the modern and light web text editor. Many programmer and developer are using sublime text 2 now and many of are starting....
However, let's start the installation process of sublime text2 in various Operating System such Windows, Linux and Ubuntu. Let's start journey...


Install in Ubuntu

Method One

Open a terminal with Ctrl+Alt+T and type:
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update

Optional: remove any installed Sublime Text packages:
sudo apt-get --purge remove sublime-text*

Now to install Sublime Text, type the following:
sudo apt-get install sublime-text






Method Two

First you need to download Sublime for 32bit or 64bit system.

Once you download the file locate it and extract it. I assume that the downloaded file is located in /home/DownloadsOpen a terminal with Ctrl+Alt+T and type 
cd ~/Downloads (With this command we change the default directory "/" to "/Downloads") and then type

For 32bit version
tar -jxvf Sublime\ Text\ 2\ 2.0.1.tar.bz2 to extract the file.

For 64bit version
tar -jxvf Sublime\ Text\ 2\ 2.0.1\ x64.tar.bz2 to extract the file.


Once you extract the file type the following commands invidually:
sudo mv Sublime\ Text\ 2 sublime
sudo mv sublime /opt/
cd /opt
sudo chown -R root:root sublime
sudo chmod -R +r sublime

Now we need to create a Sublime Text executable in your path. To do this execute the following commands:

sudo touch /usr/bin/sublime_text
sudo chmod 775 /usr/bin/sublime_text


Now press Alt+F2 and type:
gksu gedit /usr/bin/sublime_text


and copy paste the below code:

#!/bin/sh
#export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export SUBLIME_HOME="/opt/sublime"

$SUBLIME_HOME/sublime_text "$*"

and save the file.


Next , to create a menu icon press Alt+F2 and type:
gksu gedit /usr/share/applications/sublime.desktop


and copy paste the below code:

[Desktop Entry]
Encoding=UTF-8
Name=Sublime Text
Comment=
Sublime Text 2
Exec=sublime_text
Icon=/opt/sublime/Icon/256x256/sublime_text.png
Terminal=false
Type=Application
Categories=GNOME;GTK;Utility;TextEditor;
StartupNotify=true


and finally save the file.

Finally to launch Sublime Text for the first time
Menu  Accessories  Sublime Text








Install in Linux:

Oky, now lets go to see the installation process in Linux OS. Ofcourse it is different process then ubuntu. Lets go...

Method One

Download the tarfile that suits you best and extract it. Here’s the command to extract tar.bz2 files:

1.tar xf Sublime\ Text\ 2.0.1\ x64.tar.bz2
You’ll notice that I got the 64-bit version. The reason is that it’s lightning fast. So, go for that if you can!

Method Two

You’ll get a “Sublime Text 2″ folder after extraction. This folder contains all the files that Sublime Text will need. So we have to move that folder somewhere more appropriate. Like the “/opt/” folder :

1.sudo mv Sublime\ Text\ 2 /opt/

Method Three

At some point you’d want to be able to call Sublime Text from the Terminal by just typing “sublime”. To do that, we’ll just create a symbolic link in “/usr/bin” like thus:

1.sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime


Method Four

Now that our files are at the right place, we need to create a launcher in Unity. To do this, we’re going to create a .desktop file in “/usr/share/applications”:

1.sudo sublime /usr/share/applications/sublime.desktop
And paste the following content:

01.[Desktop Entry]
02.Version=1.0
03.Name=Sublime Text 2
04.# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
05.# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
06.GenericName=Text Editor
07. 
08.Exec=sublime
09.Terminal=false
10.Icon=/opt/Sublime Text 2/Icon/48x48/sublime_text.png
11.Type=Application
12.Categories=TextEditor;IDE;Development
13.X-Ayatana-Desktop-Shortcuts=NewWindow
14. 
15.[NewWindow Shortcut Group]
16.Name=New Window
17.Exec=sublime -n
18.TargetEnvironment=Unity
As you can see, these lines are quite straightforward. Go ahead and experiment a bit with them.

Method Five

Now you would probably want to open all text files with Sublime Text 2. The easiest way to do that is to open up the file associations list:

1.sudo sublime /usr/share/applications/defaults.list
And replace all occurrences of gedit.desktop with sublime.desktop.

That's all for today. Feel free to contact with me to know any more about this issue. 
----------------------------------------------------- 
Talk Soon. 
Take Part Idea Team 

No comments:

Post a Comment