Skip to content

Instantly share code, notes, and snippets.

@mslinn
Created October 13, 2019 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mslinn/db41c6b58b750855bc4e7718bf8acf28 to your computer and use it in GitHub Desktop.
Save mslinn/db41c6b58b750855bc4e7718bf8acf28 to your computer and use it in GitHub Desktop.
WSL launch script for IntelliJ IDEA
#!/bin/bash
set -eo pipefail
idea2 "$@" &
unset SBT_OPTS
export IDEA_HOME=/opt/idea-IU-192.6262.58 # TODO modify this path to the IDEA installation location
cd "$IDEA_HOME/bin"
export LIBXCB_ALLOW_SLOPPY_LOCK=1
PID_FILE=/var/run/idea.pid
if [ -f "$PID_FILE" ]; then
PID="$(cat $PID_FILE)"
if [ "$PID" != "" ]; then
echo "Killing process in $PID_FILE (pid $PID)"
sudo kill -9 "$PID"
fi
sudo rm $PID_FILE
fi
PROCS="$(ps aux | grep [i]dea | grep java)"
while read -r PSOUT; do
PID="$(echo "$PSOUT" | cut -d' ' -f5)"
NAME="$(echo "$PSOUT" | cut -d' ' -f18)"
if [ "$PID" ]; then
echo "Killing $NAME (pid $PID)"
sudo kill -9 $PID
fi
done <<< "$PROCS"
echo $! | sudo tee $PID_FILE
./idea.sh "$@" &> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment