tmux custom window activate script hook

This commit is contained in:
David Chen 2025-10-28 16:22:27 -07:00
parent 04c174c8ef
commit 8d13a7a39a
2 changed files with 23 additions and 0 deletions

View file

@ -4,6 +4,7 @@
# set-option default-path "$PWD" # deprecated in tmux 1.9
setw -g xterm-keys on
set-window-option -g xterm-keys on
set -s escape-time 0
set -sg repeat-time 300
set -s focus-events on
@ -51,6 +52,11 @@ set-hook -ag client-attached 'run -b "tmux refresh-client -S"'
set-hook -ag pane-focus-in 'run -b "~/.config/agent-tracker/bin/tracker-client command acknowledge --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id}"'
set-hook -ag pane-focus-in 'run -b "tmux refresh-client -S"'
set-hook -ag pane-died 'run -b "~/.config/agent-tracker/bin/tracker-client command delete_task --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id}"'
# -- Project-specific window activation hooks
# Checks for ./on-tmux-window-activate.sh or ../on-tmux-window-activate.sh and runs it
set-hook -ag after-select-window 'run-shell "~/.config/tmux/scripts/check_and_run_on_activate.sh \"#{pane_current_path}\""'
# set-hook -ag window-linked 'run -b "tmux refresh-client -S"'
# set-hook -ag window-unlinked 'run -b "tmux refresh-client -S"'
# set-hook -ag window-renamed 'run -b "tmux refresh-client -S"'

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Check for on-tmux-window-activate.sh in current dir or parent dir and run it
pane_dir="${1:-$PWD}"
# Check current directory
if [[ -x "$pane_dir/on-tmux-window-activate.sh" ]]; then
exec "$pane_dir/on-tmux-window-activate.sh"
fi
# Check parent directory
parent_dir=$(dirname "$pane_dir")
if [[ -x "$parent_dir/on-tmux-window-activate.sh" ]]; then
exec "$parent_dir/on-tmux-window-activate.sh"
fi
exit 0