Skip to content

Commit 2baa170

Browse files
committed
CHANGES
1 parent 93435f0 commit 2baa170

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Here you can find the recent changes to tmuxp.
1313
- [cli] ``tmuxp freeze <filename>`` experimental
1414
- [freeze] [tests] tmuxp now has experimental support for freezing live
1515
sessions.
16+
- [internals] :meth:`Window.kill_window()`
1617

1718
2013-10-29
1819
----------

tmuxp/testsuite/test_window.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ class RenameSpacesTest(RenameTest):
149149
window_name_after = 'hello \\ wazzup 0'
150150

151151

152+
class KillWindow(TmuxTestCase):
153+
154+
def test_kill_window(self):
155+
w = self.session.attached_window()
156+
w.get('window_id')
157+
158+
w.kill_window()
159+
with self.assertRaises(IndexError):
160+
w.get('window_id')
161+
162+
152163
class Options(TmuxTestCase):
153164

154165
def test_show_window_options(self):

tmuxp/window.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def set_window_option(self, option, value):
137137
:type value: string or bool
138138
'''
139139

140+
self.server._update_windows()
141+
140142
if isinstance(value, bool) and value:
141143
value = 'on'
142144
elif isinstance(value, bool) and not value:
@@ -145,6 +147,7 @@ def set_window_option(self, option, value):
145147
process = self.tmux(
146148
'set-window-option',
147149
'-t%s:%s' % (self.get('session_id'), self.get('window_index')),
150+
#'-t%s' % self.get('window_id'),
148151
option, value
149152
)
150153

@@ -155,7 +158,7 @@ def set_window_option(self, option, value):
155158
if isinstance(process.stderr, list) and len(process.stderr) == int(1):
156159
process.stderr = process.stderr[0]
157160
raise ValueError(
158-
'tmux set-window-option -t%s %s %s\n' % (self.get('window_id'), option, value) +
161+
'tmux set-window-option -t%s:%s %s %s\n' % (self.get('session_id'), self.get('window_index'), option, value) +
159162
process.stderr)
160163

161164
def show_window_options(self, option=None):
@@ -242,6 +245,24 @@ def rename_window(self, new_name):
242245

243246
return self
244247

248+
def kill_window(self):
249+
'''
250+
``$ tmux kill-window``
251+
252+
Kill the current :class:`Window` object.
253+
254+
:param target_window: the ``target window``.
255+
:type target_window: string
256+
'''
257+
258+
proc = self.tmux('kill-window', '-t%s' % self.get('window_id'))
259+
260+
if proc.stderr:
261+
raise Exception(proc.stderr)
262+
263+
self.server._update_windows()
264+
265+
245266
def select_pane(self, target_pane):
246267
'''
247268
``$ tmux select-pane``

0 commit comments

Comments
 (0)