zsh: add shell wrapper for yazi

This commit is contained in:
krolxon 2025-08-17 18:30:12 +05:30
parent 4df279d8cc
commit f5405e0092
1 changed files with 10 additions and 0 deletions

View File

@ -36,6 +36,16 @@ function zle-keymap-select () {
viins|main) echo -ne '\e[5 q';; # beam
esac
}
# Yazi shell wrapper
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
IFS= read -r -d '' cwd < "$tmp"
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
rm -f -- "$tmp"
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)