#!/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 swq "$sel" | jq '.. | select(.pid?) | .name' if [ -z "$noninteractive" ]; then { sleep 10 && kill $$; } & printf "kill? (you have 10s) " read -r fi swq "$sel" | jq '.. | select(.pid?) | .pid' | xargs kill