$ # For bash — add this line to ~/.bashrc:
$ echo 'function y() { local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd; yazi "$@" --cwd-file="$tmp"; if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then builtin cd -- "$cwd"; fi; rm -f -- "$tmp"; }' >> ~/.bashrc && source ~/.bashrc
$
$ # For zsh — add this line to ~/.zshrc:
$ echo 'function y() { local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd; yazi "$@" --cwd-file="$tmp"; if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then builtin cd -- "$cwd"; fi; rm -f -- "$tmp"; }' >> ~/.zshrc && source ~/.zshrc
$
$ # For fish — add this to ~/.config/fish/config.fish:
$ echo 'function y; set tmp (mktemp -t "yazi-cwd.XXXXXX"); yazi $argv --cwd-file="$tmp"; if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]; builtin cd -- "$cwd"; end; rm -f -- "$tmp"; end' >> ~/.config/fish/config.fish