diff --git a/CHANGES b/CHANGES index 7ab5186a6..2eb8905ff 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Here you can find the recent changes to libtmux current ------- +- :issue:`234`: ``Window.split_window``: Allow passing ``percent`` - :issue:`289`: Fix warning due to invalid escape sequences - :issue:`295`: Publish docs via our own action - :issue:`295`: Move more packaging over to poetry, though we'll keep diff --git a/libtmux/pane.py b/libtmux/pane.py index 5ea1f11f9..0be1d8151 100644 --- a/libtmux/pane.py +++ b/libtmux/pane.py @@ -155,7 +155,7 @@ def reset(self): self.cmd('send-keys', r'-R \; clear-history') - def split_window(self, attach=False, vertical=True, start_directory=None): + def split_window(self, attach=False, vertical=True, start_directory=None, percent=None): """ Split window at pane and return newly created :class:`Pane`. @@ -167,6 +167,8 @@ def split_window(self, attach=False, vertical=True, start_directory=None): split vertically start_directory : str, optional specifies the working directory in which the new pane is created. + percent: int, optional + percentage to occupy with respect to current pane Returns ------- @@ -177,6 +179,7 @@ def split_window(self, attach=False, vertical=True, start_directory=None): start_directory=start_directory, attach=attach, vertical=vertical, + percent=percent, ) def set_width(self, width): diff --git a/libtmux/window.py b/libtmux/window.py index 7b5b1b1d6..05ee34c33 100644 --- a/libtmux/window.py +++ b/libtmux/window.py @@ -382,7 +382,13 @@ def last_pane(self): return self.select_pane('-l') def split_window( - self, target=None, start_directory=None, attach=True, vertical=True, shell=None + self, + target=None, + start_directory=None, + attach=True, + vertical=True, + shell=None, + percent=None, ): """ Split window and return the created :class:`Pane`. @@ -407,6 +413,8 @@ def split_window( NOTE: When this command exits the pane will close. This feature is useful for long-running processes where the closing of the window upon completion is desired. + percent: int, optional + percentage to occupy with respect to current window Returns ------- @@ -446,6 +454,9 @@ def split_window( else: tmux_args += ('-h',) + if percent is not None: + tmux_args += ('-p %d' % percent,) + tmux_args += ('-P', '-F%s' % ''.join(tmux_formats)) # output if start_directory: