Tuesday, October 09, 2012

Install Sublime Text 2 on Ubuntu 12.04

TL;DR Version

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

Need changelog? Here.

Adventurous Version

  1. Download Sublime Text 2 http://www.sublimetext.com/nightly
  2. Extract it to your user directory (or wherever you like).
  3. Double click sublime_text.

Even More Adventurous Version

  1. Complete adventurous version step1 and step 2.
  2. Run the console:
./sublime_text

sudo ln -s ~/Apps/Sublime\ Text\ 2/sublime_text /usr/local/bin/subl

Bonus

Install Sublime Package Control. Press Ctrl + ` then enter the following code and press Enter.

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'

Bonus 2

Create launcher in Unity. Run sudo subl ~/.local/share/applications/sublime.desktop and save the following code.

#!/usr/bin/env xdg-open

[Desktop Entry]
Name=Sublime Text 2
GenericName=Text Editor
Comment=Sophisticated text editor for code, html and prose
Exec=/usr/bin/sublime-text-2 %F
Terminal=false
Type=Application
MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff;x-directory/normal;inode/directory;
Icon=sublime-text-2
Categories=TextEditor;Development;Utility;
Name[en_US]=Sublime Text 2
X-Ayatana-Desktop-Shortcuts=NewWindow;

[NewWindow Shortcut Group]
Name=Open a New Window
Exec=/usr/bin/sublime-text-2 --new-window
TargetEnvironment=Unity
[Desktop Entry]
Name=Sublime Text 2
GenericName=Text Editor
Comment=Edit text files
Keywords=Plaintext;Write;
Exec=subl
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=/home/jewei/Apps/Sublime Text 2/Icon/256x256/sublime_text.php
Categories=GNOME;GTK;Utility;TextEditor;
Actions=Window;Document;
X-Ayatana-Desktop-Shortcuts=NewWindow

[Desktop Action Window]
Name=Open a New Window
Exec=subl -n
OnlyShowIn=Unity;

[Desktop Action Document]
Name=Open a New Document
Exec=subl -n
OnlyShowIn=Unity;

Bonus 3



sudo sublime /usr/share/applications/defaults.list
~/.local/share/applications/mimeapps.list


[Added Associations]
text/plain=ubuntu-software-center.desktop;shotwell.desktop;sublimetext.desktop;
text/x-chdr=shotwell-viewer.desktop;

[Default Applications]
text/plain=sublimetext.desktop
text/x-c++src=sublimetext.desktop
text/x-chdr=sublimetext.desktop

No comments: