diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-29 10:01:10 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-29 10:01:10 +0300 |
| commit | cab9ae5285a140fab9f4341a8e20eb24b08adca5 (patch) | |
| tree | 26026dd67d9e8631c5574d5ae4c907d06218371d | |
| parent | 35d14d683cc2bab8303443050e62f1b2fa3c7680 (diff) | |
feat: prioritize agent-labeled tmux sessions when attaching
| -rw-r--r-- | fish/conf.d/tmux.fish | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/fish/conf.d/tmux.fish b/fish/conf.d/tmux.fish index 4d77b07..c1831b6 100644 --- a/fish/conf.d/tmux.fish +++ b/fish/conf.d/tmux.fish @@ -71,13 +71,23 @@ function tmux::attach return 1 end tmux attach-session || tmux::new - else - if test -n "$TMUX" - tmux switch-client -t "=$session" 2>/dev/null; or tmux::new $session $dir - else - tmux attach-session -t "=$session" 2>/dev/null; or tmux::new $session $dir + return + end + + # Prefer attaching to an agent-labeled session if one exists. + # Never create A-prefixed sessions via shortcuts; only prioritize them. + for prefixed in "A-$session" "A$session" + if tmux has-session -t "=$prefixed" 2>/dev/null + set session $prefixed + break end end + + if test -n "$TMUX" + tmux switch-client -t "=$session" 2>/dev/null; or tmux::new $session $dir + else + tmux attach-session -t "=$session" 2>/dev/null; or tmux::new $session $dir + end end function tmux::remote |
