Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
- TMUX_VERSION=1.9a
matrix:
allow_failures:
- python: pypy3.3-5.2-alpha1
- env: TMUX_VERSION=master
before_install:
- export PIP_USE_MIRRORS=true
Expand Down
10 changes: 8 additions & 2 deletions libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os

from . import exc, formats
from ._compat import text_type
from .common import EnvironmentMixin, TmuxMappingObject, \
TmuxRelationalObject, session_check_name, handle_option_error
from .window import Window
Expand Down Expand Up @@ -72,8 +73,13 @@ def cmd(self, *args, **kwargs):
Renamed from ``.tmux`` to ``.cmd``.

"""
if '-t' not in kwargs:
kwargs['-t'] = self.id
# if -t is not set in any arg yet
if not any('-t' in text_type(x) for x in args):
# insert -t immediately after 1st arg, as per tmux format
new_args = [args[0]]
new_args += ['-t', self.id]
new_args += args[1:]
args = new_args
return self.server.cmd(*args, **kwargs)

def attach_session(self):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,12 @@ def test_periods_raise_badsessionname(server, session, session_name, raises):
session.rename_session(new_name)
with pytest.raises(exc.LibTmuxException):
server.switch_client(new_name)


def test_cmd_inserts_sesion_id(session):
current_session_id = session.id
last_arg = 'last-arg'
cmd = session.cmd('not-a-command', last_arg)
assert '-t' in cmd.cmd
assert current_session_id in cmd.cmd
assert cmd.cmd[-1] == last_arg