mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* usr/bin/byobu-select-session: LP: #1241785
- rework session selecting, especially when nesting - support an environment variable BYOBU_NESTING=1 which users can set to force nesting (rather than modifying the TERM variable which other programs rely upon) - add an interactive step, where users can immediately choose to run in a nested session
This commit is contained in:
parent
e8057c30ce
commit
d84b65956a
2 changed files with 31 additions and 12 deletions
7
debian/changelog
vendored
7
debian/changelog
vendored
|
@ -7,6 +7,13 @@ byobu (5.61) unreleased; urgency=low
|
||||||
usr/share/byobu/pixmaps/byobu.svg:
|
usr/share/byobu/pixmaps/byobu.svg:
|
||||||
- add a new banner image
|
- add a new banner image
|
||||||
- use a green color for the branches in the logo
|
- use a green color for the branches in the logo
|
||||||
|
* usr/bin/byobu-select-session: LP: #1241785
|
||||||
|
- rework session selecting, especially when nesting
|
||||||
|
- support an environment variable BYOBU_NESTING=1 which users can
|
||||||
|
set to force nesting (rather than modifying the TERM variable
|
||||||
|
which other programs rely upon)
|
||||||
|
- add an interactive step, where users can immediately choose to
|
||||||
|
run in a nested session
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 21 Sep 2013 09:42:30 -0500
|
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 21 Sep 2013 09:42:30 -0500
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ SHELL = os.getenv("SHELL", "/bin/bash")
|
||||||
HOME = os.getenv("HOME")
|
HOME = os.getenv("HOME")
|
||||||
BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu")
|
BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu")
|
||||||
BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux")
|
BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux")
|
||||||
choice = ""
|
choice = -1
|
||||||
sessions = []
|
sessions = []
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
|
@ -96,6 +96,24 @@ def attach_session(session):
|
||||||
else:
|
else:
|
||||||
os.execvp("screen", ["", "-AOxRR", session_name])
|
os.execvp("screen", ["", "-AOxRR", session_name])
|
||||||
|
|
||||||
|
# Confirm nested session, if necessary
|
||||||
|
if os.getenv("BYOBU_NESTING", "0") != "1":
|
||||||
|
if (BYOBU_BACKEND == "tmux" and os.getenv("TMUX")) or (BYOBU_BACKEND == "screen" and "screen" in os.getenv("TERM")):
|
||||||
|
sys.stderr.write("WARNING: Sessions should be nested with care.\n")
|
||||||
|
try:
|
||||||
|
nest = raw_input("Are you sure you want to run Byobu inside another session? [y/N]: ")
|
||||||
|
if nest != "Y" and nest != "y":
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
if os.getenv("TMUX"):
|
||||||
|
os.unsetenv("TMUX")
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.stdout.write("\n")
|
||||||
|
sys.exit(1)
|
||||||
|
except:
|
||||||
|
sys.stdout.write("\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
sessions = get_sessions()
|
sessions = get_sessions()
|
||||||
|
|
||||||
show_shell = os.path.exists("%s/.always-select" % (BYOBU_CONFIG_DIR))
|
show_shell = os.path.exists("%s/.always-select" % (BYOBU_CONFIG_DIR))
|
||||||
|
@ -119,29 +137,23 @@ if len(sessions) > 1:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
tries += 1
|
tries += 1
|
||||||
choice = ""
|
choice = -1
|
||||||
sys.stderr.write("\nERROR: Invalid input\n")
|
sys.stderr.write("\nERROR: Invalid input\n")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print()
|
sys.stdout.write("\n")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
if choice == "":
|
if choice == "" or choice == -1:
|
||||||
choice = 1
|
choice = 1
|
||||||
break
|
break
|
||||||
tries += 1
|
tries += 1
|
||||||
choice = ""
|
choice = -1
|
||||||
sys.stderr.write("\nERROR: Invalid input\n")
|
sys.stderr.write("\nERROR: Invalid input\n")
|
||||||
elif len(sessions) == 1:
|
elif len(sessions) == 1:
|
||||||
# Auto-select the only session
|
# Auto-select the only session
|
||||||
choice = 1
|
choice = 1
|
||||||
if BYOBU_BACKEND == "tmux" and os.getenv("TMUX"):
|
|
||||||
sys.stderr.write("ERROR: Sessions should be nested with care. Unset $TMUX to force.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
elif BYOBU_BACKEND == "screen" and re.match("screen", os.getenv("TERM")):
|
|
||||||
sys.stderr.write("ERROR: Sessions should be nested with care. Remove 'screen' from $TERM to force.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if choice:
|
if choice >= 1:
|
||||||
if sessions[choice - 1] == "NEW":
|
if sessions[choice - 1] == "NEW":
|
||||||
# Create a new session
|
# Create a new session
|
||||||
if BYOBU_BACKEND == "tmux":
|
if BYOBU_BACKEND == "tmux":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue