Skip to content

Commit cbd7204

Browse files
committed
feat(Pane.kill): Add Pane.kill()
1 parent 2ea184a commit cbd7204

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/libtmux/pane.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,62 @@ def display_message(
353353
self.cmd("display-message", cmd)
354354
return None
355355

356+
def kill(
357+
self,
358+
all_except: t.Optional[bool] = None,
359+
) -> None:
360+
"""Kill :class:`Pane`.
361+
362+
``$ tmux kill-pane``.
363+
364+
Examples
365+
--------
366+
Kill a pane:
367+
>>> pane_1 = pane.split_window()
368+
369+
>>> pane_1 in window.panes
370+
True
371+
372+
>>> pane_1.kill()
373+
374+
>>> pane_1 not in window.panes
375+
True
376+
377+
Kill all panes except the current one:
378+
>>> pane.window.resize(height=100, width=100)
379+
Window(@1 1...)
380+
381+
>>> one_pane_to_rule_them_all = pane.split_window()
382+
383+
>>> other_panes = pane.split_window(
384+
... ), pane.split_window()
385+
386+
>>> all([p in window.panes for p in other_panes])
387+
True
388+
389+
>>> one_pane_to_rule_them_all.kill(all_except=True)
390+
391+
>>> all([p not in window.panes for p in other_panes])
392+
True
393+
394+
>>> one_pane_to_rule_them_all in window.panes
395+
True
396+
"""
397+
flags: t.Tuple[str, ...] = ()
398+
399+
if all_except:
400+
flags += ("-a",)
401+
402+
proc = self.cmd(
403+
"kill-pane",
404+
*flags,
405+
)
406+
407+
if proc.stderr:
408+
raise exc.LibTmuxException(proc.stderr)
409+
410+
return None
411+
356412
"""
357413
Commands ("climber"-helpers)
358414

0 commit comments

Comments
 (0)