Change the shell directory on exit
Development reference · View source
Like Yazi, Runyte cannot change the directory of the shell that launched it.
Start it through a shell function that passes --cwd-file; then :quit-here
(:qh) exits and moves the shell.
| Command | Shell directory afterwards |
|---|---|
:quit-here / :qh | The active explorer directory, or the active file’s parent |
:quit-here! / :qh! | The same, discarding unsaved changes |
:quit from the last pane, :quit-all | Unchanged; returns to another running session when possible |
A pathless view uses the last explorer directory visited in that pane, then
the working directory set by :cd. :quit-here keeps the normal
unsaved-change protection.
Bash or Zsh
Add this to the shell configuration:
function runyte() {
local runyte_tmp runyte_cwd runyte_exit
runyte_tmp="$(mktemp -t 'runyte-cwd.XXXXXX')" || return
command runyte --cwd-file "$runyte_tmp" "$@"
runyte_exit=$?
if [ "$runyte_exit" -eq 0 ] && IFS= read -r -d '' runyte_cwd < "$runyte_tmp"; then
[ -n "$runyte_cwd" ] && [ "$runyte_cwd" != "$PWD" ] && [ -d "$runyte_cwd" ] && builtin cd -- "$runyte_cwd"
fi
command rm -f -- "$runyte_tmp"
return "$runyte_exit"
}
Windows PowerShell 5.1
Save runyte.ps1 somewhere stable and dot-source it from your PowerShell profile:
. 'C:\Tools\Runyte\runyte.ps1'
- The function starts
runyte.exeand waits for it.:quitleaves the caller’s directory alone; a successful:quit-herechanges it using a literal path. - It returns the editor’s status in
$LASTEXITCODE, or a nonzero status if the wrapper fails. - The handoff needs private local NTFS temporary storage.
- The destination needs an identity-equivalent ordinary local or UNC spelling shorter than 260 UTF-16 units, with valid Unicode components. Other paths are refused before quitting.
- The bounded, versioned handoff record keeps UTF-16 code units; it differs from the Unix NUL-terminated byte format.
- PowerShell 7 has not been validated for this wrapper.
How it behaves
- After reloading the shell configuration, run
runyteas usual. --cwd-fileis for shell integration. Runyte writes it only after a successful:quit-here.- Without the wrapper,
:quit-hererefuses to exit and explains how to enable it, rather than acting like:quit. - Session commands such as
--session-listaccept the option but leave the file alone, so they work through the same function. - Persistent sessions (Unix and Windows):
:quit-hereruns in the host, which reports the chosen directory, and the attached client writes the file. The same wrapper serves both modes, and the directory follows you across workspace switches. - The capability belongs to the client, not the host: a client launched without the wrapper is refused even if an earlier one had it.
- On Windows, the frontend writes the handoff after restoring the terminal.
- In mux mode
:quit-herestops the session after the same checks as:quit. Use:detachto keep the host running.