3

when I run tmux kill-session, it sends SIGHUP to all processes that are running. This often isn't enough for my purposes, and I want to send SIGINT or SIGKILL.

A command like this would do the trick:

tmux list-panes -s -F "#{pane_pid} #{pane_current_command}" | grep -v tmux | awk '{print $1}' | xargs kill -9

(From this answer.)

How can I run this everytime I call kill-session? Apparently there is no before-kill-session hook.

fbt
  • 363
  • 1
  • 2
  • 6

1 Answers1

0

You could try this -

Put your command in a script like this:

tmux lsp ...
tmux real-kill-session "$@"

And make it +x. Then add command-alias like this:

set -s command-alias[100] 'real-kill-session=kill-session'
set -s command-alias[101] 'kill-session=run /path/to/kill.sh'

It is usually a bad idea to send everything SIGKILL though... SIGTERM or SIGINT perhaps, but they shouldn't really be any different from SIGHUP.

Nicholas Marriott
  • 3,630
  • 9
  • 12