mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
* usr/bin/byobu-select-session:
- save a few forks, use regexes for screen -ls processing - fix select-session code, LP: #602750
This commit is contained in:
parent
c8b9ec0266
commit
bbdc1e831a
2 changed files with 19 additions and 14 deletions
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -1,6 +1,8 @@
|
||||||
byobu (2.82) unreleased; urgency=low
|
byobu (2.82) unreleased; urgency=low
|
||||||
|
|
||||||
* UNRELEASED
|
* usr/bin/byobu-select-session:
|
||||||
|
- save a few forks, use regexes for screen -ls processing
|
||||||
|
- fix select-session code, LP: #602750
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 02 Jul 2010 10:02:18 -0500
|
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 02 Jul 2010 10:02:18 -0500
|
||||||
|
|
||||||
|
|
|
@ -18,27 +18,30 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import commands, os, sys
|
import commands, os, re, sys
|
||||||
|
|
||||||
PKG = "byobu"
|
PKG = "byobu"
|
||||||
SHELL = os.getenv("SHELL", "/bin/bash")
|
SHELL = os.getenv("SHELL", "/bin/bash")
|
||||||
sessions = []
|
|
||||||
choice = ""
|
choice = ""
|
||||||
sessions.append(0)
|
sessions = []
|
||||||
|
text = []
|
||||||
i = 0
|
i = 0
|
||||||
output = commands.getoutput('screen -ls "' + PKG + '" | sed "s/\s\+/ /g" | grep "^\s"')
|
output = commands.getoutput('screen -ls ' + PKG)
|
||||||
if output:
|
if output:
|
||||||
for s in output.split("\n"):
|
for s in output.split("\n"):
|
||||||
items = s.split(" ")
|
s = re.sub(r'\s+', ' ', s)
|
||||||
sessions.append(items[1])
|
if s.find(" ") == 0 and len(s) > 1:
|
||||||
i += 1
|
text.append(s)
|
||||||
|
items = s.split(" ")
|
||||||
|
sessions.append(items[1])
|
||||||
|
i += 1
|
||||||
|
|
||||||
if i > 1:
|
if i > 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:
|
||||||
i = 1
|
i = 1
|
||||||
for s in output.split("\n"):
|
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)
|
sys.stdout.write(" %d. Create a new session\n" % i)
|
||||||
|
@ -64,8 +67,8 @@ if choice:
|
||||||
# Create a new session
|
# Create a new session
|
||||||
os.execv("/usr/bin/byobu", ["", SHELL])
|
os.execv("/usr/bin/byobu", ["", SHELL])
|
||||||
else:
|
else:
|
||||||
# Attach to the chosen session
|
# Attach to the chosen session; must use the 'screen' binary
|
||||||
os.execv("/usr/bin/byobu", ["", "-AOxRR", sessions[choice]])
|
os.execv("/usr/bin/screen", ["", "-AOxRR", sessions[choice-1]])
|
||||||
else:
|
|
||||||
# No valid selection, default to the youngest session
|
# No valid selection, default to the youngest session, create if necessary
|
||||||
os.execv("/usr/bin/byobu", ["", "-AOxRR"])
|
os.execv("/usr/bin/byobu", ["", "-AOxRR"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue