mirror of
https://github.com/theniceboy/.config.git
synced 2025-12-26 14:44:57 +08:00
update agent notifier
This commit is contained in:
parent
5c134ba422
commit
06dea5e863
4 changed files with 114 additions and 0 deletions
18
agent-tracker/scripts/focus_last_origin.sh
Normal file
18
agent-tracker/scripts/focus_last_origin.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
F="$HOME/.config/agent-tracker/run/jump_back.txt"
|
||||
if [[ ! -f "$F" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sid=$(awk -F ':::' 'NR==1{print $1}' "$F" | tr -d '\r\n')
|
||||
wid=$(awk -F ':::' 'NR==1{print $2}' "$F" | tr -d '\r\n')
|
||||
pid=$(awk -F ':::' 'NR==1{print $3}' "$F" | tr -d '\r\n')
|
||||
|
||||
if [[ -z "${sid:-}" || -z "${wid:-}" || -z "${pid:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$sid" \; select-window -t "$wid" \; select-pane -t "$pid"
|
||||
|
||||
35
agent-tracker/scripts/focus_latest_notified.sh
Normal file
35
agent-tracker/scripts/focus_latest_notified.sh
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
F="$HOME/.config/agent-tracker/run/latest_notified.txt"
|
||||
if [[ ! -f "$F" ]]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Read line and split by literal ':::' into sid, wid, pid robustly
|
||||
# Extract fields robustly using awk with a literal ':::' separator
|
||||
sid=$(awk -F ':::' 'NR==1{print $1}' "$F" | tr -d '\r\n')
|
||||
wid=$(awk -F ':::' 'NR==1{print $2}' "$F" | tr -d '\r\n')
|
||||
pid=$(awk -F ':::' 'NR==1{print $3}' "$F" | tr -d '\r\n')
|
||||
|
||||
if [[ -z "${sid:-}" || -z "${wid:-}" || -z "${pid:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RUN_DIR="$HOME/.config/agent-tracker/run"
|
||||
mkdir -p "$RUN_DIR"
|
||||
|
||||
# Record current location for jump-back
|
||||
current=$(tmux display-message -p "#{session_id}:::#{window_id}:::#{pane_id}" | tr -d '\r\n')
|
||||
if [[ -n "$current" ]]; then
|
||||
printf '%s\n' "$current" > "$RUN_DIR/jump_back.txt"
|
||||
fi
|
||||
|
||||
# Mark as viewed (acknowledged) in tracker
|
||||
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
|
||||
fi
|
||||
|
||||
# Focus the tmux target
|
||||
tmux switch-client -t "$sid" \; select-window -t "$wid" \; select-pane -t "$pid"
|
||||
Loading…
Add table
Add a link
Reference in a new issue