How to use tmuxp - 10 common examples

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 tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_before_load_true_if_test_passes(server):
    config_script_completes = loadfixture(
        "workspacebuilder/config_script_completes.yaml"
    )
    assert os.path.exists(os.path.join(fixtures_dir, 'script_complete.sh'))
    sconfig = kaptan.Kaptan(handler='yaml')
    yaml = config_script_completes.format(
        fixtures_dir=fixtures_dir,
        script_complete=os.path.join(fixtures_dir, 'script_complete.sh'),
    )

    sconfig = sconfig.import_config(yaml).get()
    sconfig = config.expand(sconfig)
    sconfig = config.trickle(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig)

    with temp_session(server) as session:
        builder.build(session=session)
github tmux-python / tmuxp / tests / test_config.py View on Github external
def test_config_expand1():
    """Expand shell commands from string to list."""
    test_config = config.expand(fixtures.expand1.before_config)
    assert test_config == fixtures.expand1.after_config
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_focus_pane_index(session):
    yaml_config = loadfixture('workspacebuilder/focus_and_pane.yaml')

    sconfig = kaptan.Kaptan(handler='yaml')
    sconfig = sconfig.import_config(yaml_config).get()
    sconfig = config.expand(sconfig)
    sconfig = config.trickle(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig)

    builder.build(session=session)

    assert session.attached_window.name == 'focused window'

    pane_base_index = int(
        session.attached_window.show_window_option('pane-base-index', g=True)
    )

    if not pane_base_index:
        pane_base_index = 0
    else:
        pane_base_index = int(pane_base_index)
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_before_load_true_if_test_passes_with_args(server):
    config_script_completes = loadfixture(
        "workspacebuilder/config_script_completes.yaml"
    )

    assert os.path.exists(os.path.join(fixtures_dir, 'script_complete.sh'))
    sconfig = kaptan.Kaptan(handler='yaml')
    yaml = config_script_completes.format(
        fixtures_dir=fixtures_dir,
        script_complete=os.path.join(fixtures_dir, 'script_complete.sh') + ' -v',
    )

    sconfig = sconfig.import_config(yaml).get()
    sconfig = config.expand(sconfig)
    sconfig = config.trickle(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig)

    with temp_session(server) as session:
        builder.build(session=session)
github tmux-python / tmuxp / tests / test_config.py View on Github external
Blank strings::

        panes: [
            ''
        ]

        # should output to:
        panes:
            'shell_command': ['']

    """

    yaml_config_file = os.path.join(example_dir, 'blank-panes.yaml')
    test_config = load_config(yaml_config_file)
    assert config.expand(test_config) == fixtures.expand_blank.expected
github tmux-python / tmuxp / tests / test_config.py View on Github external
def test_in_session_scope():
    sconfig = load_yaml(fixtures.shell_command_before_session.before)

    config.validate_schema(sconfig)

    assert config.expand(sconfig) == sconfig
    assert config.expand(config.trickle(sconfig)) == load_yaml(
        fixtures.shell_command_before_session.expected
    )
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_suppress_history(session):
    yaml_config = loadfixture("workspacebuilder/suppress_history.yaml")
    sconfig = kaptan.Kaptan(handler='yaml')
    sconfig = sconfig.import_config(yaml_config).get()
    sconfig = config.expand(sconfig)
    sconfig = config.trickle(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig)
    builder.build(session=session)

    inHistoryWindow = session.find_where({'window_name': 'inHistory'})
    isMissingWindow = session.find_where({'window_name': 'isMissing'})

    def assertHistory(cmd, hist):
        return 'inHistory' in cmd and cmd.endswith(hist)

    def assertIsMissing(cmd, hist):
        return 'isMissing' in cmd and not cmd.endswith(hist)

    for w, window_name, assertCase in [
        (inHistoryWindow, 'inHistory', assertHistory),
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_blank_pane_count(session):
    """:todo: Verify blank panes of various types build into workspaces."""
    yaml_config_file = os.path.join(example_dir, 'blank-panes.yaml')
    test_config = kaptan.Kaptan().import_config(yaml_config_file).get()
    test_config = config.expand(test_config)
    builder = WorkspaceBuilder(sconf=test_config)
    builder.build(session=session)

    assert session == builder.session

    window1 = session.find_where({'window_name': 'Blank pane test'})
    assert len(window1._panes) == 3

    window2 = session.find_where({'window_name': 'More blank panes'})
    assert len(window2._panes) == 3

    window3 = session.find_where({'window_name': 'Empty string (return)'})
    assert len(window3._panes) == 3

    window4 = session.find_where({'window_name': 'Blank with options'})
    assert len(window4._panes) == 2
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
def test_global_options(session):
    yaml_config = loadfixture("workspacebuilder/global_options.yaml")
    s = session
    sconfig = kaptan.Kaptan(handler='yaml')
    sconfig = sconfig.import_config(yaml_config).get()
    sconfig = config.expand(sconfig)

    builder = WorkspaceBuilder(sconf=sconfig)
    builder.build(session=session)

    assert "top" in s.show_option('status-position', _global=True)
    assert 493 == s.show_option('repeat-time', _global=True)
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, ))