Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2012 06:56
Show Gist options
  • Save anonymous/4351118 to your computer and use it in GitHub Desktop.
Save anonymous/4351118 to your computer and use it in GitHub Desktop.
#!/bin/bash
case "$(uname -i)" in
('i386')
dl=`wget http://www.sublimetext.com/2 -O - |& grep '<li id="dl_linux_32">' | grep -Eo 'http://[^"]*'`
file="$(echo $dl | sed 's/.*\///')"
;;
('x86_64')
dl=`wget http://www.sublimetext.com/2 -O - |& grep '<li id="dl_linux_64">' | grep -Eo 'http://[^"]*'`
file="$(echo $dl | sed 's/.*\///')"
;;
esac
# Download and extract Sublime Text 2
if [ -d "$HOME/Ubuntu One" ]; then
cd "$HOME/Ubuntu One"
if [ ! -d "$HOME/Ubuntu One/Sublime Text 2" ]; then
wget "$dl" && tar xf "$file" && rm "$file"
fi
target="$HOME/Ubuntu One/Sublime Text 2"
else
cd $HOME
if [ ! -d "$HOME/Sublime Text 2" ]; then
wget "$dl" && tar xf "$file" && rm "$file"
fi
target="$HOME/Sublime Text 2"
fi
# Create desktop file
if [ ! -f "$HOME/.local/share/applications/sublime.desktop" ]; then
mkdir -p "$HOME/.local/share/applications"
cat > "$HOME/.local/share/applications/sublime.desktop" <<ENDLINE
[Desktop Entry]
Type=Application
Name=Sublime Text 2
Comment=Sublime Text is a sophisticated text editor for code, markup and prose. You'll love the slick user interface, extraordinary features and amazing performance.
Exec="$target/sublime_text"
Categories=Development;
Icon=$target/Icon/256x256/sublime_text.png
Terminal=false
StartupNotify=true
ENDLINE
fi
# Create symbolic link
if [ ! -f "$HOME/.local/bin/subl" ]; then
mkdir -p "$HOME/.local/bin"
ln -s "$target/sublime_text" $HOME/.local/bin/subl
if ! grep "$HOME/.local/bin" $HOME/.profile > /dev/null 2>&1; then
cat >> $HOME/.profile <<ENDLINE
if [ -d "\$HOME/.local/bin" ] ; then
PATH="\$PATH:\$HOME/.local/bin"
fi
ENDLINE
fi
fi
@fourdollars
Copy link

@fourdollars
Copy link

Hi all,

I made another tool at http://fourdollars.github.com/quick/ to install Sublime Text 2.

$ quick update && quick install sublime-text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment