diff options
| author | Robert Günzler <r@gnzler.io> | 2021-02-23 13:30:35 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-04-26 02:09:45 +0200 |
| commit | b4f36184737179856d38e544468af31b4c56c7eb (patch) | |
| tree | ee2facb2e4bd12fff34776c58c1cc285239f08cf /bin/swkill | |
| parent | 3085bc77b3f1fcc31259997a30be306a4d80f6bc (diff) | |
bin/swkill: query once and reuse return value
Diffstat (limited to 'bin/swkill')
| -rwxr-xr-x | bin/swkill | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/swkill b/bin/swkill index 9a4a9ab..3ca2e3f 100755 --- a/bin/swkill +++ b/bin/swkill @@ -25,12 +25,13 @@ if [ -z "$sel" ]; then sel="current workspace" fi -swq "$sel" | jq '.. | select(.pid?) | .name' +_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 -swq "$sel" | jq '.. | select(.pid?) | .pid' | xargs kill +printf "${_cons}" | jq '.[].pid' | xargs kill |