Skip to content

Commit 703e80b

Browse files
author
Jinank Jain
committed
Add percent arg to split window
While spliting window tmux supports '-p' to specify the amount (in percentage) that the newly created pane will occupy with respect to current pane. So let's expose the same functionality by an extra argument percent to split_window function. Signed-off-by: Jinank Jain <jinankj@amazon.de>
1 parent ce5e34c commit 703e80b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

libtmux/pane.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def reset(self):
155155

156156
self.cmd('send-keys', r'-R \; clear-history')
157157

158-
def split_window(self, attach=False, vertical=True, start_directory=None):
158+
def split_window(self, attach=False, vertical=True, start_directory=None, percent=None):
159159
"""
160160
Split window at pane and return newly created :class:`Pane`.
161161
@@ -167,6 +167,8 @@ def split_window(self, attach=False, vertical=True, start_directory=None):
167167
split vertically
168168
start_directory : str, optional
169169
specifies the working directory in which the new pane is created.
170+
percent: int, optional
171+
percentage to occupy with respect to current pane
170172
171173
Returns
172174
-------
@@ -177,6 +179,7 @@ def split_window(self, attach=False, vertical=True, start_directory=None):
177179
start_directory=start_directory,
178180
attach=attach,
179181
vertical=vertical,
182+
percent=percent,
180183
)
181184

182185
def set_width(self, width):

libtmux/window.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ def last_pane(self):
382382
return self.select_pane('-l')
383383

384384
def split_window(
385-
self, target=None, start_directory=None, attach=True, vertical=True, shell=None
385+
self, target=None, start_directory=None, attach=True, vertical=True,
386+
shell=None, percent=None
386387
):
387388
"""
388389
Split window and return the created :class:`Pane`.
@@ -407,6 +408,8 @@ def split_window(
407408
NOTE: When this command exits the pane will close. This feature
408409
is useful for long-running processes where the closing of the
409410
window upon completion is desired.
411+
percent: int, optional
412+
percentage to occupy with respect to current window
410413
411414
Returns
412415
-------
@@ -446,6 +449,9 @@ def split_window(
446449
else:
447450
tmux_args += ('-h',)
448451

452+
if percent:
453+
tmux_args += ('-p %d' % percent,)
454+
449455
tmux_args += ('-P', '-F%s' % ''.join(tmux_formats)) # output
450456

451457
if start_directory:

0 commit comments

Comments
 (0)