Allow using the cwd of the oldest as well as the newest foreground process for launch --cwd

This commit is contained in:
Kovid Goyal
2022-04-13 15:31:17 +05:30
parent e187110611
commit feea6998f8
4 changed files with 35 additions and 18 deletions

View File

@@ -67,7 +67,10 @@ to the newly opened window.
The working directory for the newly launched child. Use the special value
:code:`current` to use the working directory of the currently active window.
The special value :code:`last_reported` uses the last working directory
reported by the shell (needs :ref:`shell_integration` to work).
reported by the shell (needs :ref:`shell_integration` to work). The special
value :code:`oldest` works like :code:`current` but uses the working directory
of the oldest foreground process associated with the currently active window
rather than the newest foreground process.
--env
@@ -382,6 +385,8 @@ def launch(
elif opts.cwd == 'last_reported':
if active:
kw['cwd_from'] = CwdRequest(active, CwdRequestType.last_reported)
elif opts.cwd == 'oldest':
kw['cwd_from'] = CwdRequest(active, CwdRequestType.last_reported)
else:
kw['cwd'] = opts.cwd
if opts.location != 'default':