Created
September 24, 2016 00:38
-
-
Save brunohcastro/4f2f92ce33aa122ae2df1f7ddb771aae to your computer and use it in GitHub Desktop.
Bash script to install Sublime Text from tarball and generate a desktop entry. Can be modified to work with any application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### | |
# Sublime Text 3 - Installation Script | |
### | |
# | |
# Edit this configurations if you need | |
# | |
TARBALL="https://download.sublimetext.com/sublime_text_3_build_3126_x64.tar.bz2" | |
TMP_FILE="/tmp/sublime_text.tar.bz2" | |
OUTPUT_FOLDER="/opt/sublime_text" | |
PREFIX="/usr/local" | |
# You don't NEED to touch anything after this. | |
# But be my guest if you really want! | |
if [ $EUID != 0 ]; then | |
sudo "$0" "$@" | |
exit $? | |
fi | |
SHORTCUT="[Desktop Entry] | |
Name=Sublime Text 3 | |
Comment=Edit text files | |
Exec=$OUTPUT_FOLDER/sublime_text | |
Icon=$OUTPUT_FOLDER/Icon/128x128/sublime-text.png | |
Terminal=false | |
Type=Application | |
Encoding=UTF-8 | |
Categories=Utility;TextEditor;" | |
SCRIPT="#!/bin/sh | |
if [ \${1} == \"--help\" ]; then | |
$OUTPUT_FOLDER/sublime_text --help | |
else | |
$OUTPUT_FOLDER/sublime_text \$@ > /dev/null 2>&1 & | |
fi" | |
echo "Downloading..." | |
curl -L ${TARBALL} -o ${TMP_FILE} | |
rm -rf ${OUTPUT_FOLDER} | |
mkdir -pv ${OUTPUT_FOLDER} | |
echo "Extracting the tarball..." | |
tar -xjf ${TMP_FILE} --strip-components=1 -C ${OUTPUT_FOLDER} | |
echo "Creating scripts..." | |
echo "${SCRIPT}" > "$PREFIX/bin/subl" | |
chmod +x "$PREFIX/bin/subl" | |
echo "${SHORTCUT}" > "/usr/share/applications/sublime_text_3.desktop" | |
echo "Cleaning up..." | |
rm -rf ${TMP_FILE} | |
echo "Finish!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment