mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-19 21:13:19 -07:00
* 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
This commit is contained in:
parent
42f21f0e34
commit
330435d96a
3 changed files with 33 additions and 8 deletions
9
debian/changelog
vendored
9
debian/changelog
vendored
|
@ -1,6 +1,13 @@
|
||||||
byobu (4.8) unreleased; urgency=low
|
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 <kirkland@ubuntu.com> Sat, 28 May 2011 22:22:35 -0500
|
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 28 May 2011 22:22:35 -0500
|
||||||
|
|
||||||
|
|
|
@ -22,22 +22,31 @@ import commands, os, re, sys
|
||||||
|
|
||||||
PKG = "byobu"
|
PKG = "byobu"
|
||||||
SHELL = os.getenv("SHELL", "/bin/bash")
|
SHELL = os.getenv("SHELL", "/bin/bash")
|
||||||
|
HOME=os.getenv("HOME")
|
||||||
choice = ""
|
choice = ""
|
||||||
sessions = []
|
sessions = []
|
||||||
text = []
|
text = []
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
output = commands.getoutput('screen -ls ')
|
output = commands.getoutput('screen -ls ')
|
||||||
if output:
|
if output:
|
||||||
for s in output.split("\n"):
|
for s in output.split("\n"):
|
||||||
s = re.sub(r'\s+', ' ', s)
|
s = re.sub(r'\s+', ' ', s)
|
||||||
# Ignore hidden sessions (named sessions that start with a ".")
|
# Ignore hidden sessions (named sessions that start with a ".")
|
||||||
if s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0:
|
if s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0:
|
||||||
text.append(s)
|
text.append("Select %s" % s.strip())
|
||||||
items = s.split(" ")
|
items = s.split(" ")
|
||||||
sessions.append(items[1])
|
sessions.append(items[1])
|
||||||
i += 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")
|
sys.stdout.write("\nByobu sessions...\n\n")
|
||||||
tries = 0
|
tries = 0
|
||||||
while tries < 3:
|
while tries < 3:
|
||||||
|
@ -45,8 +54,6 @@ if i > 1:
|
||||||
for s in text:
|
for s in text:
|
||||||
sys.stdout.write(" %d. %s\n" % (i, s))
|
sys.stdout.write(" %d. %s\n" % (i, s))
|
||||||
i += 1
|
i += 1
|
||||||
sys.stdout.write(" %d. Create a new session\n" % i)
|
|
||||||
i += 1
|
|
||||||
try:
|
try:
|
||||||
choice = input("\nChoose 1-%d [1]: " % (i-1))
|
choice = input("\nChoose 1-%d [1]: " % (i-1))
|
||||||
if choice >= 1 and choice < i:
|
if choice >= 1 and choice < i:
|
||||||
|
@ -65,13 +72,15 @@ if i > 1:
|
||||||
tries += 1
|
tries += 1
|
||||||
choice = ""
|
choice = ""
|
||||||
sys.stderr.write("\nERROR: Invalid input\n");
|
sys.stderr.write("\nERROR: Invalid input\n");
|
||||||
elif i == 1:
|
elif len(sessions) == 1:
|
||||||
os.execvp("byobu", ["", "-AOxRR"])
|
os.execvp("byobu", ["", "-AOxRR"])
|
||||||
|
|
||||||
if choice:
|
if choice:
|
||||||
if choice == i-1:
|
if sessions[choice-1] == "NEW":
|
||||||
# Create a new session
|
# Create a new session
|
||||||
os.execvp("byobu", ["", SHELL])
|
os.execvp("byobu", ["", SHELL])
|
||||||
|
elif sessions[choice-1] == "SHELL":
|
||||||
|
os.execvp(SHELL, [SHELL])
|
||||||
else:
|
else:
|
||||||
# Attach to the chosen session; must use the 'screen' binary
|
# Attach to the chosen session; must use the 'screen' binary
|
||||||
os.execvp("screen", ["", "-AOxRR", sessions[choice-1]])
|
os.execvp("screen", ["", "-AOxRR", sessions[choice-1]])
|
||||||
|
|
|
@ -3,11 +3,20 @@
|
||||||
byobu\-select\-session \- select and connect to a byobu session
|
byobu\-select\-session \- select and connect to a byobu session
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.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:
|
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
|
byobu \-S .hidden
|
||||||
|
|
||||||
|
.SH "FILES"
|
||||||
|
\fI$DATA/.always-select\fP
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.PD 0
|
.PD 0
|
||||||
.TP
|
.TP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue