Merge branch 'feat/cwd-sync'

Keep the file manager panel and the shell in the same directory in both
directions, through the shell integration instead of typing commands.
This commit is contained in:
BlackAngelTV committed 2026-11-12 07:32:09 +01:00
commit 38c4975943
13 files changed
+546 -10

No files matched your search

+27
View File
@@ -48,6 +48,29 @@ directories first, then files sorted by size, largest first.
egr()
agr('shell', 'Shell synchronisation')
opt(
'sync_cwd',
'yes',
option_type='to_bool',
long_text="""
Keep the shell's working directory and the panel in step. A :code:`cd` in the
shell moves the panel to the same directory, and walking through the panel moves
the shell to the directory being browsed at its next prompt. Quitting the panel
without validating a directory withdraws a request the shell has not read yet.
The exchange goes through two small files in the session directory kitty
exports as :envvar:`KITTY_CWD_SYNC_DIR`, so nothing is typed into the shell:
the command never lands in the history and a half typed multi-line command is
left untouched. Bash, zsh and fish are supported by their kitty shell
integration; other shells keep the current behaviour. Set :code:`sync_cwd no`
to keep the two directories independent.
""",
)
egr()
agr('opening', 'Opening files')
opt(
@@ -219,6 +242,10 @@ def handle_result(args: list[str], data: dict[str, Any], target_window_id: int,
action, path = data.get('action'), data.get('path')
if action != 'cd' or not path:
return
if data.get('sync'):
# The panel published the directory in the session file and the shell
# picks it up from its prompt hook, see the sync_cwd option.
return
w = boss.window_id_map.get(target_window_id)
if w is None:
boss.ring_bell_if_allowed()