Skip to content

Commit 0fd98a5

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 374d466 commit 0fd98a5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libtmux/pane.py

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

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

157-
def split_window(self, attach=False, vertical=True, start_directory=None):
157+
def split_window(self, attach=False, vertical=True, start_directory=None, percent=None):
158158
"""
159159
Split window at pane and return newly created :class:`Pane`.
160160
@@ -166,6 +166,8 @@ def split_window(self, attach=False, vertical=True, start_directory=None):
166166
split vertically
167167
start_directory : str, optional
168168
specifies the working directory in which the new pane is created.
169+
percent: int, optional
170+
percentage to occupy with respect to current pane
169171
170172
Returns
171173
-------
@@ -176,6 +178,7 @@ def split_window(self, attach=False, vertical=True, start_directory=None):
176178
start_directory=start_directory,
177179
attach=attach,
178180
vertical=vertical,
181+
percent=percent,
179182
)
180183

181184
def set_width(self, width):

libtmux/window.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ 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, shell=None, percent=None
386386
):
387387
"""
388388
Split window and return the created :class:`Pane`.
@@ -407,6 +407,8 @@ def split_window(
407407
NOTE: When this command exits the pane will close. This feature
408408
is useful for long-running processes where the closing of the
409409
window upon completion is desired.
410+
percent: int, optional
411+
percentage to occupy with respect to current window
410412
411413
Returns
412414
-------
@@ -446,6 +448,9 @@ def split_window(
446448
else:
447449
tmux_args += ('-h',)
448450

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

451456
if start_directory:

0 commit comments

Comments
 (0)