Implement --cwd=last_reported
This commit is contained in:
parent
72b1996423
commit
afa6128155
2 changed files with 10 additions and 1 deletions
|
|
@ -14,7 +14,7 @@
|
|||
from .tabs import Tab, TabManager
|
||||
from .types import run_once
|
||||
from .utils import log_error, resolve_custom_file, set_primary_selection, which
|
||||
from .window import CwdRequest, Watchers, Window
|
||||
from .window import CwdRequest, CwdRequestType, Watchers, Window
|
||||
|
||||
try:
|
||||
from typing import TypedDict
|
||||
|
|
@ -62,6 +62,8 @@ def options_spec() -> str:
|
|||
--cwd
|
||||
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).
|
||||
|
||||
|
||||
--env
|
||||
|
|
@ -359,6 +361,9 @@ def launch(
|
|||
if opts.cwd == 'current':
|
||||
if active:
|
||||
kw['cwd_from'] = CwdRequest(active)
|
||||
elif opts.cwd == 'last_reported':
|
||||
if active:
|
||||
kw['cwd_from'] = CwdRequest(active, CwdRequestType.last_reported)
|
||||
else:
|
||||
kw['cwd'] = opts.cwd
|
||||
if opts.location != 'default':
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ def modify_argv_for_launch_with_cwd(self, argv: List[str]) -> str:
|
|||
@property
|
||||
def cwd_of_child(self) -> Optional[str]:
|
||||
window = get_boss().window_id_map.get(self.window_id)
|
||||
if window and self.request_type is CwdRequestType.last_reported and window.screen.last_reported_cwd:
|
||||
cwd = path_from_osc7_url(window.screen.last_reported_cwd)
|
||||
if cwd:
|
||||
return cwd
|
||||
return window.cwd_of_child if window else None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue