mirror of
https://github.com/theniceboy/.config.git
synced 2025-12-26 06:24:57 +08:00
make tmux config graceful when agent-tracker unavailable
This commit is contained in:
parent
69984585d0
commit
2f0fb14065
3 changed files with 17 additions and 12 deletions
16
.tmux.conf
16
.tmux.conf
|
|
@ -41,18 +41,18 @@ TMUX_THEME_COLOR \
|
|||
'
|
||||
# set-hook -gu client-attached
|
||||
# set-hook -g client-attached 'run -b "cut -c3- ~/.tmux.conf | sh -s update_env_event"'
|
||||
# Acknowledge the current pane's task when a client attaches
|
||||
set-hook -ag client-attached 'run -b "~/.config/agent-tracker/bin/tracker-client command acknowledge --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id}"'
|
||||
# Acknowledge the current pane's task when a client attaches (graceful if tracker unavailable)
|
||||
set-hook -ag client-attached 'run -b "test -x ~/.config/agent-tracker/bin/tracker-client && ~/.config/agent-tracker/bin/tracker-client command acknowledge --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id} || true"'
|
||||
set-hook -ag client-attached 'run -b "tmux refresh-client -S"'
|
||||
|
||||
# set-hook -gu client-resized
|
||||
# set-hook -ag client-resized 'run -b "~/.config/agent-tracker/bin/tracker-client command refresh --client #{client_tty}"'
|
||||
# set-hook -ag client-resized '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 "test -x ~/.config/agent-tracker/bin/tracker-client && ~/.config/agent-tracker/bin/tracker-client command acknowledge --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id} || true"'
|
||||
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}"'
|
||||
set-hook -ag pane-died 'run -b "~/.config/agent-tracker/bin/tracker-client command note_archive_pane --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id}"'
|
||||
set-hook -ag pane-died 'run -b "test -x ~/.config/agent-tracker/bin/tracker-client && ~/.config/agent-tracker/bin/tracker-client command delete_task --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id} || true"'
|
||||
set-hook -ag pane-died 'run -b "test -x ~/.config/agent-tracker/bin/tracker-client && ~/.config/agent-tracker/bin/tracker-client command note_archive_pane --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id} || true"'
|
||||
|
||||
# -- Project-specific window activation hooks
|
||||
# Checks for ./on-tmux-window-activate.sh or ../on-tmux-window-activate.sh and runs it
|
||||
|
|
@ -107,7 +107,7 @@ bind -n M-s run-shell "~/.config/tmux/scripts/toggle_scratchpad.sh"
|
|||
# window management
|
||||
bind -n M-o new-window -c "#{pane_current_path}"
|
||||
bind -n M-Q kill-pane
|
||||
bind -n M-t run-shell "~/.config/agent-tracker/bin/tracker-client command toggle --client '#{client_tty}'"
|
||||
bind -n M-t run-shell "test -x ~/.config/agent-tracker/bin/tracker-client && ~/.config/agent-tracker/bin/tracker-client command toggle --client '#{client_tty}' || true"
|
||||
bind . command-prompt -p "Rename session to:" "run-shell \"~/.config/tmux/scripts/rename_session_prompt.sh '%%'\""
|
||||
unbind ,
|
||||
bind , command-prompt -p "Rename window:" "rename-window '%%'"
|
||||
|
|
@ -184,8 +184,8 @@ bind -n M-i select-pane -R
|
|||
bind > swap-pane -D
|
||||
bind < swap-pane -U
|
||||
bind | swap-pane
|
||||
bind -n M-m run-shell "bash ~/.config/agent-tracker/scripts/focus_latest_notified.sh"
|
||||
bind -n M-M run-shell "bash ~/.config/agent-tracker/scripts/focus_last_origin.sh"
|
||||
bind -n M-m run-shell "test -f ~/.config/agent-tracker/scripts/focus_latest_notified.sh && bash ~/.config/agent-tracker/scripts/focus_latest_notified.sh || true"
|
||||
bind -n M-M run-shell "test -f ~/.config/agent-tracker/scripts/focus_last_origin.sh && bash ~/.config/agent-tracker/scripts/focus_last_origin.sh || true"
|
||||
bind Space run-shell "~/.config/tmux/scripts/toggle_orientation.sh"
|
||||
|
||||
bind W choose-tree -Z
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
|||
|
||||
F="$HOME/.config/agent-tracker/run/latest_notified.txt"
|
||||
if [[ ! -f "$F" ]]; then
|
||||
exit -1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Read line and split by literal ':::' into sid, wid, pid robustly
|
||||
|
|
@ -25,10 +25,10 @@ if [[ -n "$current" ]]; then
|
|||
printf '%s\n' "$current" > "$RUN_DIR/jump_back.txt"
|
||||
fi
|
||||
|
||||
# Mark as viewed (acknowledged) in tracker
|
||||
# Mark as viewed (acknowledged) in tracker (graceful if unavailable)
|
||||
CLIENT_BIN="$HOME/.config/agent-tracker/bin/tracker-client"
|
||||
if [[ -x "$CLIENT_BIN" ]]; then
|
||||
"$CLIENT_BIN" command -session-id "$sid" -window-id "$wid" -pane "$pid" acknowledge >/dev/null 2>&1 || true
|
||||
"$CLIENT_BIN" command acknowledge -session-id "$sid" -window-id "$wid" -pane "$pid" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# Focus the tmux target
|
||||
|
|
|
|||
|
|
@ -130,8 +130,13 @@ load_tracker_info() {
|
|||
fi
|
||||
|
||||
if [[ -z "$tracker_lines" ]]; then
|
||||
local tracker_bin="$HOME/.config/agent-tracker/bin/tracker-client"
|
||||
if [[ ! -x "$tracker_bin" ]]; then
|
||||
rm -f "$TRACKER_CACHE_FILE" 2>/dev/null || true
|
||||
return
|
||||
fi
|
||||
local tracker_state
|
||||
tracker_state=$(~/.config/agent-tracker/bin/tracker-client state 2>/dev/null || true)
|
||||
tracker_state=$("$tracker_bin" state 2>/dev/null || true)
|
||||
if [[ -z "$tracker_state" ]]; then
|
||||
rm -f "$TRACKER_CACHE_FILE" 2>/dev/null || true
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue