Skip to content

Commit d991e69

Browse files
authored
Merge pull request #19 from gandelman-a/master
Add start_directory to support to new sessions and panes
2 parents 5c227e6 + 5518068 commit d991e69

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

libtmux/pane.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,22 @@ def reset(self):
103103

104104
self.cmd('send-keys', '-R \; clear-history')
105105

106-
def split_window(self, attach=False, vertical=True):
106+
def split_window(self, attach=False, vertical=True, start_directory=None):
107107
"""Split window at pane and return newly created :class:`Pane`.
108108
109109
:param attach: Attach / select pane after creation.
110110
:type attach: bool
111111
:param vertical: split vertically
112112
:type vertical: bool
113113
:rtype: :class:`Pane`.
114+
:param start_directory: specifies the working directory in which the
115+
new pane is created.
116+
:type start_directory: string
114117
115118
"""
116119
return self.window.split_window(
117120
target=self.get('pane_id'),
121+
start_directory=start_directory,
118122
attach=attach,
119123
vertical=vertical
120124
)

libtmux/server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ def new_session(self,
401401
session_name=None,
402402
kill_session=False,
403403
attach=False,
404+
start_directory=None,
404405
*args,
405406
**kwargs):
406407
"""Return :class:`Session` from ``$ tmux new-session``.
@@ -428,6 +429,11 @@ def new_session(self,
428429
:param kill_session: Kill current session if ``$ tmux has-session``
429430
Useful for testing workspaces.
430431
:type kill_session: bool
432+
433+
:param start_directory: specifies the working directory in which the
434+
new session is created.
435+
:type start_directory: string
436+
431437
:raises: :exc:`exc.BadSessionName`
432438
:rtype: :class:`Session`
433439
@@ -461,6 +467,8 @@ def new_session(self,
461467
if not attach:
462468
tmux_args += ('-d',)
463469

470+
if start_directory:
471+
tmux_args += ('-c', start_directory)
464472
proc = self.cmd(
465473
'new-session',
466474
*tmux_args

libtmux/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def new_window(self,
145145
146146
:type window_name: string
147147
:param start_directory: specifies the working directory in which the
148-
new created.
148+
new window is created.
149149
:type start_directory: string
150150
:param attach: make new window the current window after creating it,
151151
default True.

libtmux/window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def split_window(
368368
default True.
369369
:type attach: bool
370370
:param start_directory: specifies the working directory in which the
371-
new created.
371+
new window is created.
372372
:type start_directory: string
373373
:param target: ``target_pane`` to split.
374374
:type target: bool

0 commit comments

Comments
 (0)