mirror of
https://github.com/theniceboy/.config.git
synced 2026-02-22 12:55:39 +08:00
add M-b hotkey to toggle manual unread bell on tmux windows
This commit is contained in:
parent
a97e3a5e20
commit
4a5044a949
3 changed files with 18 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ set-hook -ag client-attached 'run -b "tmux refresh-client -S"'
|
||||||
set-hook -gu pane-focus-in
|
set-hook -gu pane-focus-in
|
||||||
set-hook -g pane-focus-in "run -b 'bash ~/.config/tmux/fzf_panes.tmux update_mru_pane_ids'"
|
set-hook -g pane-focus-in "run -b 'bash ~/.config/tmux/fzf_panes.tmux update_mru_pane_ids'"
|
||||||
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 "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 set -wu -t #{window_id} @unread 2>/dev/null || 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 -gu pane-died
|
set-hook -gu pane-died
|
||||||
|
|
@ -185,6 +186,7 @@ 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-b run-shell 'val=$(tmux show -wv @unread 2>/dev/null); if [ "$val" = "1" ]; then tmux set -wu @unread; else tmux set -w @unread 1; fi; tmux refresh-client -S'
|
||||||
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_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 -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"
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,15 @@ fi
|
||||||
|
|
||||||
get_session_icon() {
|
get_session_icon() {
|
||||||
local sid="$1"
|
local sid="$1"
|
||||||
|
|
||||||
|
# Check for manual @unread on any window in this session
|
||||||
|
local unread_win
|
||||||
|
unread_win=$(tmux list-windows -t "$sid" -F '#{@unread}' 2>/dev/null | grep -m1 '^1$' || true)
|
||||||
|
if [[ -n "$unread_win" ]]; then
|
||||||
|
printf '🔔'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -z "$tracker_state" ]] && return
|
[[ -z "$tracker_state" ]] && return
|
||||||
local result
|
local result
|
||||||
result=$(echo "$tracker_state" | jq -r --arg sid "$sid" '
|
result=$(echo "$tracker_state" | jq -r --arg sid "$sid" '
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ set -euo pipefail
|
||||||
window_id="$1"
|
window_id="$1"
|
||||||
[[ -z "$window_id" ]] && exit 0
|
[[ -z "$window_id" ]] && exit 0
|
||||||
|
|
||||||
|
# Check manual @unread flag
|
||||||
|
unread=$(tmux show -wv -t "$window_id" @unread 2>/dev/null || true)
|
||||||
|
if [[ "$unread" == "1" ]]; then
|
||||||
|
printf '🔔'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
CACHE_FILE="/tmp/tmux-tracker-cache.json"
|
CACHE_FILE="/tmp/tmux-tracker-cache.json"
|
||||||
[[ ! -f "$CACHE_FILE" ]] && exit 0
|
[[ ! -f "$CACHE_FILE" ]] && exit 0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue