Something went wrong. Try again.
Mirroring: https://github.com/MunifTanjim/scripts.sh
Something went wrong. Try again.
scripts.sh setup-jetbrains-toolbox
1.1 kB · 53 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#!/usr/bin/env bash
set -euo pipefail
command_exists() { type "${1}" >/dev/null 2>&1}
ensure_tool() { local -r tool="${1}" if ! command_exists "${tool}"; then echo "missing required tool: ${tool}" exit 1 fi}
setup_for_darwin() { ensure_tool brew
echo 'cask "jetbrains-toolbox"' | brew bundle --file=-}
setup_for_debian() { ensure_tool curl
local -r url="$(curl -fsSI "https://download.jetbrains.com/product?code=TBA&latest&distribution=linux" | tr -d '\r' | grep -i "location:" | cut -d' ' -f2)" local -r filename="$(basename "${url}")" local -r archive_path="/tmp/${filename}" local -r binary_path="/tmp/jetbrains-toolbox"
echo "Downloading..." curl --progress-bar --continue-at - --output "${archive_path}" -L "${url}" echo
echo "Installing..." tar --strip-components=1 -xvzf "${archive_path}" chmod u+x "${binary_path}" mv "${binary_path}" "${HOME}/.local/bin/" echo
echo "Done!"}
case $OSTYPE in darwin*) setup_for_darwin;; linux*) setup_for_debian ;; *) echo "Unknown OS!" exit 1;;esac