I often find a command in the search and really want its directory, not the command itself: the repo I built something in, or the folder I edited a config in. switch-context filters the list to that context, but it doesn’t take the shell there.
This was asked for in #1450 (the “cd to the path where the command was run” part). #1494 shows a zsh/fzf plugin built around the same need.
I’d like to propose two keymap actions:
accept-cd: close the search and runcdto the selected entry’s directory.return-cd: put thatcdon the command line instead, likereturn-selection.
No default binding; users bind them, e.g. [keymap.prefix] "g" = "accept-cd". They also work from the inspector.
The path would be quoted for each shell the integration supports (bash/zsh/fish, nushell, xonsh, PowerShell). Entries without a usable directory (imported history records unknown) would close the search like return-original.
I have a working implementation, tested with bash, zsh and fish (the shells CI runs) and with nushell, xonsh and pwsh locally. I’d be happy to open a PR if this sounds useful.