Merge pull request #332 from ThePhilderbeast/tmux-reattach

Fix Tmux-autoattach plugin to reattach to a session is there is one
This commit is contained in:
Koichi Murase 2022-06-20 13:59:25 +09:00 committed by GitHub
commit 4ed64bc877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,12 +7,20 @@
[ -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 -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