diff options
Diffstat (limited to 'home-manager/config/lf/cmds/stripspace')
-rwxr-xr-x | home-manager/config/lf/cmds/stripspace | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/home-manager/config/lf/cmds/stripspace b/home-manager/config/lf/cmds/stripspace new file mode 100755 index 00000000..bcbfa018 --- /dev/null +++ b/home-manager/config/lf/cmds/stripspace @@ -0,0 +1,36 @@ +#! /usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +# . ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH + +LIB_TEMP_DIR_FOR_SCRIPT=$(mktemp -d) + +files=$(mktmp); +echo "$fx" > $files; + +awk_source=$(mktmp); +cat << OFT > $awk_source +BEGIN {FS=" "} +{for (i=1; i != NF + 1; i++) + if (i == NF) { + parts[i]=tolower(\$i); + } else { + parts[i]=tolower(\$i"_"); + } +} +END {for (i in parts) printf parts[i]} +OFT + +while read -r file; do + dirty_name=$(mktmp) + basename "$file" > $dirty_name; + clean_name=$(awk -f "$awk_source" "$dirty_name"); + + [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!"; + mv "$(cat $dirty_name)" "$clean_name" || die "Move failed"; + lf -remote 'send reload' +done < "$files"; + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh |