From: Christopher Larson <kergoth@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Christopher Larson <chris_larson@mentor.com>
Subject: [PATCHv3] oe.terminal: add tmux classes
Date: Thu, 4 Apr 2013 17:44:43 -0700 [thread overview]
Message-ID: <1365122683-17652-1-git-send-email-kergoth@gmail.com> (raw)
In-Reply-To: <1365101122-15705-1-git-send-email-kergoth@gmail.com>
From: Christopher Larson <chris_larson@mentor.com>
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
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
meta/lib/oe/terminal.py | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 2e23d59..e52863f 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -142,6 +142,44 @@ class TmuxNewSession(Terminal):
else:
logger.warn(msg)
+class TmuxRunning(Terminal):
+ """Open a new pane in the current running tmux window"""
+ name = 'tmux-running'
+ command = 'tmux split-window {command}'
+ priority = 2.75
+
+ def __init__(self, sh_cmd, title=None, env=None, d=None):
+ if not bb.utils.which(os.getenv('PATH'), 'tmux'):
+ raise UnsupportedTerminal('tmux is not installed')
+
+ if not os.getenv('TMUX'):
+ raise UnsupportedTerminal('tmux is not running')
+
+ Terminal.__init__(self, sh_cmd, title, env, d)
+
+class Tmux(Terminal):
+ """Start a new tmux session and window"""
+ command = 'tmux new -d -s devshell -n devshell {command}'
+ priority = 0.75
+
+ def __init__(self, sh_cmd, title=None, env=None, d=None):
+ if not bb.utils.which(os.getenv('PATH'), 'tmux'):
+ raise UnsupportedTerminal('tmux is not installed')
+
+ # TODO: consider using a 'devshell' session shared amongst all
+ # devshells, if it's already there, add a new window to it.
+ window_name = 'devshell-%i' % os.getpid()
+
+ self.command = 'tmux new -d -s {0} -n {0} {{command}}'.format(window_name)
+ Terminal.__init__(self, sh_cmd, title, env, d)
+
+ attach_cmd = 'tmux att -t {0}'.format(window_name)
+ msg = 'Tmux started. Please connect in another terminal with `tmux att -t {0}`'.format(window_name)
+ if d:
+ bb.event.fire(bb.event.LogExecTTY(msg, attach_cmd, 0.5, 10), d)
+ else:
+ logger.warn(msg)
+
class Custom(Terminal):
command = 'false' # This is a placeholder
priority = 3
--
1.8.2
next prev parent reply other threads:[~2013-04-05 1:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-04 18:45 [PATCHv2] oe.terminal: add tmux classes Christopher Larson
2013-04-05 0:44 ` Christopher Larson [this message]
2013-04-05 13:55 ` [PATCHv3] " Jason Wessel
2013-04-05 14:20 ` Chris Larson
2013-04-05 22:10 ` Jason Wessel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365122683-17652-1-git-send-email-kergoth@gmail.com \
--to=kergoth@gmail.com \
--cc=chris_larson@mentor.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.