From 330435d96a6439eebc54f08dc334c244fb38cef7 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 1 Jun 2011 09:22:00 -0500 Subject: [PATCH] * usr/bin/byobu-select-session: - add an option to select-session for running a shell without byobu * usr/bin/byobu-select-session, usr/share/man/man1/byobu-select- session.1: - updated to document the .always-select configuration --- debian/changelog | 9 ++++++++- usr/bin/byobu-select-session | 21 +++++++++++++++------ usr/share/man/man1/byobu-select-session.1 | 11 ++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 683030ab..b04c77fc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,13 @@ byobu (4.8) unreleased; urgency=low - * UNRELEASED + [ Scott Moser and Dustin Kirkland ] + * usr/bin/byobu-select-session: + - add an option to select-session for running a shell without byobu + + [ Dustin Kirkland ] + * usr/bin/byobu-select-session, usr/share/man/man1/byobu-select- + session.1: + - updated to document the .always-select configuration -- Dustin Kirkland Sat, 28 May 2011 22:22:35 -0500 diff --git a/usr/bin/byobu-select-session b/usr/bin/byobu-select-session index bdde2507..500502c0 100755 --- a/usr/bin/byobu-select-session +++ b/usr/bin/byobu-select-session @@ -22,22 +22,31 @@ import commands, os, re, sys PKG = "byobu" SHELL = os.getenv("SHELL", "/bin/bash") +HOME=os.getenv("HOME") choice = "" sessions = [] text = [] i = 0 + output = commands.getoutput('screen -ls ') if output: for s in output.split("\n"): s = re.sub(r'\s+', ' ', s) # Ignore hidden sessions (named sessions that start with a ".") if s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0: - text.append(s) + text.append("Select %s" % s.strip()) items = s.split(" ") sessions.append(items[1]) i += 1 -if i > 1: +show_shell = os.path.exists("%s/.%s/.always-select" % (HOME, PKG)) +if i>1 or show_shell: + sessions.append("NEW") + text.append("Create a new Byobu session") + sessions.append("SHELL") + text.append("Run a shell without Byobu (%s)" % SHELL) + +if len(sessions) > 1: sys.stdout.write("\nByobu sessions...\n\n") tries = 0 while tries < 3: @@ -45,8 +54,6 @@ if i > 1: for s in text: sys.stdout.write(" %d. %s\n" % (i, s)) i += 1 - sys.stdout.write(" %d. Create a new session\n" % i) - i += 1 try: choice = input("\nChoose 1-%d [1]: " % (i-1)) if choice >= 1 and choice < i: @@ -65,13 +72,15 @@ if i > 1: tries += 1 choice = "" sys.stderr.write("\nERROR: Invalid input\n"); -elif i == 1: +elif len(sessions) == 1: os.execvp("byobu", ["", "-AOxRR"]) if choice: - if choice == i-1: + if sessions[choice-1] == "NEW": # Create a new session os.execvp("byobu", ["", SHELL]) + elif sessions[choice-1] == "SHELL": + os.execvp(SHELL, [SHELL]) else: # Attach to the chosen session; must use the 'screen' binary os.execvp("screen", ["", "-AOxRR", sessions[choice-1]]) diff --git a/usr/share/man/man1/byobu-select-session.1 b/usr/share/man/man1/byobu-select-session.1 index 2a2cbca6..e485e2c7 100644 --- a/usr/share/man/man1/byobu-select-session.1 +++ b/usr/share/man/man1/byobu-select-session.1 @@ -3,11 +3,20 @@ byobu\-select\-session \- select and connect to a byobu session .SH DESCRIPTION -\fBbyobu\-select\-session\fP is an application that lists the available screen sessions running on the system, and prompts the user to select one. If an invalid selection is chosen 3 times in a row, the user is connected to the youngest session. If only one session exists, the user is connected to that session. If no sessions exist, a new session is created. +\fBbyobu\-select\-session\fP is an application that lists the available screen sessions running on the system, and prompts the user to select one. The user also has the option to create a new Byobu session, or launch the default shell without Byobu. + +If an invalid selection is chosen 3 times in a row, the user is connected to the youngest session. + +By default, if only one session exists, the user is connected to that session, and if no sessions exist, a new session is created -- such that there is no interactive prompt in the normal behavior. However, some users may choose to always be prompted, by touching the file $DATA/.always-select. + +Note that DATA=$HOME/.byobu. Named sessions that begin with a "." are "hidden" from \fBbyobu\-select\-session\fP(1). This is useful, for instance, if you do not want a session to be automatically selected at login. Example: byobu \-S .hidden +.SH "FILES" +\fI$DATA/.always-select\fP + .SH "SEE ALSO" .PD 0 .TP