From fb978ce75e091c4ea7f0c373f6dbca32883ef969 Mon Sep 17 00:00:00 2001 From: Phillip Ledger Date: Wed, 18 May 2022 19:21:59 +1000 Subject: [PATCH 1/2] plugins/tmux-autoattach: Automatically attach to session 0 by default this corrects the plugin not connecting back to the session by default --- plugins/tmux-autoattach/tmux-autoattach.plugin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh index 34224c4..6b8c73d 100644 --- a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh +++ b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh @@ -8,11 +8,11 @@ [ -z "$OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR" ] && OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR="detach" _osh_plugin_tmux_autoattach_exit() { - [ -z "$TMUX" ] && tmux -2u new -A && exit + [ -z "$TMUX" ] && tmux -2u new -As0 && exit } _osh_plugin_tmux_autoattach_detach() { - [ -z "$TMUX" ] && tmux -2u new -A + [ -z "$TMUX" ] && tmux -2u new -As0 } case "$OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR" in From cb3d338a0e28b826a6ba453ecbd12f65e26b6cbb Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 20 Jun 2022 13:50:09 +0900 Subject: [PATCH 2/2] plugins/tmux-autoattach: Add memorandum about the background of option "-s0" --- plugins/tmux-autoattach/tmux-autoattach.plugin.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh index 6b8c73d..42770ef 100644 --- a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh +++ b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh @@ -7,6 +7,14 @@ [ -z "$OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR" ] && OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR="detach" +# Note on the option "-As0": tmux-3.0a and before does not attach to a session +# as far as the session name is not given by "-s SESSION_NAME" [1]. From +# tmux-3.1, it attaches to an existing session, if any, without specifying the +# session. Here, we assume the session name to be "0", which is the default +# name for the first session. +# +# [1] https://github.com/ohmybash/oh-my-bash/pull/332 + _osh_plugin_tmux_autoattach_exit() { [ -z "$TMUX" ] && tmux -2u new -As0 && exit }