How to use the tmuxp.Session function in tmuxp

To help you get started, we’ve selected a few tmuxp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomasballinger / rlundo / test / tmux.py View on Github external
def __enter__(self):
        self.tmux_config = self.tempfile(self.tmux_config_contents())
        self.bash_config = self.tempfile(self.bash_config_contents())

        self.server = tmuxp.Server()
        if self.use_existing_session:
            try:
                session_dict = self.server.attached_sessions()  # until tmuxp bug is fixed
                if session_dict is None:
                    raise tmuxp.exc.TmuxpException
                self.session = tmuxp.Session(self.server, **session_dict[0])
            except tmuxp.exc.TmuxpException:
                self.session = self.server.new_session(session_name='rlundotesting')
        else:
            self.session = self.server.new_session(session_name='rlundotesting', kill_session=True)

        self.window = self.session.new_window(attach=False)
        try:
            output = self.window.panes[0].cmd('respawn-pane', '-k', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
            if output.stderr:
                raise ValueError(repr(output.stderr) + " " +  repr(self.window.panes))
            (pane, ) = self.window.panes
            output = pane.cmd('respawn-pane', '-k', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
            if output.stderr:
                raise ValueError(repr(output.stderr) + " " +  repr(self.window.panes))
            pane.cmd('split-window', '-h', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
            pane.cmd('split-window', '-v', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
github tmux-python / tmuxp / tmuxp / testsuite / server.py View on Github external
def test_new_session(self):
        new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
        new_session = Session.new_session(session_name=new_session_name)

        self.assertIsInstance(new_session, Session)
github tmux-python / tmuxp / tmuxp / testsuite / server.py View on Github external
def test_new_session(self):
        new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
        new_session = Session.new_session(session_name=new_session_name)

        self.assertIsInstance(new_session, Session)
github tmux-python / tmuxp / tmuxp / testsuite / server.py View on Github external
def test_new_session(self):
        new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
        new_session = Session.new_session(session_name=new_session_name)

        self.assertIsInstance(new_session, Session)
github tmux-python / tmuxp / tmuxp / testsuite / server.py View on Github external
def test_new_session(self):
        new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
        new_session = Session.new_session(session_name=new_session_name)

        self.assertIsInstance(new_session, Session)
github tmux-python / tmuxp / tmuxp / workspacebuilder.py View on Github external
)
                raise exc.TmuxSessionExists(
                    'Session name %s is already running.' %
                    self.sconf['session_name']
                )
            else:
                session = self.server.new_session(
                    session_name=self.sconf['session_name']
                )

            assert(self.sconf['session_name'] == session.get('session_name'))
            assert(len(self.sconf['session_name']) > 0)

        self.session = session

        assert(isinstance(session, Session))

        focus = None

        for w, wconf in self.iter_create_windows(session):
            assert(isinstance(w, Window))

            focus_pane = None
            for p, pconf in self.iter_create_panes(w, wconf):
                assert(isinstance(p, Pane))
                p = p

                if 'layout' in wconf:
                    w.select_layout(wconf['layout'])

                if 'focus' in pconf and pconf['focus']:
                    focus_pane = p