Skip to content

Instantly share code, notes, and snippets.

@metaquanta
Last active July 28, 2016 21:21
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 metaquanta/0c3eac0207a57a0d4586a2a408aadd57 to your computer and use it in GitHub Desktop.
Save metaquanta/0c3eac0207a57a0d4586a2a408aadd57 to your computer and use it in GitHub Desktop.
For when you need to quit an Eclipse running in a different X session:
#!/bin/sh
ECLIPSE_VERSION=46
ECLIPSE_HOME= ## path to the jar referenced in the next line ##
ECLIPSE_CMDLINE_MATCH="jar ${ECLIPSE_HOME}/plugins/org.eclipse.equinox.launcher"
# This just leaves an orphan
killall eclipse${ECLIPSE_VERSION} 2> /dev/null
# This still just leaves an orphan
killall eclipse 2> /dev/null
ECLIPSE_JAVA_PID=`\
ps xo pid,cmd \
| grep "${ECLIPSE_CMDLINE_MATCH}" \
| grep -v grep \
| grep -o -P '^ *\d+' \
| grep -oP '\d*' \
`
if [ -n "$ECLIPSE_JAVA_PID" ]
then
# This really kills it
kill ${ECLIPSE_JAVA_PID}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment