[yazi] Init
This commit is contained in:
1 parent
ba3e3927e5
commit
3d9d2532d2
27 files changed
+3414
-3
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
multiple="$1"
|
||||
directory="$2"
|
||||
save="$3"
|
||||
path="$4"
|
||||
out="$5"
|
||||
|
||||
termcmd="kitty --class=filechooser --title=Yazi-FileChooser -e"
|
||||
|
||||
cmd="yazi"
|
||||
|
||||
if [ "$save" = "1" ]; then
|
||||
set -- --chooser-file="$out" "$path"
|
||||
elif [ "$directory" = "1" ]; then
|
||||
set -- --chooser-file="$out" --cwd-file="$out.1" "$path"
|
||||
else
|
||||
set -- --chooser-file="$out" "$path"
|
||||
fi
|
||||
|
||||
# Escape and run
|
||||
command="$termcmd $cmd"
|
||||
for arg in "$@"; do
|
||||
escaped=$(printf '%s' "$arg" | sed 's/"/\\"/g')
|
||||
command="$command \"$escaped\""
|
||||
done
|
||||
|
||||
sh -c "$command"
|
||||
|
||||
# Handle directory selection (Yazi writes cwd on quit)
|
||||
if [ "$directory" = "1" ]; then
|
||||
if [ ! -s "$out" ] && [ -s "$out.1" ]; then
|
||||
cat "$out.1" > "$out"
|
||||
fi
|
||||
rm -f "$out.1"
|
||||
fi
|
||||
Reference in new issue
Block a user