aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-12-19 16:19:36 +0100
committerDuncaen <mail@duncano.de>2017-12-19 16:19:36 +0100
commit4bf3195e13d85e81cc5004c1d0e95414899d4558 (patch)
treef2fae8e3fd1bc8854a03d674a81afe596c9ce445
parentd58fee76e7014a461fada5b0c549198c33f48379 (diff)
downloaddotfiles-4bf3195e13d85e81cc5004c1d0e95414899d4558.tar.gz
tmux: add ^T to send SIGUSR1 to foreground process
-rwxr-xr-xbin/tmux-signal14
-rw-r--r--tmux.conf1
2 files changed, 15 insertions, 0 deletions
diff --git a/bin/tmux-signal b/bin/tmux-signal
new file mode 100755
index 0000000..f268167
--- /dev/null
+++ b/bin/tmux-signal
@@ -0,0 +1,14 @@
+#!/bin/sh
+# tmux-signal pid [signal] - send signal to running processes in pids session
+# bind ^T run-shell -b "tmux-signal #{pane_pid} USR1"
+
+[ "$#" -lt 1 ] && return 1
+sid=$(cut -d' ' -f6 "/proc/$1/stat")
+sig=$2
+: ${sig:=USR1}
+ps -ho state,pid --sid "$sid" | \
+while read state pid; do
+ case "$state" in
+ R) kill -s"$sig" "$pid" ;;
+ esac
+done
diff --git a/tmux.conf b/tmux.conf
index c4b95e6..a7654dc 100644
--- a/tmux.conf
+++ b/tmux.conf
@@ -47,6 +47,7 @@ bind h split-window -h
bind v split-window
bind . neww -c '#{pane_current_path}'
bind ^R neww rc
+bind -n ^T run-shell -b "tmux-signal #{pane_pid} USR1"
bind -n C-left previous-window
bind -n C-right next-window