mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* debian/control, debian/rules, usr/bin/byobu-config, usr/bin/byobu-
select-session: LP: #1043048 - get our python code pep8 compliant + except use tabs instead of spaces, and allow lines longer than 80 characters - this should get byobu's python code working better with python3
This commit is contained in:
parent
6b13802d71
commit
f541a82be9
5 changed files with 322 additions and 275 deletions
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -27,6 +27,12 @@ byobu (5.23) unreleased; urgency=low
|
|||
- simplify, removing detail
|
||||
* usr/lib/byobu/distro, usr/lib/byobu/logo: LP: #1094716
|
||||
- try to improve logo printing and distro detection on Mac
|
||||
* debian/control, debian/rules, usr/bin/byobu-config, usr/bin/byobu-
|
||||
select-session: LP: #1043048
|
||||
- get our python code pep8 compliant
|
||||
+ except use tabs instead of spaces, and allow lines longer than
|
||||
80 characters
|
||||
- this should get byobu's python code working better with python3
|
||||
|
||||
[ Dustin Kirkland and Philip Muškovac ]
|
||||
* usr/lib/byobu/battery: LP: #1090831
|
||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -5,7 +5,7 @@ Maintainer: Dustin Kirkland <kirkland@ubuntu.com>
|
|||
DM-Upload-Allowed: yes
|
||||
Uploaders: Antoine Beaupré <anarcat@koumbit.org>
|
||||
Standards-Version: 3.9.3
|
||||
Build-Depends: debhelper (>= 7.0.50~), gettext-base, automake, autoconf
|
||||
Build-Depends: debhelper (>= 7.0.50~), gettext-base, automake, autoconf, pep8
|
||||
Homepage: http://byobu.co
|
||||
Vcs-Bzr: http://bazaar.launchpad.net/~kirkland/byobu/trunk
|
||||
|
||||
|
|
5
debian/rules
vendored
5
debian/rules
vendored
|
@ -2,6 +2,11 @@
|
|||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
# Check syntax
|
||||
pep8 --verbose --repeat --ignore W191,E501 usr/bin/byobu-config usr/bin/byobu-select-session
|
||||
dh_auto_build
|
||||
|
||||
override_dh_perl:
|
||||
dh_perl -d
|
||||
|
||||
|
|
|
@ -21,28 +21,35 @@
|
|||
# If you change any strings, please generate localization information with:
|
||||
# ./debian/rules get-po
|
||||
|
||||
|
||||
import sys, os, os.path, time, string, commands, gettext, glob, snack
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
import string
|
||||
import commands
|
||||
import gettext
|
||||
import glob
|
||||
import snack
|
||||
from ConfigParser import SafeConfigParser
|
||||
from snack import *
|
||||
|
||||
PKG="byobu"
|
||||
HOME=os.getenv("HOME")
|
||||
USER=os.getenv("USER")
|
||||
BYOBU_CONFIG_DIR=os.getenv("BYOBU_CONFIG_DIR", HOME+"/.byobu")
|
||||
BYOBU_BACKEND=os.getenv("BYOBU_BACKEND", "tmux")
|
||||
BYOBU_SOCKETDIR=os.getenv("SOCKETDIR", "/var/run/screen")
|
||||
PKG = "byobu"
|
||||
HOME = os.getenv("HOME")
|
||||
USER = os.getenv("USER")
|
||||
BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu")
|
||||
BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux")
|
||||
BYOBU_SOCKETDIR = os.getenv("SOCKETDIR", "/var/run/screen")
|
||||
BYOBU_PREFIX = os.getenv("BYOBU_PREFIX", "/usr")
|
||||
SHARE=BYOBU_PREFIX+'/share/'+PKG
|
||||
DOC=BYOBU_PREFIX+'/share/doc/'+PKG
|
||||
SHARE = BYOBU_PREFIX + '/share/' + PKG
|
||||
DOC = BYOBU_PREFIX + '/share/doc/' + PKG
|
||||
if not os.path.exists(SHARE):
|
||||
SHARE = BYOBU_CONFIG_DIR+"/"+SHARE
|
||||
SHARE = BYOBU_CONFIG_DIR + "/" + SHARE
|
||||
if not os.path.exists(DOC):
|
||||
DOC = BYOBU_CONFIG_DIR+"/"+DOC
|
||||
DEF_ESC="A"
|
||||
DOC = BYOBU_CONFIG_DIR + "/" + DOC
|
||||
DEF_ESC = "A"
|
||||
RELOAD = "If you are using the default set of keybindings, press\n<F5> or <ctrl-a-R> to activate these changes.\n\nOtherwise, exit this session and start a new one."
|
||||
RELOAD_FLAG="%s/reload-required" % (BYOBU_CONFIG_DIR)
|
||||
RELOAD_CMD="%s -X at 0 source %s/profile" % (BYOBU_BACKEND, BYOBU_CONFIG_DIR)
|
||||
RELOAD_FLAG = "%s/reload-required" % (BYOBU_CONFIG_DIR)
|
||||
RELOAD_CMD = "%s -X at 0 source %s/profile" % (BYOBU_BACKEND, BYOBU_CONFIG_DIR)
|
||||
ESC = ''
|
||||
snack.hotkeys[ESC] = ord(ESC)
|
||||
snack.hotkeys[ord(ESC)] = ESC
|
||||
|
@ -50,91 +57,106 @@ if commands.getstatusoutput('which gsed')[0] == 0:
|
|||
BYOBU_SED = "gsed"
|
||||
else:
|
||||
BYOBU_SED = "sed"
|
||||
gettext.bindtextdomain(PKG, SHARE+'/po')
|
||||
gettext.bindtextdomain(PKG, SHARE + '/po')
|
||||
gettext.textdomain(PKG)
|
||||
_ = gettext.gettext
|
||||
|
||||
def ioctl_GWINSZ(fd): #### TABULATION FUNCTIONS
|
||||
try: ### Discover terminal width
|
||||
import fcntl, termios, struct, os
|
||||
|
||||
def ioctl_GWINSZ(fd):
|
||||
# Discover terminal width
|
||||
try:
|
||||
import fcntl
|
||||
import termios
|
||||
import struct
|
||||
import os
|
||||
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
|
||||
except:
|
||||
return None
|
||||
return cr
|
||||
|
||||
|
||||
def reload_required():
|
||||
try:
|
||||
if not os.path.exists(BYOBU_CONFIG_DIR):
|
||||
os.makedirs(BYOBU_CONFIG_DIR, 0755)
|
||||
f = open(RELOAD_FLAG,'w')
|
||||
f = open(RELOAD_FLAG, 'w')
|
||||
f.close()
|
||||
commands.getoutput(RELOAD_CMD)
|
||||
except:
|
||||
True
|
||||
|
||||
def terminal_size(): ### decide on *some* terminal size
|
||||
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) # try open fds
|
||||
if not cr: # ...then ctty
|
||||
|
||||
def terminal_size():
|
||||
# decide on some terminal size
|
||||
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
|
||||
# try open fds
|
||||
if not cr:
|
||||
# ...then ctty
|
||||
try:
|
||||
fd = os.open(os.ctermid(), os.O_RDONLY)
|
||||
cr = ioctl_GWINSZ(fd)
|
||||
os.close(fd)
|
||||
except:
|
||||
pass
|
||||
if not cr: # env vars or finally defaults
|
||||
if not cr:
|
||||
# env vars or finally defaults
|
||||
try:
|
||||
cr = (env['LINES'], env['COLUMNS'])
|
||||
except:
|
||||
cr = (25, 80)
|
||||
return int(cr[1]-5), int(cr[0]-5) # reverse rows, cols
|
||||
# reverse rows, cols
|
||||
return int(cr[1] - 5), int(cr[0] - 5)
|
||||
|
||||
|
||||
def menu(snackScreen, size, isInstalled):
|
||||
if isInstalled:
|
||||
installtext=_("Byobu currently launches at login (toggle off)")
|
||||
installtext = _("Byobu currently launches at login (toggle off)")
|
||||
else:
|
||||
installtext=_("Byobu currently does not launch at login (toggle on)")
|
||||
li = Listbox(height = 6, width = 60, returnExit = 1)
|
||||
installtext = _("Byobu currently does not launch at login (toggle on)")
|
||||
li = Listbox(height=6, width=60, returnExit=1)
|
||||
li.append(_("Help -- Quick Start Guide"), 1)
|
||||
li.append(_("Toggle status notifications"), 2)
|
||||
li.append(_("Change escape sequence"), 3)
|
||||
li.append(installtext, 4)
|
||||
bb = ButtonBar(snackScreen, (("Exit", "exit", ESC),), compact=1)
|
||||
g = GridForm(snackScreen, _(" Byobu Configuration Menu"), 1, 2)
|
||||
g.add(li, 0, 0, padding=(4,2,4,2))
|
||||
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||
g.add(li, 0, 0, padding=(4, 2, 4, 2))
|
||||
g.add(bb, 0, 1, padding=(1, 1, 0, 0))
|
||||
if bb.buttonPressed(g.runOnce()) == "exit":
|
||||
return 0
|
||||
else:
|
||||
return li.current()
|
||||
|
||||
def messagebox(snackScreen, width, height, title, text, scroll=0, \
|
||||
buttons=((_("Okay"), "okay"),(_("Cancel"), "cancel", ESC)) ):
|
||||
t = Textbox(width, height, text, scroll=scroll )
|
||||
bb = ButtonBar(snackScreen, buttons, compact = 1)
|
||||
|
||||
def messagebox(snackScreen, width, height, title, text, scroll=0, buttons=((_("Okay"), "okay"), (_("Cancel"), "cancel", ESC))):
|
||||
t = Textbox(width, height, text, scroll=scroll)
|
||||
bb = ButtonBar(snackScreen, buttons, compact=1)
|
||||
g = GridForm(snackScreen, title, 1, 2)
|
||||
g.add(t, 0, 0, padding=(0,0,0,0))
|
||||
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||
g.add(t, 0, 0, padding=(0, 0, 0, 0))
|
||||
g.add(bb, 0, 1, padding=(1, 1, 0, 0))
|
||||
return bb.buttonPressed(g.runOnce())
|
||||
|
||||
|
||||
def help(snackScreen, size, config):
|
||||
f=file(DOC+'/help.'+BYOBU_BACKEND+'.txt')
|
||||
text=f.read()
|
||||
f = file(DOC + '/help.' + BYOBU_BACKEND + '.txt')
|
||||
text = f.read()
|
||||
f.close()
|
||||
text=text.replace("<esckey>", getesckey(), 1)
|
||||
text=text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | " + BYOBU_SED + " 's/.* //'"), 1)
|
||||
text = text.replace("<esckey>", getesckey(), 1)
|
||||
text = text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | " + BYOBU_SED + " 's/.* //'"), 1)
|
||||
t = Textbox(67, 16, text, scroll=1, wrap=1)
|
||||
bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact = 1)
|
||||
bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1)
|
||||
g = GridForm(snackScreen, _("Byobu Help"), 2, 4)
|
||||
g.add(t, 1, 0)
|
||||
g.add(bb, 1, 1, padding=(1,1,0,0))
|
||||
g.add(bb, 1, 1, padding=(1, 1, 0, 0))
|
||||
button = bb.buttonPressed(g.runOnce())
|
||||
return 100
|
||||
|
||||
|
||||
def readstatus():
|
||||
status={}
|
||||
status = {}
|
||||
glo = {}
|
||||
loc = {}
|
||||
for f in [SHARE+'/status/status', BYOBU_CONFIG_DIR+'/status']:
|
||||
for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']:
|
||||
if os.path.exists(f):
|
||||
try:
|
||||
execfile(f, glo, loc)
|
||||
|
@ -150,19 +172,20 @@ def readstatus():
|
|||
status[i] = "0"
|
||||
else:
|
||||
status[i] = "1"
|
||||
li=[]
|
||||
li = []
|
||||
keys = status.keys()
|
||||
keys.sort()
|
||||
for i in keys:
|
||||
window=[int(status[i]), i]
|
||||
window = [int(status[i]), i]
|
||||
li.append(window)
|
||||
return li
|
||||
|
||||
|
||||
def genstatusstring(s, status):
|
||||
new = ""
|
||||
glo = {}
|
||||
loc = {}
|
||||
execfile(SHARE+'/status/status', glo, loc)
|
||||
execfile(SHARE + '/status/status', glo, loc)
|
||||
for i in loc[s].split():
|
||||
if i.startswith("#"):
|
||||
i = i.replace("#", "")
|
||||
|
@ -172,9 +195,10 @@ def genstatusstring(s, status):
|
|||
new += " #" + i
|
||||
return new
|
||||
|
||||
|
||||
def writestatus(items):
|
||||
status={}
|
||||
path = BYOBU_CONFIG_DIR+'/status'
|
||||
status = {}
|
||||
path = BYOBU_CONFIG_DIR + '/status'
|
||||
for i in items:
|
||||
status[i[1]] = i[0]
|
||||
# BYOBU_SED is hacky here, but effective
|
||||
|
@ -189,30 +213,32 @@ def writestatus(items):
|
|||
commands.getoutput("%s -i -e '/^%s=/d' %s" % (BYOBU_SED, key, path))
|
||||
commands.getoutput("echo '%s=\"%s\"' >> %s" % (key, val, path))
|
||||
|
||||
|
||||
def togglestatus(snackScreen, size):
|
||||
itemlist=readstatus()
|
||||
rl=Label("")
|
||||
r=CheckboxTree(12, scroll=1)
|
||||
count=0
|
||||
itemlist = readstatus()
|
||||
rl = Label("")
|
||||
r = CheckboxTree(12, scroll=1)
|
||||
count = 0
|
||||
for item in itemlist:
|
||||
if item[0] != -1:
|
||||
r.append(item[1],count,selected=item[0])
|
||||
count=count+1
|
||||
bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1)
|
||||
g = GridForm(snackScreen, _("Toggle status notifications"), 2, 4 )
|
||||
g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4,0,0,1))
|
||||
r.append(item[1], count, selected=item[0])
|
||||
count = count + 1
|
||||
bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1)
|
||||
g = GridForm(snackScreen, _("Toggle status notifications"), 2, 4)
|
||||
g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4, 0, 0, 1))
|
||||
g.add(r, 1, 0)
|
||||
g.add(bb, 1, 1, padding=(4,1,0,0))
|
||||
g.add(bb, 1, 1, padding=(4, 1, 0, 0))
|
||||
if bb.buttonPressed(g.runOnce()) != "cancel":
|
||||
count=0
|
||||
count = 0
|
||||
for item in itemlist:
|
||||
if item[0] != -1:
|
||||
item[0] = r.getEntryValue(count)[1]
|
||||
count=count+1
|
||||
count = count + 1
|
||||
writestatus(itemlist)
|
||||
reload_required()
|
||||
return 100
|
||||
|
||||
|
||||
def install(snackScreen, size, isInstalled):
|
||||
if isInstalled:
|
||||
out = commands.getoutput("byobu-launcher-uninstall")
|
||||
|
@ -227,6 +253,7 @@ def install(snackScreen, size, isInstalled):
|
|||
button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), )))
|
||||
return 100
|
||||
|
||||
|
||||
def appendtofile(p, s):
|
||||
f = open(p, 'a')
|
||||
try:
|
||||
|
@ -237,40 +264,43 @@ def appendtofile(p, s):
|
|||
f.close()
|
||||
return
|
||||
|
||||
|
||||
def getesckey():
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
path=BYOBU_CONFIG_DIR+'/keybindings.tmux'
|
||||
line = commands.getoutput("grep '^set -g prefix ' "+path)
|
||||
path = BYOBU_CONFIG_DIR + '/keybindings.tmux'
|
||||
line = commands.getoutput("grep '^set -g prefix ' " + path)
|
||||
else:
|
||||
path=BYOBU_CONFIG_DIR+'/keybindings'
|
||||
line = commands.getoutput("grep ^escape "+path)
|
||||
path = BYOBU_CONFIG_DIR + '/keybindings'
|
||||
line = commands.getoutput("grep ^escape " + path)
|
||||
if not os.path.exists(path):
|
||||
return DEF_ESC
|
||||
if line == "":
|
||||
return DEF_ESC
|
||||
esc = line[line.find('^')+1]
|
||||
esc = line[line.find('^') + 1]
|
||||
if esc == "`":
|
||||
esc = " "
|
||||
return esc
|
||||
|
||||
|
||||
def setesckey(key):
|
||||
if key.isalpha():
|
||||
out = commands.getoutput("byobu-ctrl-a screen %s" % key)
|
||||
|
||||
|
||||
def chgesc(snackScreen, size):
|
||||
esc=Entry(2, text=getesckey(), returnExit=1)
|
||||
escl=Label(_("Escape key: ctrl-"))
|
||||
bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1)
|
||||
g = GridForm(snackScreen, _("Change escape sequence"), 2, 4 )
|
||||
g.add(escl, 0, 0, anchorLeft=1, padding=(1,0,0,1))
|
||||
esc = Entry(2, text=getesckey(), returnExit=1)
|
||||
escl = Label(_("Escape key: ctrl-"))
|
||||
bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1)
|
||||
g = GridForm(snackScreen, _("Change escape sequence"), 2, 4)
|
||||
g.add(escl, 0, 0, anchorLeft=1, padding=(1, 0, 0, 1))
|
||||
g.add(esc, 1, 0, anchorLeft=1)
|
||||
g.add(bb, 1, 1)
|
||||
g.setTimer(100)
|
||||
loop=1
|
||||
loop = 1
|
||||
while loop:
|
||||
which=g.run()
|
||||
which = g.run()
|
||||
if which == "TIMER":
|
||||
val=esc.value()
|
||||
val = esc.value()
|
||||
if len(val) > 1:
|
||||
esc.set(val[1])
|
||||
# Ensure that escape sequence is not \ or /
|
||||
|
@ -284,7 +314,7 @@ def chgesc(snackScreen, size):
|
|||
# do nothing
|
||||
dummy = "foo"
|
||||
else:
|
||||
loop=0
|
||||
loop = 0
|
||||
snackScreen.popWindow()
|
||||
button = bb.buttonPressed(which)
|
||||
if button != "cancel":
|
||||
|
@ -294,8 +324,9 @@ def chgesc(snackScreen, size):
|
|||
return 0
|
||||
return 100
|
||||
|
||||
|
||||
def autolaunch():
|
||||
if os.path.exists(BYOBU_CONFIG_DIR+"/disable-autolaunch"):
|
||||
if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"):
|
||||
return 0
|
||||
if commands.getstatusoutput('grep -qs byobu-launch %s/.profile' % HOME)[0] == 0:
|
||||
return 1
|
||||
|
@ -305,16 +336,15 @@ def autolaunch():
|
|||
|
||||
|
||||
def main():
|
||||
"""This is the main loop of our utility
|
||||
"""
|
||||
"""This is the main loop of our utility"""
|
||||
size = terminal_size()
|
||||
snackScreen = SnackScreen()
|
||||
snackScreen.drawRootText(1,0,_('Byobu Configuration Menu'))
|
||||
snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu'))
|
||||
snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits'))
|
||||
config = SafeConfigParser()
|
||||
isInstalled = autolaunch()
|
||||
tag = 100
|
||||
while tag > 0 :
|
||||
while tag > 0:
|
||||
tag = menu(snackScreen, size, isInstalled)
|
||||
if tag == 1:
|
||||
tag = help(snackScreen, size, config)
|
||||
|
@ -329,4 +359,5 @@ def main():
|
|||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -20,20 +20,23 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import commands, os, re, sys, subprocess
|
||||
import commands
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
PKG = "byobu"
|
||||
SHELL = os.getenv("SHELL", "/bin/bash")
|
||||
HOME=os.getenv("HOME")
|
||||
BYOBU_CONFIG_DIR=os.getenv("BYOBU_CONFIG_DIR", HOME+"/.byobu")
|
||||
BYOBU_BACKEND=os.getenv("BYOBU_BACKEND", "tmux")
|
||||
HOME = os.getenv("HOME")
|
||||
BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu")
|
||||
BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux")
|
||||
choice = ""
|
||||
sessions = []
|
||||
text = []
|
||||
|
||||
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_AUTH_SOCK", "SSH_AGENT_PID"]
|
||||
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_AUTH_SOCK", "SSH_AGENT_PID"]
|
||||
|
||||
|
||||
def get_sessions():
|
||||
sessions = []
|
||||
|
@ -59,6 +62,7 @@ def get_sessions():
|
|||
i += 1
|
||||
return sessions
|
||||
|
||||
|
||||
def update_environment(session):
|
||||
backend, session_name = session.split("____", 2)
|
||||
for var in BYOBU_UPDATE_ENVVARS:
|
||||
|
@ -71,6 +75,7 @@ def update_environment(session):
|
|||
print "Sending variable: %s" % (cmd, )
|
||||
subprocess.call(cmd, stdout=open(os.devnull, "w"))
|
||||
|
||||
|
||||
def attach_session(session):
|
||||
print("Attaching: [%s]\n" % session)
|
||||
update_environment(session)
|
||||
|
@ -99,13 +104,13 @@ if len(sessions) > 1:
|
|||
sys.stdout.write(" %d. %s\n" % (i, s))
|
||||
i += 1
|
||||
try:
|
||||
choice = int(raw_input("\nChoose 1-%d [1]: " % (i-1)))
|
||||
choice = int(raw_input("\nChoose 1-%d [1]: " % (i - 1)))
|
||||
if choice >= 1 and choice < i:
|
||||
break
|
||||
else:
|
||||
tries += 1
|
||||
choice = ""
|
||||
sys.stderr.write("\nERROR: Invalid input\n");
|
||||
sys.stderr.write("\nERROR: Invalid input\n")
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
sys.exit(0)
|
||||
|
@ -115,7 +120,7 @@ if len(sessions) > 1:
|
|||
break
|
||||
tries += 1
|
||||
choice = ""
|
||||
sys.stderr.write("\nERROR: Invalid input\n");
|
||||
sys.stderr.write("\nERROR: Invalid input\n")
|
||||
elif len(sessions) == 1:
|
||||
# Auto-select the only session
|
||||
choice = 1
|
||||
|
@ -127,17 +132,17 @@ elif len(sessions) == 1:
|
|||
sys.exit(1)
|
||||
|
||||
if choice:
|
||||
if sessions[choice-1] == "NEW":
|
||||
if sessions[choice - 1] == "NEW":
|
||||
# Create a new session
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
os.execvp("byobu", ["", "new-session", SHELL])
|
||||
else:
|
||||
os.execvp("byobu", ["", SHELL])
|
||||
elif sessions[choice-1] == "SHELL":
|
||||
elif sessions[choice - 1] == "SHELL":
|
||||
os.execvp(SHELL, [SHELL])
|
||||
else:
|
||||
# Attach to the chosen session; must use the binary, not the wrapper!
|
||||
attach_session(sessions[choice-1])
|
||||
attach_session(sessions[choice - 1])
|
||||
|
||||
# No valid selection, default to the youngest session, create if necessary
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue