Files
dotfiles/dot_local/bin/executable_yazi-nvim-open
T
Prad Nukala 03a03980de mise ~/.config/mise/config.toml tools: crush@0.91.0
feat(cli): add omarchy-cycle scripts for window cycling
2026-08-24 10:04:18 -05:00

27 lines
918 B
Bash
Executable File

#!/bin/sh
# Yazi `edit` opener. Inside a Neovim terminal ($NVIM set) files open in the
# HOST instance via _G.EditFromYazi (see ~/.config/nvim/lua/config/yazi_session.lua)
# and the yazi window hides itself; standalone yazi gets a regular blocking nvim.
#
# usage: nvim-open.sh [vsplit|split|tabedit] file... (default mode: edit)
case "$1" in
vsplit | split | tabedit) mode="$1"; shift ;;
*) mode="edit" ;;
esac
[ -n "$YAZI_OPEN_TRACE" ] && printf 'NVIM=%s MODE=%s ARGS=%s\n' "$NVIM" "$mode" "$*" >> "$YAZI_OPEN_TRACE"
if [ -z "$NVIM" ]; then
# split modes are meaningless outside an nvim terminal — quiet no-op
[ "$mode" = "edit" ] || exit 0
exec nvim "$@"
fi
for f in "$@"; do
abs=$(realpath -- "$f") || continue
# escape for a vimscript double-quoted string
esc=$(printf '%s' "$abs" | sed 's/[\\"]/\\&/g')
nvim --server "$NVIM" --remote-expr "v:lua.EditFromYazi(\"$mode\", \"$esc\")"
done