From 3d86b528df41750d8b8730b8457b537f9c2f7425 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 4 Apr 2026 08:31:36 +0900 Subject: modified lf/lfrc --- ar/.config/lf/lfrc | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'ar') diff --git a/ar/.config/lf/lfrc b/ar/.config/lf/lfrc index 328a5fc..46999dc 100644 --- a/ar/.config/lf/lfrc +++ b/ar/.config/lf/lfrc @@ -184,7 +184,11 @@ cmd trash ${{ while [ "$files" ]; do file=${files%%;*} - trash-put "$(basename "$file")" + trash-put "$(basename "$file")" || { + printf "sudo delete?[y/N]" + read ans + [ $ans = "y" ] && sudo rm -rf -- $fx + } if [ "$files" = "$file" ]; then files='' else @@ -387,27 +391,36 @@ cmd select-mime &{{ case "$1" in -*) - # Exclusion: grep -v (e.g., -inode/directory for files) pattern="${1#-}" - files=$(find "$PWD" -mindepth 1 -maxdepth 1 \ + find "$PWD" -mindepth 1 -maxdepth 1 \ $([ "$lf_hidden" = false ] && printf '%s\n' ! -name '.*') -print | file -L --mime-type -f - | grep -v "$pattern" | cut -d: -f1 | - sort -f | - sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/"/' | - tr '\n' ' ') + sort -f > /tmp/lf-select-mime-$$ ;; *) - # Inclusion: grep pattern - files=$(find "$PWD" -mindepth 1 -maxdepth 1 \ + find "$PWD" -mindepth 1 -maxdepth 1 \ $([ "$lf_hidden" = false ] && printf '%s\n' ! -name '.*') -print | file -L --mime-type -f - | grep "$1" | cut -d: -f1 | - sort -f | - sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/"/' | - tr '\n' ' ') + sort -f > /tmp/lf-select-mime-$$ ;; esac - [ -n "$files" ] && lf -remote "send $id :unselect; toggle $files" + [ -s /tmp/lf-select-mime-$$ ] || { rm -f /tmp/lf-select-mime-$$; exit; } + + lf -remote "send $id unselect" + batch="" + while IFS= read -r file; do + quoted=$(printf '%s' "$file" | sed 's/\\/\\\\/g;s/"/\\"/g') + candidate="$batch \"$quoted\"" + if [ ${#candidate} -gt 8000 ]; then + lf -remote "send $id toggle $batch" + batch="\"$quoted\"" + else + batch="$candidate" + fi + done < /tmp/lf-select-mime-$$ + [ -n "$batch" ] && lf -remote "send $id toggle $batch" + rm -f /tmp/lf-select-mime-$$ }} cmd select-dirs select-mime 'inode/directory' cmd select-files select-mime '-inode/directory' -- cgit v1.2.3