Skip to content

Commit 8f5df99

Browse files
committed
Fix select_window() by providing the session ID as argument to -t
Previosly select_window() would not work in nested tmux scenarios, as there was no tmux session ID in the final tmux command. This is because select_window() already adds the '-t' argument, hence the check in cmd() does not add the session ID. Thanks to Fabian Lesniak and Andreas Fried for pointing this out. Fixes #161
1 parent 2101653 commit 8f5df99

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ current
1010
- :issue:`306`: chore: Remove python 2.7 support
1111
- :issue:`314`: chore: Python 3.x syntax tweaks
1212
- :issue:`312`: ci: Add tmux 3.2a to CI
13+
- :issue:`271`: Fix select_window() by providing the session ID as
14+
argument to -t.
1315

1416
libtmux 0.8.5 (2020-10-25)
1517
--------------------------

libtmux/session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ def select_window(self, target_window):
353353
assure ``-l``, ``-n``, ``-p`` work.
354354
"""
355355

356-
target = '-t%s' % target_window
356+
# Note that we also provide the session ID here, since cmd()
357+
# will not automatically add it as there is already a '-t'
358+
# argument provided.
359+
target = '-t%s:%s' % (self._session_id, target_window)
357360

358361
proc = self.cmd('select-window', target)
359362

0 commit comments

Comments
 (0)