mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -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
|
||||
|
||||
* 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
|
||||
|
||||
|
|
|
@ -18,27 +18,30 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import commands, os, sys
|
||||
import commands, os, re, sys
|
||||
|
||||
PKG = "byobu"
|
||||
SHELL = os.getenv("SHELL", "/bin/bash")
|
||||
sessions = []
|
||||
choice = ""
|
||||
sessions.append(0)
|
||||
sessions = []
|
||||
text = []
|
||||
i = 0
|
||||
output = commands.getoutput('screen -ls "' + PKG + '" | sed "s/\s\+/ /g" | grep "^\s"')
|
||||
output = commands.getoutput('screen -ls ' + PKG)
|
||||
if output:
|
||||
for s in output.split("\n"):
|
||||
items = s.split(" ")
|
||||
sessions.append(items[1])
|
||||
i += 1
|
||||
s = re.sub(r'\s+', ' ', s)
|
||||
if s.find(" ") == 0 and len(s) > 1:
|
||||
text.append(s)
|
||||
items = s.split(" ")
|
||||
sessions.append(items[1])
|
||||
i += 1
|
||||
|
||||
if i > 1:
|
||||
sys.stdout.write("\nByobu sessions...\n\n")
|
||||
tries = 0
|
||||
while tries < 3:
|
||||
i = 1
|
||||
for s in output.split("\n"):
|
||||
for s in text:
|
||||
sys.stdout.write(" %d. %s\n" % (i, s))
|
||||
i += 1
|
||||
sys.stdout.write(" %d. Create a new session\n" % i)
|
||||
|
@ -64,8 +67,8 @@ if choice:
|
|||
# Create a new session
|
||||
os.execv("/usr/bin/byobu", ["", SHELL])
|
||||
else:
|
||||
# Attach to the chosen session
|
||||
os.execv("/usr/bin/byobu", ["", "-AOxRR", sessions[choice]])
|
||||
else:
|
||||
# No valid selection, default to the youngest session
|
||||
os.execv("/usr/bin/byobu", ["", "-AOxRR"])
|
||||
# Attach to the chosen session; must use the 'screen' binary
|
||||
os.execv("/usr/bin/screen", ["", "-AOxRR", sessions[choice-1]])
|
||||
|
||||
# No valid selection, default to the youngest session, create if necessary
|
||||
os.execv("/usr/bin/byobu", ["", "-AOxRR"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue