Skip to content

Commit bb555f7

Browse files
committed
split_window now allows -c for start directory. #35
1 parent 0ca8e33 commit bb555f7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

tmuxp/window.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import absolute_import, division, print_function, \
99
with_statement, unicode_literals
1010

11+
import os
1112
import pipes
1213
import logging
1314

@@ -322,7 +323,12 @@ def last_pane(self):
322323
"""Return last pane."""
323324
return self.select_pane('-l')
324325

325-
def split_window(self, target=None, attach=True):
326+
def split_window(
327+
self,
328+
target=None,
329+
start_directory=None,
330+
attach=True
331+
):
326332
"""Split window and return the created :class:`Pane`.
327333
328334
.. note::
@@ -342,6 +348,9 @@ def split_window(self, target=None, attach=True):
342348
:param attach: make new window the current window after creating it,
343349
default True.
344350
:type attach: bool
351+
:param start_directory: specifies the working directory in which the
352+
new created.
353+
:type start_directory: string
345354
:param target: ``target_pane`` to split.
346355
:type target: bool
347356
@@ -366,6 +375,12 @@ def split_window(self, target=None, attach=True):
366375
'-P', '-F%s' % ''.join(tmux_formats) # output
367376
)
368377

378+
if start_directory:
379+
# as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c.
380+
start_directory = os.path.expanduser(start_directory)
381+
start_directory = pipes.quote(start_directory)
382+
tmux_args += ('-c%s' % start_directory,)
383+
369384
if not attach:
370385
tmux_args += ('-d',)
371386

tmuxp/workspacebuilder.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,17 @@ def iter_create_panes(self, w, wconf):
224224
p = w.attached_pane()
225225

226226
else:
227+
def get_pane_start_directory():
228+
229+
if 'start_directory' in pconf:
230+
return pconf['start_directory']
231+
elif 'start_directory' in wconf:
232+
return wconf['start_directory']
233+
else:
234+
return None
227235
p = w.split_window(
228236
attach=True,
229-
#target=w.list_panes()[-1].get('pane_index')
237+
start_directory=get_pane_start_directory(),
230238
)
231239

232240
assert(isinstance(p, Pane))

0 commit comments

Comments
 (0)