Skip to content

Instantly share code, notes, and snippets.

@YuriyGuts
Last active December 1, 2018 13:57
Show Gist options
  • Save YuriyGuts/a88d522333ec5770f2775bbc98ef6c6c to your computer and use it in GitHub Desktop.
Save YuriyGuts/a88d522333ec5770f2775bbc98ef6c6c to your computer and use it in GitHub Desktop.
Download and install any JetBrains product (IntelliJ IDEA, PyCharm, CLion etc.) on Linux.
#!/usr/bin/env bash
# Install or upgrade any JetBrains product on Linux, assuming it is distributed as a tarball
# and has the entry point at $INSTALL_DIR/bin/$PRODUCT.sh
# Tested on IDEA, PyCharm, CLion, DataGrip 2016-2018.*
# Usage:
# install-jetbrains-product.sh [ProductName] [DownloadURL]
#
# Example:
# install-jetbrains-product.sh idea https://download.jetbrains.com/idea/ideaIU-2018.3.tar.gz
# install-jetbrains-product.sh pycharm https://download.jetbrains.com/python/pycharm-professional-2018.3.tar.gz
# -----------------------------------------------------
if [ -z "$1" ] && [ -z "$2" ]; then
PRODUCT=idea
DOWNLOAD_URL=https://download.jetbrains.com/idea/ideaIU-2018.3.tar.gz
else
PRODUCT=$1
DOWNLOAD_URL=$2
fi
# Convert product name to lowercase.
PRODUCT=`echo $PRODUCT | tr '[:upper:]' '[:lower:]'`
# -----------------------------------------------------
INITIAL_DIR=`pwd`
# Use axel if installed, wget otherwise.
if hash axel 2>/dev/null; then
DOWNLOADER="axel -o $PRODUCT.tar.gz"
else
DOWNLOADER="wget -O $PRODUCT.tar.gz"
fi
# Create temp folder for unpacking.
rm -rf /tmp/$PRODUCT
mkdir -p /tmp/$PRODUCT
cd /tmp/$PRODUCT
# Download and unpack, strip version number.
$DOWNLOADER $DOWNLOAD_URL
tar xzvf $PRODUCT.tar.gz
rm *.tar.gz
mv `ls -dt * | head -1` $PRODUCT
# Create target folder and move files there.
# PRODUCT is guaranteed to be non-empty nere.
INSTALL_DIR=/opt/$PRODUCT
sudo rm -rf $INSTALL_DIR
sudo mkdir -p $INSTALL_DIR
sudo chown -R `whoami` $INSTALL_DIR
rsync -IPavz $PRODUCT/ $INSTALL_DIR/
# Create symlinks.
sudo rm -f /usr/local/bin/$PRODUCT
sudo ln -s $INSTALL_DIR/bin/$PRODUCT.sh /usr/local/bin/$PRODUCT
# Remove the temp folder.
cd $INITIAL_DIR
rm -rf /tmp/$PRODUCT
@zabidok
Copy link

zabidok commented Sep 13, 2017

similar script for install or update(auto) jetbrains products like phpstorm, webstorm, IntelliJ Idea and other. + dependencies + non latin hotkeys fixes
https://gist.github.com/zabidok/8418c4f679741f585ac9ce90b16fb8a5

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