summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-11-03 23:59:02 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-11-03 23:59:02 +0400
commit87b30db073936b4830fd1e534d8c380db5fb403c (patch)
treea69b6ad1497a7890446c1de3f677fad1f8ffc4d8
parentc1a7442c8b11906b878200424157ef2a85a3374c (diff)
fix(lf): remove files that have spaces in them
-rw-r--r--config/lf/lfrc11
1 files changed, 7 insertions, 4 deletions
diff --git a/config/lf/lfrc b/config/lf/lfrc
index 40b6272..fa4e307 100644
--- a/config/lf/lfrc
+++ b/config/lf/lfrc
@@ -32,17 +32,20 @@ set rulerfmt "\033[32;1;7m"
set promptfmt "\033[48;1;234m %w/%f"
+# Use a custom separator to safely split filenames that contain spaces.
+set filesep " / "
+
cmd trash ${{
set -f
mkdir -p ~/.trash
- for entry in $fx; do
- trash_path=~/.trash/$(basename -- "${entry}")
+ echo "$fx" | sed 's/ \/ /\n/g' | while IFS= read -r file; do
+ tmp=~/.trash/$(basename -- "${file}")
+ trash_path=$(printf '%s' "$tmp" | tr ' ' '_')
if [ -e "${trash_path}" ]; then
printf '%s exists\n' "${trash_path}" >&2
trash_path="${trash_path}_$(date +%s)_$RANDOM"
printf 'moving to %s\n' "${trash_path}" >&2
fi
-
- mv -- "${entry}" "${trash_path}"
+ mv -- "${file}" "${trash_path}"
done
}}