#!/usr/bin/env bash | |
# Usage: {script} [ OPTIONS ] TARGET VERSION | |
# | |
# TARGET Default target is "/usr/local". | |
# VERSION If not defined tries to get the build into the Sublime Text 2 website. | |
# | |
# OPTIONS | |
# | |
# -h, --help Displays this help message. | |
# | |
# Report bugs to Henrique Moody <henriquemoody@gmail.com> | |
# | |
set -e | |
if [[ "${1}" = '-h' ]] || [[ "${1}" = '--help' ]]; then | |
sed -E 's/^#\s?(.*)/\1/g' "${0}" | | |
sed -nE '/^Usage/,/^Report/p' | | |
sed "s/{script}/$(basename "${0}")/g" | |
exit | |
fi | |
declare URL | |
declare URL_FORMAT="http://c758482.r82.cf2.rackcdn.com/%s.tar.bz2" | |
declare PACKAGE="Sublime Text" | |
declare TARGET="${1:-/usr/local}" | |
declare VERSION="${2}" | |
declare BITS=$(uname -m) | |
if [[ -z "${VERSION}" ]]; then | |
VERSION=$( | |
curl -Ls http://www.sublimetext.com/2 | | |
grep '<h2>Version' | | |
head -n1 | | |
sed -E 's#<h2>Version ([0-9.]+)</h2>#\1#g' | |
) | |
fi | |
PACKAGE+=" ${VERSION}" | |
if [[ "${BITS}" = "x86_64" ]]; then | |
PACKAGE+=" x64" | |
fi | |
URL=$(printf "${URL_FORMAT}" "${PACKAGE}" | sed 's/ /%20/g') | |
read -p "Do you really want to install \"${PACKAGE}\" on \"${TARGET}\"? [Y/n]: " CONFIRM | |
CONFIRM=$(echo "${CONFIRM}" | tr [a-z] [A-Z]) | |
if [[ "${CONFIRM}" = 'N' ]] || [[ "${CONFIRM}" = 'NO' ]]; then | |
echo "Aborted!" | |
exit | |
fi | |
echo "Downloading ${PACKAGE}" | |
curl -L "${URL}" | tar -xjC ${TARGET} | |
echo "Creating binary file" | |
cat > ${TARGET}/bin/subl <<SCRIPT | |
#!/bin/sh | |
if [ \${1} == \"--help\" ]; then | |
${TARGET}/sublime_text_3/sublime_text --help | |
else | |
${TARGET}/sublime_text_3/sublime_text \$@ > /dev/null 2>&1 & | |
fi | |
SCRIPT | |
echo "Creating shortcut file" | |
cat > "/usr/share/applications/sublime-text-2.desktop" <<SHORTCUT | |
[Desktop Entry] | |
Name=Sublime Text 2 | |
Comment=Edit text files | |
Exec=/usr/local/sublime-text-2/sublime_text | |
Icon=/usr/local/sublime-text-2/Icon/128x128/sublime_text.png | |
Terminal=false | |
Type=Application | |
Encoding=UTF-8 | |
Categories=Utility;TextEditor; | |
SHORTCUT | |
echo "Finish!" |
#!/usr/bin/env bash | |
# Usage: {script} [ OPTIONS ] TARGET BUILD | |
# | |
# TARGET Default target is "/usr/local". | |
# BUILD If not defined tries to get the build into the Sublime Text 3 website. | |
# | |
# OPTIONS | |
# | |
# -h, --help Displays this help message. | |
# | |
# Report bugs to Henrique Moody <henriquemoody@gmail.com> | |
# | |
set -e | |
if [[ "${1}" = '-h' ]] || [[ "${1}" = '--help' ]]; then | |
sed -E 's/^#\s?(.*)/\1/g' "${0}" | | |
sed -nE '/^Usage/,/^Report/p' | | |
sed "s/{script}/$(basename "${0}")/g" | |
exit | |
fi | |
declare URL | |
declare URL_FORMAT="http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_%d_x%d.tar.bz2" | |
declare TARGET="${1:-/usr/local}" | |
declare BUILD="${2}" | |
declare BITS | |
if [[ -z "${BUILD}" ]]; then | |
BUILD=$( | |
curl -Ls http://www.sublimetext.com/3 | | |
grep '<h2>Build' | | |
head -n1 | | |
sed -E 's#<h2>Build ([0-9]+)</h2>#\1#g' | |
) | |
fi | |
if [[ "$(uname -m)" = "x86_64" ]]; then | |
BITS=64 | |
else | |
BITS=32 | |
fi | |
URL=$(printf "${URL_FORMAT}" "${BUILD}" "${BITS}") | |
read -p "Do you really want to install Sublime Text 3 (Build ${BUILD}, x${BITS}) on \"${TARGET}\"? [Y/n]: " CONFIRM | |
CONFIRM=$(echo "${CONFIRM}" | tr [a-z] [A-Z]) | |
if [[ "${CONFIRM}" = 'N' ]] || [[ "${CONFIRM}" = 'NO' ]]; then | |
echo "Aborted!" | |
exit | |
fi | |
echo "Downloading Sublime Text 3" | |
curl -L "${URL}" | tar -xjC ${TARGET} | |
echo "Creating shortcut file" | |
cat ${TARGET}/sublime_text_3/sublime_text.desktop | | |
sed "s#/opt#${TARGET}#g" | | |
cat > "/usr/share/applications/sublime_text.desktop" | |
echo "Creating binary file" | |
cat > ${TARGET}/bin/subl <<SCRIPT | |
#!/bin/sh | |
if [ \${1} == \"--help\" ]; then | |
${TARGET}/sublime_text_3/sublime_text --help | |
else | |
${TARGET}/sublime_text_3/sublime_text \$@ > /dev/null 2>&1 & | |
fi | |
SCRIPT | |
echo "Finish!" |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
czpython
commented
Oct 24, 2012
Works like a charm. Thanks :). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
bargaorobalo
commented
Nov 8, 2012
Best way to install sublime text 2. Thank you. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
Taris9047
Nov 29, 2012
I suggest attach ' %U' to the line "Exec=/usr/local/sublime-text-2/sublime_text".
It will enable mime type association in Gnome 3. Without this, we cannot open anything with Sublime Text 2 in the Nautilus GUI environment.
Taris9047
commented
Nov 29, 2012
I suggest attach ' %U' to the line "Exec=/usr/local/sublime-text-2/sublime_text". |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
nvurgaft
commented
Dec 15, 2012
works nice, thanks. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
prubini87
commented
Dec 27, 2012
Thanks! Works great on Fedora 7! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
xtranophilist
Jan 23, 2013
wget -O /etc/yum.repos.d/sublime2.repo http://repo.cloudhike.com/sublime2/fedora/sublime2.repo
yum -y install sublime-text
xtranophilist
commented
Jan 23, 2013
wget -O /etc/yum.repos.d/sublime2.repo http://repo.cloudhike.com/sublime2/fedora/sublime2.repo |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
michahell
Jan 29, 2013
@xtranophilist and theeeeen? How to fire it up? Maybe provide a liiiitle more information would be nice :)
michahell
commented
Jan 29, 2013
@xtranophilist and theeeeen? How to fire it up? Maybe provide a liiiitle more information would be nice :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
michahell
Jan 29, 2013
On fedora 18 in virtualbox VM on Mac OSX, first tried method of @xtranophilist: don't know where it's installed or how to fire it up... Then tried the shell script, that worked, also got an icon in activities, but when i click it, nothing happens. So, i'll download the tar from sublime text 2 site (which i should've done first anyway) and check if 'just' unzipping that works :)
michahell
commented
Jan 29, 2013
On fedora 18 in virtualbox VM on Mac OSX, first tried method of @xtranophilist: don't know where it's installed or how to fire it up... Then tried the shell script, that worked, also got an icon in activities, but when i click it, nothing happens. So, i'll download the tar from sublime text 2 site (which i should've done first anyway) and check if 'just' unzipping that works :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
nvurgaft
Feb 8, 2013
if you install from the script, sublime will be installed at "/usr/local/sublime-text-2"
if from the repo then sublime will install itself at "/usr/local/sublime-text/" !!
the first doesn't work for me (fedora18), neither is the menu link, the second approach does!
it puts the "sublime" executable into your PATH (/usr/bin ) so you can start it from command.
nvurgaft
commented
Feb 8, 2013
if you install from the script, sublime will be installed at "/usr/local/sublime-text-2" the first doesn't work for me (fedora18), neither is the menu link, the second approach does! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
xtranophilist
Feb 14, 2013
@michahell
as @nvurgaft said, you can launch sublime
from anywhere since it's in your path (/bin/sublime
).
Also, I can see Sublime2
under Applications in Gnome.
xtranophilist
commented
Feb 14, 2013
@michahell Also, I can see |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
gdiazs
commented
Mar 4, 2013
thanks!! very useful. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
t0dd
commented
Mar 23, 2013
awesome! Thx! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
vtufekciev
commented
Apr 28, 2013
Works great on Fedora 18 tnx |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
chris-roerig
commented
May 1, 2013
Fedora 19 beta checking in. Thanks! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
kyon0304
May 7, 2013
In my case, to enable command line use, the contents of /usr/bin/sublime/
should be:
if [ "${1}" == "--help" ]; then
/usr/local/sublime-text-2/sublime_text --help
else
/usr/local/sublime-text-2/sublime_text $@ > /dev/null 2>&1 &
fi
and I'm in fedora 18.
Hope for some use.
kyon0304
commented
May 7, 2013
In my case, to enable command line use, the contents of
and I'm in fedora 18. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
closethipster
commented
May 31, 2013
Works perfectly with final Fedora 19 beta; thank you! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
storrgie
Jun 17, 2013
On Fedora 19 here, I made a different script based on this one: https://gist.github.com/storrgie/5799669
storrgie
commented
Jun 17, 2013
On Fedora 19 here, I made a different script based on this one: https://gist.github.com/storrgie/5799669 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
sayak-sarkar
Jun 18, 2013
Thanks!! Works great on Fedora 19.
However, you might wanna add an extra line at the end to insert a symbolic link the application at /usr/bin
to enable terminal shortcut as follows:
ln -s /usr/local/sublime-text-2/sublime_text /usr/bin/sublime-text
An example can be found at this fork: https://gist.github.com/sayak-sarkar/5810101
sayak-sarkar
commented
Jun 18, 2013
Thanks!! Works great on Fedora 19. However, you might wanna add an extra line at the end to insert a symbolic link the application at
An example can be found at this fork: https://gist.github.com/sayak-sarkar/5810101 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
gustavovnicius
Jul 10, 2013
Thanks! Works great!!!
I just needed to change the SCRIPT var a little bit, adding quotes in $1 parameter, cause when I call "subl" without a path specified as a parameter gave me a error:
/usr/local/bin/subl: line 2: [: =: unary operator expected
SCRIPT="#!/bin/sh
if [ \"\${1}\" == \"--help\" ]; then
/usr/local/sublime-text-2/sublime_text --help
else
/usr/local/sublime-text-2/sublime_text \$@ > /dev/null 2>&1 &
fi"
gustavovnicius
commented
Jul 10, 2013
Thanks! Works great!!! I just needed to change the SCRIPT var a little bit, adding quotes in $1 parameter, cause when I call "subl" without a path specified as a parameter gave me a error:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
supaiku0
Jul 13, 2013
The link should be updated to the new version:
http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.2%20x64.tar.bz2
supaiku0
commented
Jul 13, 2013
The link should be updated to the new version: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
martijnvandijk
Jul 18, 2013
Works like a charm. Had to modify it a bit, I already installed sublime in /opt
martijnvandijk
commented
Jul 18, 2013
Works like a charm. Had to modify it a bit, I already installed sublime in /opt |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
chetu
Aug 8, 2013
Awesome work !!!
for sublime beta 3 modified script.
_
!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
Exec=/usr/local/sublime-text_3/sublime_text
Icon=/usr/local/sublime-text_3/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
SCRIPT="#!/bin/sh
if [ ${1} == "--help" ]; then
/usr/local/sublime-text_3/sublime_text --help
else
/usr/local/sublime-text_3/sublime_text $@ > /dev/null 2>&1 &
fi"
curl -L "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3047_x64.tar.bz2" -o "/usr/src/Sublime Text 3.tar.bz2"
cd /usr/src
tar -xvjf "Sublime Text 3.tar.bz2"
cd "sublime_text_3"
mkdir -pv "/usr/local/sublime-text_3"
mv -fv * "/usr/local/sublime-text_3/"
echo "${SCRIPT}" > "/usr/local/bin/subl"
chmod +x "/usr/local/bin/subl"
echo "${SHORTCUT}" > "/usr/share/applications/sublime-text_3.desktop"
echo "Finish!"
chetu
commented
Aug 8, 2013
Awesome work !!! for sublime beta 3 modified script. _ !/bin/shSHORTCUT="[Desktop Entry] curl -L "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3047_x64.tar.bz2" -o "/usr/src/Sublime Text 3.tar.bz2" echo "Finish!" |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
Strongground
Oct 4, 2013
Works perfectly. I just get one error when starting sublime:
"/usr/local/bin/subl: 2: [: ==: unexpected operator"
Any idea where this unexpected operator comes from?
I installed on Ubuntu 13.04, 32bit.
Strongground
commented
Oct 4, 2013
Works perfectly. I just get one error when starting sublime: Any idea where this unexpected operator comes from? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
jamerlan
Oct 4, 2013
Strongground, this should work without error
!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
Exec=/usr/local/sublime-text_3/sublime_text
Icon=/usr/local/sublime-text_3/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
SCRIPT="#!/bin/sh
/usr/local/sublime-text_3/sublime_text $@ > /dev/null 2>&1 &
curl -L "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3047_x64.tar.bz2" -o "/usr/src/Sublime Text 3.tar.bz2"
cd /usr/src
tar -xvjf "Sublime Text 3.tar.bz2"
cd "sublime_text_3"
mkdir -pv "/usr/local/sublime-text_3"
mv -fv * "/usr/local/sublime-text_3/"
echo "${SCRIPT}" > "/usr/local/bin/subl"
chmod +x "/usr/local/bin/subl"
echo "${SHORTCUT}" > "/usr/share/applications/sublime-text_3.desktop"
echo "Finish!"
jamerlan
commented
Oct 4, 2013
Strongground, this should work without error !/bin/shSHORTCUT="[Desktop Entry] curl -L "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3047_x64.tar.bz2" -o "/usr/src/Sublime Text 3.tar.bz2" echo "Finish!" |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
docbillnet
Dec 20, 2013
I like the repo mentioned above:
wget -O /etc/yum.repos.d/sublime2.repo http://repo.cloudhike.com/sublime2/fedora/sublime2.repo
yum -y install sublime-text
Sadly, though the repo doesn't seemed to be maintained anymore. The newest build is a year old, and the newest Fedora versions supported is also a year old...
docbillnet
commented
Dec 20, 2013
I like the repo mentioned above:
Sadly, though the repo doesn't seemed to be maintained anymore. The newest build is a year old, and the newest Fedora versions supported is also a year old... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
uccmen
Jan 11, 2014
I can't see the Sublime icon under Applications after running this script. How do I fix this?
uccmen
commented
Jan 11, 2014
I can't see the Sublime icon under Applications after running this script. How do I fix this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
simonewebdesign
Oct 28, 2014
@uccmen you need to update the Icon path in the sublime_text.desktop
file. Icons are under the /opt/sublime_text/Icon
folder (assuming you have installed it there).
Guys, if you need to install Sublime Text 3 in other Linux distros, try this script:
https://gist.github.com/simonewebdesign/8507139
simonewebdesign
commented
Oct 28, 2014
@uccmen you need to update the Icon path in the Guys, if you need to install Sublime Text 3 in other Linux distros, try this script: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
angvishvish
commented
Jul 2, 2015
really nice, works like a charm for me too .. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
3esmit
Mar 4, 2016
Hey, you need to update the download site https://download.sublimetext.com/sublime_text_3_build_3103_x32.tar.bz2
3esmit
commented
Mar 4, 2016
Hey, you need to update the download site https://download.sublimetext.com/sublime_text_3_build_3103_x32.tar.bz2 |
Works like a charm. Thanks :).