mirror of
https://github.com/theniceboy/.config.git
synced 2025-12-26 14:44: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 -gu client-attached
|
||||||
# set-hook -g client-attached 'run -b "cut -c3- ~/.tmux.conf | sh -s update_env_event"'
|
# 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
|
# Acknowledge the current pane's task when a client attaches (graceful if tracker unavailable)
|
||||||
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}"'
|
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 -ag client-attached 'run -b "tmux refresh-client -S"'
|
||||||
|
|
||||||
# set-hook -gu client-resized
|
# 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 "~/.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 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-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 "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 "~/.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 note_archive_pane --client #{client_tty} --session-id #{session_id} --window-id #{window_id} --pane #{pane_id} || true"'
|
||||||
|
|
||||||
# -- Project-specific window activation hooks
|
# -- Project-specific window activation hooks
|
||||||
# Checks for ./on-tmux-window-activate.sh or ../on-tmux-window-activate.sh and runs it
|
# 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
|
# window management
|
||||||
bind -n M-o new-window -c "#{pane_current_path}"
|
bind -n M-o new-window -c "#{pane_current_path}"
|
||||||
bind -n M-Q kill-pane
|
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 '%%'\""
|
bind . command-prompt -p "Rename session to:" "run-shell \"~/.config/tmux/scripts/rename_session_prompt.sh '%%'\""
|
||||||
unbind ,
|
unbind ,
|
||||||
bind , command-prompt -p "Rename window:" "rename-window '%%'"
|
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 -D
|
||||||
bind < swap-pane -U
|
bind < swap-pane -U
|
||||||
bind | swap-pane
|
bind | swap-pane
|
||||||
bind -n M-m run-shell "bash ~/.config/agent-tracker/scripts/focus_latest_notified.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 "bash ~/.config/agent-tracker/scripts/focus_last_origin.sh"
|
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 Space run-shell "~/.config/tmux/scripts/toggle_orientation.sh"
|
||||||
|
|
||||||
bind W choose-tree -Z
|
bind W choose-tree -Z
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
||||||
|
|
||||||
F="$HOME/.config/agent-tracker/run/latest_notified.txt"
|
F="$HOME/.config/agent-tracker/run/latest_notified.txt"
|
||||||
if [[ ! -f "$F" ]]; then
|
if [[ ! -f "$F" ]]; then
|
||||||
exit -1
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Read line and split by literal ':::' into sid, wid, pid robustly
|
# 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"
|
printf '%s\n' "$current" > "$RUN_DIR/jump_back.txt"
|
||||||
fi
|
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"
|
CLIENT_BIN="$HOME/.config/agent-tracker/bin/tracker-client"
|
||||||
if [[ -x "$CLIENT_BIN" ]]; then
|
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
|
fi
|
||||||
|
|
||||||
# Focus the tmux target
|
# Focus the tmux target
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,13 @@ load_tracker_info() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$tracker_lines" ]]; then
|
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
|
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
|
if [[ -z "$tracker_state" ]]; then
|
||||||
rm -f "$TRACKER_CACHE_FILE" 2>/dev/null || true
|
rm -f "$TRACKER_CACHE_FILE" 2>/dev/null || true
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue