diff options
author | Christopher Larson <chris_larson@mentor.com> | 2013-04-04 11:45:22 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-04-04 23:52:21 +0100 |
commit | 59e425455fb0a01a0928f366538fc8382075d85e (patch) | |
tree | 25678c1276fb01b65c76395bead5c462fc9ea1b2 /meta/lib | |
parent | 078d3cbc28e78c1e00120779df2218e800b64dcc (diff) | |
download | poky-59e425455fb0a01a0928f366538fc8382075d85e.tar.gz |
oe.terminal: add tmux classes
This adds two new Terminal classes. It's separated into two, so that opening
a split inside a tmux window is preferred to the other terminal types, but
opening a tmux session is prioritized only slightly higher than screen.
- tmuxrunning: Open a new pane in the current running tmux window. Requires
that the TMUX variable be added to the env whitelist to use it.
- tmux: Open a new tmux session
(From OE-Core rev: 31c58d584f838738a6b6258b87b1c7e6ca173086)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/terminal.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index 4c1e318c7c..2e23d59cae 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py | |||
@@ -105,6 +105,43 @@ class Screen(Terminal): | |||
105 | else: | 105 | else: |
106 | logger.warn(msg) | 106 | logger.warn(msg) |
107 | 107 | ||
108 | class TmuxRunning(Terminal): | ||
109 | """Open a new pane in the current running tmux window""" | ||
110 | command = 'tmux split-window {command}' | ||
111 | priority = 2.75 | ||
112 | |||
113 | def __init__(self, sh_cmd, title=None, env=None, d=None): | ||
114 | if not bb.utils.which(os.getenv('PATH'), 'tmux'): | ||
115 | raise UnsupportedTerminal('tmux is not installed') | ||
116 | |||
117 | if not os.getenv('TMUX'): | ||
118 | raise UnsupportedTerminal('tmux is not running') | ||
119 | |||
120 | Terminal.__init__(self, sh_cmd, title, env, d) | ||
121 | |||
122 | class TmuxNewSession(Terminal): | ||
123 | """Start a new tmux session and window""" | ||
124 | command = 'tmux new -d -s devshell -n devshell {command}' | ||
125 | priority = 0.75 | ||
126 | |||
127 | def __init__(self, sh_cmd, title=None, env=None, d=None): | ||
128 | if not bb.utils.which(os.getenv('PATH'), 'tmux'): | ||
129 | raise UnsupportedTerminal('tmux is not installed') | ||
130 | |||
131 | # TODO: consider using a 'devshell' session shared amongst all | ||
132 | # devshells, if it's already there, add a new window to it. | ||
133 | window_name = 'devshell-%i' % os.getpid() | ||
134 | |||
135 | self.command = 'tmux new -d -s {0} -n {0} {{command}}'.format(window_name) | ||
136 | Terminal.__init__(self, sh_cmd, title, env, d) | ||
137 | |||
138 | attach_cmd = 'tmux att -t {0}'.format(window_name) | ||
139 | msg = 'Tmux started. Please connect in another terminal with `tmux att -t {0}`'.format(window_name) | ||
140 | if d: | ||
141 | bb.event.fire(bb.event.LogExecTTY(msg, attach_cmd, 0.5, 10), d) | ||
142 | else: | ||
143 | logger.warn(msg) | ||
144 | |||
108 | class Custom(Terminal): | 145 | class Custom(Terminal): |
109 | command = 'false' # This is a placeholder | 146 | command = 'false' # This is a placeholder |
110 | priority = 3 | 147 | priority = 3 |