summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fish/conf.d/tmux.fish20
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