diff options
Diffstat (limited to '')
24 files changed, 375 insertions, 178 deletions
diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix index 1cb6996a..f5372a38 100644 --- a/hm/soispha/conf/lf/commands/default.nix +++ b/hm/soispha/conf/lf/commands/default.nix @@ -233,7 +233,7 @@ in { gnutar unzip # TODO: this is unfree! unrar - + p7zip ; }; diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh index 5f4e3792..9ac07898 100755 --- a/hm/soispha/conf/lf/commands/scripts/archive.sh +++ b/hm/soispha/conf/lf/commands/scripts/archive.sh @@ -9,46 +9,52 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # times. set -f -archivers="$(tmp echo gzip xz 7z zip)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" + +archivers="$(tmp echo gzip xz 7z zip)" prompt "Archive name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Archive already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Archive name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Archive already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Archive name: " + fi fi - fi done -root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; +root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/"; fi)" # fx contains all selected file name separated by a newline while read -r raw_file; do - file="$(echo "$raw_file" | sed "s|$root||")"; - set -- "$@" "$file"; -done < "$(tmp echo "$fx")"; + file="$(echo "$raw_file" | sed "s|$root||")" + set -- "$@" "$file" +done <"$(tmp echo "$fx")" case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in - "gzip") - tar -czf "$name".tar.gz "$@" - ;; - "xz") - tar -cf "$name".tar "$@" - xz -z -9 -e -T0 "$name".tar - ;; - "7z") - 7z a "$name".7z "$@" - ;; - "zip") - zip --symlinks -r "$name".zip "$@" - ;; +"gzip") + tar -czf "$name".tar.gz "$@" + ;; +"xz") + tar -cf "$name".tar "$@" + xz -z -9 -e -T0 "$name".tar + ;; +"7z") + 7z a "$name".7z "$@" + ;; +"zip") + zip --symlinks -r "$name".zip "$@" + ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh index 0feb5daf..4afb36ac 100755 --- a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + tmp=$(mktmp) res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" diff --git a/hm/soispha/conf/lf/commands/scripts/chmod.sh b/hm/soispha/conf/lf/commands/scripts/chmod.sh index f2cc0dc8..81373352 100755 --- a/hm/soispha/conf/lf/commands/scripts/chmod.sh +++ b/hm/soispha/conf/lf/commands/scripts/chmod.sh @@ -3,11 +3,22 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + readp "Mode bits: " bits +# shellcheck disable=SC2269 +bits="$bits" while read -r file; do chmod "$bits" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" lf -remote 'send reload' # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh index 85fd3431..c17b7668 100755 --- a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh +++ b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh @@ -1,8 +1,17 @@ -#!/usr/bin/env dash +#!/usr/bin/env bash # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # source: https://github.com/gokcehan/lf/wiki/Tips#use-copy-on-write-when-possible # # # FIXME: Add this. The hardest part is in checking, if a file can be reflinked, as fuse and bind mount are hard to @@ -31,13 +40,13 @@ if [ "$mode" = 'copy' ]; then src_targets="$(df --output=target -- "$@" | sed '1d' | sort -u)" if [ "$(df --output=target -- "$PWD" | tail -n 1)" = \ - "$(echo "$src_targets" | tail -n 1)" ] && \ - (( "$(echo "$src_targets" | wc -l)" == 1 )) && \ + "$(echo "$src_targets" | tail -n 1)" ] && + (("$(echo "$src_targets" | wc -l)" == 1)) && [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then - echo 'selected copy and cp reflink paste' + echo 'selected copy and cp reflink paste' - start=$(date '+%s') + start=$(date '+%s') # Handle same names in dst # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... @@ -47,7 +56,7 @@ if [ "$mode" = 'copy' ]; then count=0 while [ -w "$PWD/$name" ]; do - count=$((count+1)) + count=$((count + 1)) name="$original.~$count~" done @@ -55,15 +64,15 @@ if [ "$mode" = 'copy' ]; then cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" set -e - if [ ! -z "$cp_out" ]; then + if [ -n "$cp_out" ]; then lf -remote "send $id echoerr $cp_out" exit 0 fi done - finish=$(( $(date '+%s') - $start )) + finish=$(($(date '+%s') - start)) t='' - if (( $finish > 2 )); then + if ((finish > 2)); then t="${finish}s" fi @@ -80,14 +89,14 @@ if [ "$mode" = 'copy' ]; then echo 'selected copy and lf native paste' lf -remote "send $id paste" lf -remote "send clear" - fi - - elif [ $mode = 'move' ]; then - echo 'selected move and lf native paste' - lf -remote "send $id paste" - lf -remote "send clear" fi +elif [ "$mode" = 'move' ]; then + echo 'selected move and lf native paste' + lf -remote "send $id paste" + lf -remote "send clear" +fi + # # for debug # set +x diff --git a/hm/soispha/conf/lf/commands/scripts/dl_file.sh b/hm/soispha/conf/lf/commands/scripts/dl_file.sh index 5092174f..4f97f9b9 100755 --- a/hm/soispha/conf/lf/commands/scripts/dl_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/dl_file.sh @@ -3,31 +3,41 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # Provides the ability to download a file by dropping it into a window url="$(dragon -t -x)" if [ -n "$url" ]; then - prompt "File Name: " - name="" - while [ -z "$name" ] || [ -e "$name" ] - do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans + prompt "File Name: " + name="" + while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File Name: " - fi - fi - done + if [ "$ans" = "y" ]; then + break + else + prompt "File Name: " + fi + fi + done - # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" + # Download the file with curl + if [ -n "$name" ]; then + curl -o "$name" "$url" || die "curl failed" + fi else - die "URL is null!" + die "URL is null!" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon.sh b/hm/soispha/conf/lf/commands/scripts/dragon.sh index 59a50920..70633583 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon -a -x "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh index 051537f9..500be67c 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh index 8f880848..273482ea 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do - set -- "$@" "$file"; -done < "$(tmp echo "$fx")" + set -- "$@" "$file" +done <"$(tmp echo "$fx")" dragon -a "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh index 172c44d3..6f8981f3 100755 --- a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh @@ -5,12 +5,20 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + if [ -f "$res" ]; then cmd="select" elif [ -d "$res" ]; then cmd="cd" fi - lf -remote "send $id $cmd \"$res\"" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/go_project_root.sh b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh index 9ed9f7ad..e1147fce 100755 --- a/hm/soispha/conf/lf/commands/scripts/go_project_root.sh +++ b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -flake_base_dir="$(search_flake_base_dir)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +flake_base_dir="$(search_flake_base_dir)" if [ "$flake_base_dir" ]; then lf -remote "send $id cd $flake_base_dir" || die "Bug: No base dir ($flake_base_dir)" else - die "Unable to locate base dir"; + die "Unable to locate base dir" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh index adf60d99..6079b85d 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "Directory Name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Directory already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Directory already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "Directory Name: " + if [ "$ans" = "y" ]; then + break + else + prompt "Directory Name: " + fi fi - fi done mkdir "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file.sh b/hm/soispha/conf/lf/commands/scripts/mk_file.sh index cdef38a0..9fb0a000 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "File name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh index 662b29ac..2007cc99 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "File name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh index f5dcd395..e767c848 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -while IFS= read -r i;do +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +while IFS= read -r i; do set -- "$@" "$i" -done < "$HOME"/.local/share/lf/files +done <"$HOME"/.local/share/lf/files mode="$1" shift @@ -16,20 +25,20 @@ if [ "$#" -eq 0 ]; then fi case "$mode" in - copy) - while [ "$#" -gt 0 ]; do - file="$1" - ans="$(basename "$file")" - - while [ -e "$ans" ];do - prompt "$ans already exists, new name for link: " - read -r ans - done - - ln -s "$file" "$(pwd)/$ans" - shift +copy) + while [ "$#" -gt 0 ]; do + file="$1" + ans="$(basename "$file")" + + while [ -e "$ans" ]; do + prompt "$ans already exists, new name for link: " + read -r ans done - ;; + + ln -s "$file" "$(pwd)/$ans" + shift + done + ;; esac rm ~/.local/share/lf/files # lf -remote "send clear" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh index 6e69fc4f..915725cc 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh @@ -3,29 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" prompt "Script name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi fi - fi done script="$(pwd)"/"$name" -cat "%SHELL_LIBRARY_TEMPLATE" > "$script" +cat "%SHELL_LIBRARY_TEMPLATE" >"$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh index 612ff19d..0f8394fa 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh @@ -3,30 +3,36 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" prompt "Script name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi fi - fi done script="$(pwd)"/"$name" -sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" +sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" >"$script" sed -i 's|dash|sh|' "$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open.sh b/hm/soispha/conf/lf/commands/scripts/open.sh index 3dd8f485..4df06dd8 100755 --- a/hm/soispha/conf/lf/commands/scripts/open.sh +++ b/hm/soispha/conf/lf/commands/scripts/open.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + case $(file --mime-type "$f" -bL) in - text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; - image/*) "$IVIEWER" "$f";; - *) xdg-open "$f";; +text/* | application/json | application/vnd.hp-HPGL) "$EDITOR" "$f" ;; +image/*) "$IVIEWER" "$f" ;; +*) xdg-open "$f" ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open_config.sh b/hm/soispha/conf/lf/commands/scripts/open_config.sh index 4054abdd..455ca25a 100755 --- a/hm/soispha/conf/lf/commands/scripts/open_config.sh +++ b/hm/soispha/conf/lf/commands/scripts/open_config.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + "$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO: implement this # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh index 94d26a26..7aeed7bf 100755 --- a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh index f7714880..828c0708 100755 --- a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh +++ b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + die "No yet implemented" # TODO: do what the 'die' says #sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv #nohub swaybg -i "$f" diff --git a/hm/soispha/conf/lf/commands/scripts/stripspace.sh b/hm/soispha/conf/lf/commands/scripts/stripspace.sh index c8781a60..65eefbcd 100755 --- a/hm/soispha/conf/lf/commands/scripts/stripspace.sh +++ b/hm/soispha/conf/lf/commands/scripts/stripspace.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -files=$(mktmp); -echo "$fx" > "$files"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" -awk_source=$(mktmp); -cat << OFT > "$awk_source" +files=$(mktmp) +echo "$fx" >"$files" + +awk_source=$(mktmp) +cat <<OFT >"$awk_source" BEGIN {FS=" "} {for (i=1; i != NF + 1; i++) if (i == NF) { @@ -21,11 +30,11 @@ OFT while read -r file; do dirty_name=$(mktmp) - basename "$file" > "$dirty_name"; - clean_name=$(awk -f "$awk_source" "$dirty_name"); + 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"; + [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!" + mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed" lf -remote 'send reload' -done < "$files"; +done <"$files" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/trash.sh b/hm/soispha/conf/lf/commands/scripts/trash.sh index 4da188e5..c605420e 100755 --- a/hm/soispha/conf/lf/commands/scripts/trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/trash.sh @@ -3,26 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -trash_output=$(mktmp); -expected_error_output=$(mktmp); +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +trash_output=$(mktmp) +expected_error_output=$(mktmp) while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" # TODO: why are we using trashy at all, when trash-cli can do everything? # # try trashy first, through nix because both trashy and trash-cli provide a trash command, which conflicts -nix run nixpkgs#trashy -- put "$@" 2> "$trash_output"; +nix run nixpkgs#trashy -- put "$@" 2>"$trash_output" # FIXME: Find a way, that does not depend on parsing an error message <2023-08-29> -cat << EOF > "$expected_error_output"; +cat <<EOF >"$expected_error_output" [1;31merror:[0m Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" } EOF -if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ];then - warning "Deleting with trash-cli to the /.Trash folder"; +if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ]; then + warning "Deleting with trash-cli to the /.Trash folder" # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this - trash-put "$@"; + trash-put "$@" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/unarchive.sh b/hm/soispha/conf/lf/commands/scripts/unarchive.sh index 1ecc702b..d52eee61 100755 --- a/hm/soispha/conf/lf/commands/scripts/unarchive.sh +++ b/hm/soispha/conf/lf/commands/scripts/unarchive.sh @@ -3,20 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # extract the current file with the right command # (xkcd link: https://xkcd.com/1168/) set -f # TODO: add support for multiple files at once case "$f" in - *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";; - *.tar.gz|*.tgz) tar xzvf "$f";; - *.tar.xz|*.txz) tar xJvf "$f";; - *.zip) unzip "$f";; - *.rar) - die "rar is a unfree format!" - #unrar x $f - ;; - *.7z) 7z x "$f";; - *) die "Unsupported format" ;; +*.tar.bz | *.tar.bz2 | *.tbz | *.tbz2) tar xjvf "$f" ;; +*.tar.gz | *.tgz) tar xzvf "$f" ;; +*.tar.xz | *.txz) tar xJvf "$f" ;; +*.zip) unzip "$f" ;; +*.rar) + die "rar is a unfree format!" + #unrar x $f + ;; +*.7z) 7z x "$f" ;; +*) die "Unsupported format" ;; esac # vim: ft=sh |