Session file: Allow specifying multiple cd directives per tab to have different windows launched with different working directories
This commit is contained in:
parent
ce230b071b
commit
c551384369
@ -286,7 +286,7 @@ command line flag. For example:
|
||||
....
|
||||
# Set the window layout for the current tab
|
||||
layout tall
|
||||
# Set the working directory for the current tab
|
||||
# Set the working directory for windows in the current tab
|
||||
cd ~
|
||||
# Create a window and run the specified command in it
|
||||
launch zsh
|
||||
|
||||
@ -41,7 +41,8 @@ class Session:
|
||||
cmd = shlex.split(cmd) if isinstance(cmd, str) else cmd
|
||||
else:
|
||||
cmd = None
|
||||
self.tabs[-1].windows.append(cmd)
|
||||
from .tabs import SpecialWindow
|
||||
self.tabs[-1].windows.append(SpecialWindow(cmd, cwd=self.tabs[-1].cwd))
|
||||
|
||||
def add_special_window(self, sw):
|
||||
self.tabs[-1].windows.append(sw)
|
||||
|
||||
@ -22,11 +22,11 @@ from .utils import color_as_int
|
||||
from .window import Window, calculate_gl_geometry
|
||||
|
||||
TabbarData = namedtuple('TabbarData', 'title is_active is_last')
|
||||
SpecialWindowInstance = namedtuple('SpecialWindow', 'cmd stdin override_title cwd_from')
|
||||
SpecialWindowInstance = namedtuple('SpecialWindow', 'cmd stdin override_title cwd_from cwd')
|
||||
|
||||
|
||||
def SpecialWindow(cmd, stdin=None, override_title=None, cwd_from=None):
|
||||
return SpecialWindowInstance(cmd, stdin, override_title, cwd_from)
|
||||
def SpecialWindow(cmd, stdin=None, override_title=None, cwd_from=None, cwd=None):
|
||||
return SpecialWindowInstance(cmd, stdin, override_title, cwd_from, cwd)
|
||||
|
||||
|
||||
class Tab: # {{{
|
||||
@ -109,7 +109,7 @@ class Tab: # {{{
|
||||
w.set_visible_in_layout(i, True)
|
||||
self.relayout()
|
||||
|
||||
def launch_child(self, use_shell=False, cmd=None, stdin=None, cwd_from=None):
|
||||
def launch_child(self, use_shell=False, cmd=None, stdin=None, cwd_from=None, cwd=None):
|
||||
if cmd is None:
|
||||
if use_shell:
|
||||
cmd = [shell_path]
|
||||
@ -122,12 +122,12 @@ class Tab: # {{{
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
ans = Child(cmd, self.cwd, self.opts, stdin, env, cwd_from)
|
||||
ans = Child(cmd, cwd or self.cwd, self.opts, stdin, env, cwd_from)
|
||||
ans.fork()
|
||||
return ans
|
||||
|
||||
def new_window(self, use_shell=True, cmd=None, stdin=None, override_title=None, cwd_from=None):
|
||||
child = self.launch_child(use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from)
|
||||
def new_window(self, use_shell=True, cmd=None, stdin=None, override_title=None, cwd_from=None, cwd=None):
|
||||
child = self.launch_child(use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd)
|
||||
window = Window(self, child, self.opts, self.args, override_title=override_title)
|
||||
# Must add child before laying out so that resize_pty succeeds
|
||||
get_boss().add_child(window)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user