-
-
Save kigster/ebe0efcece59b6700faadb52997a7bed to your computer and use it in GitHub Desktop.
JetBrains Command Line IDE Finder / Launcher. This tool should be installed in /usr/local/bin/jb and then, as long as your JetBrains apps are installed into `/Applications/apps` folder, `jb` will be able to find launch them. If the binaries are installed elsewhere, set the `JETBRAINS_INSTALLATION_DIR` folder.
This file contains 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
#!/usr/bin/env bash | |
# | |
# © 2019 Konstantin Gredeskoul | |
# | |
# A generic jetbrains command line launcher after the Toolbox one seems to | |
# never really work anymore. | |
# | |
# This tool should be installed in /usr/local/bin/jb and then, as long as your JetBrains apps | |
# are installed into `/Applications/apps` folder, `jb` will be able to find launch them. | |
# If the binaries are installed elsewhere, set the `JETBRAINS_INSTALLATION_DIR` folder. | |
# | |
# For instance, grab the latest RAW URL of the script and paste it into the JB_URL definition below: | |
# | |
# JB_URL="https://gist.githubusercontent.com/kigster/ebe0efcece59b6700faadb52997a7bed/raw/5c2118d5dd99147b582ede4df7694ab414864288/jb" | |
# curl -fSLs $JB_URL -o/usr/local/bin/jb && chmod 755 /usr/local/bin/jb | |
# | |
set -e | |
export JETBRAINS_INSTALLATION_DIR=${JETBRAINS_INSTALLATION_DIR:-"/Applications/apps"} | |
export JETBRAINS_LOG_DIR=${JETBRAINS_LOG_DIR:-"${HOME}/Library/Logs/JetBrains"} | |
jb::binaries() { | |
find "${JETBRAINS_INSTALLATION_DIR}" -type f -perm 755 | grep MacOS | sed 's/.*MacOS\///g' | tr '\n' ' ' | |
} | |
jb::binary() { | |
local binary="$1" | |
[[ -n "${binary}" ]] && find "${JETBRAINS_INSTALLATION_DIR}" -type f -perm 755 -name ${binary} -print | |
} | |
jb::run() { | |
local exe="$1"; shift | |
local binary="$(basename "${exe}")" | |
local now=$(date +%Y-%m-%d.%H:%M:%S) | |
mkdir -p "${JETBRAINS_LOG_DIR}/${binary}" | |
local path="$(pwd)" | |
( "${exe}" "${path}" 1>"${JETBRAINS_LOG_DIR}/${binary}/${now}.log" 2>&1 ) & | |
return $? | |
} | |
jb::main() { | |
local ide="${1:-'rubymine'}"; shift | |
for executable in $(jb::binaries); do | |
if [[ "${executable}" == *${ide}* ]] ; then | |
local exe="$(jb::binary ${executable})" | |
if [[ -x "${exe}" ]]; then | |
jb::run "${exe}" "$@" | |
# not really necessary, since | |
exit $? | |
fi | |
fi | |
done | |
printf "ERROR: Couldn't find any IDE matching %s.\n" "${ide}" | |
exit 1 | |
} | |
jb::main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment