From 72e8630b1d19e0b6d322c13e28afea206aee8014 Mon Sep 17 00:00:00 2001 From: Chow Loong Jin Date: Thu, 5 Oct 2017 13:29:38 +0800 Subject: [PATCH 1/2] Fix cull_zombies() for sessions with non-numeric names --- usr/lib/byobu/include/select-session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/lib/byobu/include/select-session.py b/usr/lib/byobu/include/select-session.py index 78b0ea15..22e7fcc3 100755 --- a/usr/lib/byobu/include/select-session.py +++ b/usr/lib/byobu/include/select-session.py @@ -102,7 +102,7 @@ def cull_zombies(session_name): # Find the master session to extract the group number. We use # the group number to be extra sure the right session is getting # killed. We don't want to accidentally kill the wrong one - pattern = "^%s:.+\\((group \\d+)\\).*$" % session_name + pattern = "^%s:.+\\((group [^\\)]+)\\).*$" % session_name master = re.search(pattern, output, re.MULTILINE) if not master: return From 755c0e9f28b3f8ee57d9c7fc166f0bcbe96577db Mon Sep 17 00:00:00 2001 From: Chow Loong Jin Date: Thu, 5 Oct 2017 13:30:42 +0800 Subject: [PATCH 2/2] Allow disabling of automatic tmux session creation --- usr/lib/byobu/include/select-session.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr/lib/byobu/include/select-session.py b/usr/lib/byobu/include/select-session.py index 22e7fcc3..44192043 100755 --- a/usr/lib/byobu/include/select-session.py +++ b/usr/lib/byobu/include/select-session.py @@ -40,6 +40,7 @@ BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux") choice = -1 sessions = [] text = [] +reuse_sessions = os.path.exists("%s/.reuse-session" % (BYOBU_CONFIG_DIR)) BYOBU_UPDATE_ENVVARS = ["DISPLAY", "DBUS_SESSION_BUS_ADDRESS", "SESSION_MANAGER", "GPG_AGENT_INFO", "XDG_SESSION_COOKIE", "XDG_SESSION_PATH", "GNOME_KEYRING_CONTROL", "GNOME_KEYRING_PID", "GPG_AGENT_INFO", "SSH_ASKPASS", "SSH_AUTH_SOCK", "SSH_AGENT_PID", "WINDOWID", "UPSTART_JOB", "UPSTART_EVENTS", "UPSTART_SESSION", "UPSTART_INSTANCE"] @@ -131,7 +132,11 @@ def attach_session(session): cull_zombies(session_name) # must use the binary, not the wrapper! if backend == "tmux": - os.execvp("tmux", ["tmux", "-2", "new-session", "-t", session_name, "-s", "_%s-%i" % (session_name, os.getpid())]) + if reuse_sessions: + os.execvp("tmux", ["tmux", "attach", "-t", session_name]) + else: + os.execvp("tmux", ["tmux", "-2", "new-session", "-t", session_name, "-s", "_%s-%i" % (session_name, os.getpid())]) + else: os.execvp("screen", ["screen", "-AOxRR", session_name])