Skip to content

Instantly share code, notes, and snippets.

@rijnhard
Forked from aikar/jbtb-open.sh
Last active September 10, 2019 08:48
Show Gist options
  • Save rijnhard/757d02948b00e697ca570535a8ad7617 to your computer and use it in GitHub Desktop.
Save rijnhard/757d02948b00e697ca570535a8ad7617 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ]; then
echo "$0 <app> <channel> <binpath> [*args]"
exit 1
fi
app=$1
channel=$2
binpath=$3
shift
shift
shift
base=~/.local/share/JetBrains/Toolbox/apps/$app
apppath=$base/$channel
ver=$(/bin/ls "$apppath" | tail -n 1)
if [ -z "$ver" ]; then
echo "Can not find $app - $channel"
exit 1
fi
$apppath/$ver/bin/${binpath}.sh "$@"
#!/usr/bin/env bash
# PhpStorm URL Handler
# phpstorm://open?url=file://@file&line=@line
# phpstorm://open?file=@file&line=@line
#
# @license GPL
# @author Stefan Auditor <stefan.auditor@erdfisch.de>
# @modified by Rijnhard Hessel <r.hessel.git@gmail.com>
TOOLBOX_HOME=~/.local/share/JetBrains/Toolbox/apps/
#
# param app Directory name ()
#
function find_idea() {
local app=$1
local binpath=$(echo "${app}" | tr '[:upper:]' '[:lower:]')
local apppath=$(find "${TOOLBOX_HOME}/${app}/" \
! -path '*.vmoptions' ! -path '*.plugins' \
-maxdepth 2 -mindepth 2 -type d \
-exec echo {} \; \
| sort -t '\0' -n \
| tail -n -1)
if [ -z "$apppath" ]; then
echo "Can not find $app in ${TOOLBOX_HOME}/${app}/"
exit 2
fi
echo "$apppath/bin/${binpath}.sh"
}
arg=${1}
pattern=".*file(:\/\/|\=)(.*)&line=(.*)"
file=$(echo "${arg}" | sed -r "s/${pattern}/\2/")
line=$(echo "${arg}" | sed -r "s/${pattern}/\3/")
executable=$(find_idea PhpStorm)
"${executable}" --line "${line}" "${file}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment