diff --git a/libtmux/pane.py b/libtmux/pane.py index 80f11b65b..80b00f0ba 100644 --- a/libtmux/pane.py +++ b/libtmux/pane.py @@ -103,7 +103,7 @@ 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. @@ -111,10 +111,14 @@ def split_window(self, attach=False, vertical=True): :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 ) diff --git a/libtmux/server.py b/libtmux/server.py index bebc703c8..dafe36d94 100644 --- a/libtmux/server.py +++ b/libtmux/server.py @@ -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``. @@ -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` @@ -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 diff --git a/libtmux/session.py b/libtmux/session.py index 5689b65ed..d046188d2 100644 --- a/libtmux/session.py +++ b/libtmux/session.py @@ -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. diff --git a/libtmux/window.py b/libtmux/window.py index 13fd7e583..4b70919c7 100644 --- a/libtmux/window.py +++ b/libtmux/window.py @@ -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