Skip to content

Instantly share code, notes, and snippets.

@agilesteel
Created July 4, 2021 17:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agilesteel/7a3431388ad65e8fa032526f8548f14b to your computer and use it in GitHub Desktop.
Save agilesteel/7a3431388ad65e8fa032526f8548f14b to your computer and use it in GitHub Desktop.
alias jps ='jps -lvm'
alias jpsk9='jps | fzf --reverse -m -e -i | cut -d " " -f1 | xargs kill -9 2>/dev/null'
alias jpsk ='jps | fzf --reverse -m -e -i | cut -d " " -f1 | xargs kill 2>/dev/null'
@pjhampton
Copy link

Thanks! I didn't know about jps and this is awesome <3

@agilesteel
Copy link
Author

I also just learned about it a few weeks ago :)

@kotobotov
Copy link

i like it

@fredshonorio
Copy link

I've based a version of this, it includes the working directory (which is useful for distinguishing sbt processes running in the background):

jpsk() {
    jps -l | awk '{
        # run pwdx for the first column, write the output to `wd`
        cmd = "pwdx "$1
        cmd | getline wd
        close(cmd)
        # pwdx prefixes the working directory with a pid, like "1234: /home/john", we remove it (modifying `wd` in-place)
        sub("[0-9]+: ", "", wd)
        # then append wd to the jps output
        print $0  " [" wd "]"
    }' | fzf --reverse -m -e -i | cut -d " " -f1 | xargs kill 2>/dev/null
}

@agilesteel
Copy link
Author

Fancy 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment