blob: 3ca2e3fe50c9536dc4ecc48f072fc0ce6f511b46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/sh
#
# DESCRIPTION:
# kill the processes behind the containers returned by the `swq` query
#
set -e
[ -n "$DEBUG" ] && set -x
# check requirements
for tool in jq swq; do
if ! command -v "$tool" >/dev/null; then
printf "%s: %s not installed but required\n" "$(basename "$0")" "$tool" >&2
exit 1
fi
done
if [ "$1" = "-y" ]; then
shift
noninteractive=1
fi
sel="$*"
if [ -z "$sel" ]; then
sel="current workspace"
fi
_cons=$(swq $sel | jq '[ .. | select(.pid?) | { name: .name, pid: .pid } ]')
if [ -z "$noninteractive" ]; then
printf "${_cons}" | jq '.[].name'
{ sleep 10 && kill $$; } &
printf "kill? (you have 10s) "
read -r
fi
printf "${_cons}" | jq '.[].pid' | xargs kill
|