Skip to content

Instantly share code, notes, and snippets.

@Enelar
Last active August 29, 2015 14:21
Show Gist options
  • Save Enelar/774cb07fca2fcf832d52 to your computer and use it in GitHub Desktop.
Save Enelar/774cb07fca2fcf832d52 to your computer and use it in GitHub Desktop.
Any yum based linux Sublime Text 3 install (into /opt with current user shortcut)
#!/bin/bash
# http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
RED='\033[0;31m'
NC='\033[0m' # No Color
printf "${RED}Check&install required utility${NC}\n"
rpmqa=`rpm -qa`
echo $rpmqa | grep -qw lynx || sudo yum install lynx
echo $rpmqa | grep -qw wget || sudo yum install wget
echo $rpmqa | grep -qw tar || sudo yum install tar
bit="32"
if [ `uname -m` == "x86_64" ]; then
bit="64"
fi
printf "${RED}We detected $bit system${NC}\n"
printf "${RED}Extract url from sublime site${NC}\n"
url=`lynx -dump -listonly http://www.sublimetext.com/3 | grep $bit | grep .tar.bz2`
if [ -z url ]; then
printf "${RED}Sorry, looks sublimetext.com looks different. I cant exctract url to archieve${NC}\n"
exit 1
fi
download_url=`echo $url | awk '{print $2}'`
printf "${RED}Extracted link: ${NC} $download_url\n"
printf "${RED}Download&Install${NC}\n"
cd /opt
sudo wget --progress=bar:force -O sublime.tar.bz2 $download_url
sudo tar -xvf sublime.tar.bz2
printf "${RED}Desktop icon${NC}\n"
cat > ~/.local/share/applications/sublime_text_3.desktop << EOF
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sublime Text 3
Comment=Sublime Text 3
Exec=/opt/sublime_text_3/sublime_text
Icon=/opt/sublime_text_3/Icon/256x256/sublime-text.png
Terminal=false
EOF
printf "${RED}Done. Feel free to use${NC}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment