#!/bin/bash
case "$(uname -i)" in
('i386')
dl=`wget http://www.sublimetext.com/2 -O - |& grep '
' | grep -Eo 'http://[^"]*'`
file="$(echo $dl | sed 's/.*\///')"
;;
('x86_64')
dl=`wget http://www.sublimetext.com/2 -O - |& grep '' | 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" < /dev/null 2>&1; then
cat >> $HOME/.profile <