Skip to content

Instantly share code, notes, and snippets.

@felixexter
Created August 5, 2015 09:20
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 felixexter/18e4df3c62352a3f72ad to your computer and use it in GitHub Desktop.
Save felixexter/18e4df3c62352a3f72ad to your computer and use it in GitHub Desktop.
killbydir
#!/bin/bash
# add to /usr/local/bin/killbydir
# chmod +x /usr/local/bin/killbydir
path=`pwd`
for process in `pgrep $1`; do
foo=(`pwdx $process`)
if [ ${foo[1]} = $path ]; then
pid=${foo[0]::-1}
`kill -9 $pid`
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment