Skip to content

Add start_directory to support to new sessions and panes #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,22 @@ def reset(self):

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

def split_window(self, attach=False, vertical=True):
def split_window(self, attach=False, vertical=True, start_directory=None):
"""Split window at pane and return newly created :class:`Pane`.

:param attach: Attach / select pane after creation.
:type attach: bool
:param vertical: split vertically
:type vertical: bool
:rtype: :class:`Pane`.
:param start_directory: specifies the working directory in which the
new pane is created.
:type start_directory: string

"""
return self.window.split_window(
target=self.get('pane_id'),
start_directory=start_directory,
attach=attach,
vertical=vertical
)
Expand Down
8 changes: 8 additions & 0 deletions libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def new_session(self,
session_name=None,
kill_session=False,
attach=False,
start_directory=None,
*args,
**kwargs):
"""Return :class:`Session` from ``$ tmux new-session``.
Expand Down Expand Up @@ -428,6 +429,11 @@ def new_session(self,
:param kill_session: Kill current session if ``$ tmux has-session``
Useful for testing workspaces.
:type kill_session: bool

:param start_directory: specifies the working directory in which the
new session is created.
:type start_directory: string

:raises: :exc:`exc.BadSessionName`
:rtype: :class:`Session`

Expand Down Expand Up @@ -461,6 +467,8 @@ def new_session(self,
if not attach:
tmux_args += ('-d',)

if start_directory:
tmux_args += ('-c', start_directory)
proc = self.cmd(
'new-session',
*tmux_args
Expand Down
2 changes: 1 addition & 1 deletion libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def new_window(self,

:type window_name: string
:param start_directory: specifies the working directory in which the
new created.
new window is created.
:type start_directory: string
:param attach: make new window the current window after creating it,
default True.
Expand Down
2 changes: 1 addition & 1 deletion libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def split_window(
default True.
:type attach: bool
:param start_directory: specifies the working directory in which the
new created.
new window is created.
:type start_directory: string
:param target: ``target_pane`` to split.
:type target: bool
Expand Down