Skip to content

Commit 7101c30

Browse files
authored
Merge pull request #234 from jinankjain/add_percent
Add percent arg to split window
2 parents ce5e34c + f11d4f6 commit 7101c30

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Here you can find the recent changes to libtmux
66

77
current
88
-------
9+
- :issue:`234`: ``Window.split_window``: Allow passing ``percent``
910
- :issue:`289`: Fix warning due to invalid escape sequences
1011
- :issue:`295`: Publish docs via our own action
1112
- :issue:`295`: Move more packaging over to poetry, though we'll keep

libtmux/pane.py

+4-1
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

+12-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,13 @@ 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,
386+
target=None,
387+
start_directory=None,
388+
attach=True,
389+
vertical=True,
390+
shell=None,
391+
percent=None,
386392
):
387393
"""
388394
Split window and return the created :class:`Pane`.
@@ -407,6 +413,8 @@ def split_window(
407413
NOTE: When this command exits the pane will close. This feature
408414
is useful for long-running processes where the closing of the
409415
window upon completion is desired.
416+
percent: int, optional
417+
percentage to occupy with respect to current window
410418
411419
Returns
412420
-------
@@ -446,6 +454,9 @@ def split_window(
446454
else:
447455
tmux_args += ('-h',)
448456

457+
if percent is not None:
458+
tmux_args += ('-p %d' % percent,)
459+
449460
tmux_args += ('-P', '-F%s' % ''.join(tmux_formats)) # output
450461

451462
if start_directory:

0 commit comments

Comments
 (0)