diff options
38 files changed, 389 insertions, 351 deletions
diff --git a/home-manager/config/lf/cmds/archive.sh b/home-manager/config/lf/cmds/archive index 86c3d12d..b25cb3e1 100644..100755 --- a/home-manager/config/lf/cmds/archive.sh +++ b/home-manager/config/lf/cmds/archive @@ -1,8 +1,10 @@ -#!/usr/bin/env dash +#! /usr/bin/env dash # shellcheck disable=SC2086 -# shellcheck source=/home/dt/.local/lib/shell/lib +# shellcheck source=/dev/null +# . ~/.local/lib/shell/lib . %SHELL_LIBRARY_PATH +LIB_TEMP_DIR_FOR_SCRIPT=$(mktemp -d) # Option '-f' disables pathname expansion which can be useful when $f, $fs, and # $fx variables contain names with '*' or '?' characters. However, this option @@ -11,16 +13,16 @@ set -f archivers=$(mktmp) -echo "tar+zip tar+xz 7z zip" > $archivers; +echo "gzip xz 7z zip" > $archivers; readp "File Name: " name case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in - "tar+zip") + "gzip") tar -czf "$name".tar.gz "$fx" ;; - "tar+xz") + "xz") tar -cf "$name".tar "$fx" xz -z -9 -e -T0 "$name".tar ;; @@ -33,6 +35,5 @@ case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in esac - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/broot_jump b/home-manager/config/lf/cmds/broot_jump new file mode 100755 index 00000000..01273507 --- /dev/null +++ b/home-manager/config/lf/cmds/broot_jump @@ -0,0 +1,21 @@ +#! /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) + +tmp=$(mktmp) +res="$(broot --outcmd $tmp && cat $tmp | sed 's/cd //')" + +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi + +lf -remote "send $id $cmd \"$res\"" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/broot_jump.sh b/home-manager/config/lf/cmds/broot_jump.sh deleted file mode 100644 index 00d04b2b..00000000 --- a/home-manager/config/lf/cmds/broot_jump.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -f=$(mktemp) -res="$(broot --outcmd $f && cat $f | sed 's/cd //')" -rm -f "$f" -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi -lf -remote "send $id $cmd \"$res\"" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/chmod b/home-manager/config/lf/cmds/chmod new file mode 100755 index 00000000..9cdebffc --- /dev/null +++ b/home-manager/config/lf/cmds/chmod @@ -0,0 +1,21 @@ +#! /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) + +readp "Mode Bits: " bits + +files=$(mktmp); +echo "$fx" > $files; + +while read -r file; do + chmod "$bits" "$file" +done < "$files" + +lf -remote 'send reload' + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/chmod.sh b/home-manager/config/lf/cmds/chmod.sh deleted file mode 100644 index c7bb6ff8..00000000 --- a/home-manager/config/lf/cmds/chmod.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -readp "Mode Bits: " ans - -for file in $fx -do - chmod "$ans" "$file" -done - -lf -remote 'send reload' - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/clear_trash.sh b/home-manager/config/lf/cmds/clear_trash index d732756f..1de81b7f 100644..100755 --- a/home-manager/config/lf/cmds/clear_trash.sh +++ b/home-manager/config/lf/cmds/clear_trash @@ -1,11 +1,13 @@ -#!/usr/bin/env dash +#! /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) # could also use --force, for instand removal trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/dl_file.sh b/home-manager/config/lf/cmds/dl_file index ac6d6ded..dfd11f69 100644..100755 --- a/home-manager/config/lf/cmds/dl_file.sh +++ b/home-manager/config/lf/cmds/dl_file @@ -1,8 +1,11 @@ -#!/usr/bin/env dash +#! /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) + # Provides the ability to download a file by dropping it into a window url=$(dragon -t -x) @@ -26,11 +29,10 @@ if [ -n "$url" ]; then done # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || exit 1 + [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" else - exit 1 + die "Url is not valid!" fi - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/dragon b/home-manager/config/lf/cmds/dragon new file mode 100755 index 00000000..512d04b0 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon @@ -0,0 +1,12 @@ +#! /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) + +dragon -a -x "$fx" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/dragon.sh b/home-manager/config/lf/cmds/dragon.sh deleted file mode 100644 index be91a951..00000000 --- a/home-manager/config/lf/cmds/dragon.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -dragon -a -x "$fx" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dragon_individual b/home-manager/config/lf/cmds/dragon_individual new file mode 100755 index 00000000..bcda1288 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon_individual @@ -0,0 +1,12 @@ +#! /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) + +dragon "$fx" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/dragon_individual.sh b/home-manager/config/lf/cmds/dragon_individual.sh deleted file mode 100644 index 8215a20b..00000000 --- a/home-manager/config/lf/cmds/dragon_individual.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -dragon "$fx" - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/dragon_stay b/home-manager/config/lf/cmds/dragon_stay new file mode 100755 index 00000000..be75e233 --- /dev/null +++ b/home-manager/config/lf/cmds/dragon_stay @@ -0,0 +1,12 @@ +#! /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) + +dragon -a "$fx" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/dragon_stay.sh b/home-manager/config/lf/cmds/dragon_stay.sh deleted file mode 100644 index bf5bb7dd..00000000 --- a/home-manager/config/lf/cmds/dragon_stay.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -dragon -a "$fx" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/fzf_jump b/home-manager/config/lf/cmds/fzf_jump new file mode 100755 index 00000000..464a9fd4 --- /dev/null +++ b/home-manager/config/lf/cmds/fzf_jump @@ -0,0 +1,18 @@ +#! /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) + +res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi +lf -remote "send $id $cmd \"$res\"" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/fzf_jump.sh b/home-manager/config/lf/cmds/fzf_jump.sh deleted file mode 100644 index 7e3bb9d0..00000000 --- a/home-manager/config/lf/cmds/fzf_jump.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')" -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi -lf -remote "send $id $cmd \"$res\"" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/help b/home-manager/config/lf/cmds/help new file mode 100755 index 00000000..d7a28f71 --- /dev/null +++ b/home-manager/config/lf/cmds/help @@ -0,0 +1,12 @@ +#! /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) + +cat ~/.config/lf/lfrc | less # TODO make this better + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/help.sh b/home-manager/config/lf/cmds/help.sh deleted file mode 100644 index 5eb64dd5..00000000 --- a/home-manager/config/lf/cmds/help.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -cat ~/.config/lf/lfrc - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_dir b/home-manager/config/lf/cmds/mk_dir new file mode 100755 index 00000000..bfd6b2df --- /dev/null +++ b/home-manager/config/lf/cmds/mk_dir @@ -0,0 +1,13 @@ +#! /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) + +readp "Directory Name: " dir +mkdir "$dir" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/mk_dir.sh b/home-manager/config/lf/cmds/mk_dir.sh deleted file mode 100644 index aaffce5f..00000000 --- a/home-manager/config/lf/cmds/mk_dir.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -readp "Directory Name: " ans -mkdir $ans - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_file b/home-manager/config/lf/cmds/mk_file new file mode 100755 index 00000000..a7e4cacf --- /dev/null +++ b/home-manager/config/lf/cmds/mk_file @@ -0,0 +1,13 @@ +#! /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) + +readp "File Name: " name +"$EDITOR" "$name" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/mk_file.sh b/home-manager/config/lf/cmds/mk_file.sh deleted file mode 100644 index 14fc8881..00000000 --- a/home-manager/config/lf/cmds/mk_file.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -readp "File Name: " name -$EDITOR "$name" - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/mk_ln.sh b/home-manager/config/lf/cmds/mk_ln index f2129763..6b9e2b30 100644..100755 --- a/home-manager/config/lf/cmds/mk_ln.sh +++ b/home-manager/config/lf/cmds/mk_ln @@ -1,8 +1,11 @@ -#!/usr/bin/env dash +#! /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) + while IFS= read -r i;do set -- "$@" "$i" done < "$(tmp 'cat ~/.local/share/lf/files')" @@ -15,21 +18,18 @@ if [ "$#" -lt 1 ]; then exit 0 fi - case "$mode" in copy) while [ "$#" -gt 0 ]; do file="$1" ans="$(basename "$file")" - while ls -a "$(pwd)" | grep --word-regexp "$ans" > /dev/null;do + while [ -e "$ans" ];do printf "\"%s\" already exists, new name for link: " "$ans" read -r ans done ln -s "$file" "$(pwd)/$ans" - - shift done ;; @@ -37,7 +37,5 @@ esac rm ~/.local/share/lf/files # lf -remote "send clear" - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/mk_scr b/home-manager/config/lf/cmds/mk_scr new file mode 100755 index 00000000..12efe315 --- /dev/null +++ b/home-manager/config/lf/cmds/mk_scr @@ -0,0 +1,38 @@ +#! /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) + +script=$(mktmp) +cat << EOF > $script +#!/usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. %SHELL_LIBRARY_PATH + +LIB_TEMP_DIR_FOR_SCRIPT=\$(mktemp -d) + + + + +if [ -d "\$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "\$LIB_TEMP_DIR_FOR_SCRIPT"; fi +EOF + +readp "Script Name: " script_name +scr="$(pwd)"/"$script_name" + +while [ -e "$scr" ];do + readp "$script_name already exists, new name for script: " script_name + scr="$(pwd)"/"$script_name" +done + +cat "$script" > "$scr" +chmod +x "$scr" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi + +"$VISUAL" "$scr" +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/mk_scr.sh b/home-manager/config/lf/cmds/mk_scr.sh deleted file mode 100644 index 0441c63f..00000000 --- a/home-manager/config/lf/cmds/mk_scr.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -star=$(mktmp) -cat << EOF > $star -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -LIB_TEMP_DIR_FOR_SCRIPT=\$(mktemp -d) - - - - -if [ -d "\$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "\$LIB_TEMP_DIR_FOR_SCRIPT"; fi -EOF - -readp "Script Name: " script_name -scr="$(pwd)"/"$script_name" - -[ -e $scr ] && die "$script_name exist, exiting.." - -cat "$star" > $scr -chmod +x $scr -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi - -$VISUAL $scr diff --git a/home-manager/config/lf/cmds/open b/home-manager/config/lf/cmds/open new file mode 100755 index 00000000..e7f1efd7 --- /dev/null +++ b/home-manager/config/lf/cmds/open @@ -0,0 +1,16 @@ +#! /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) + +case $(file --mime-type "$f" -bL) in + text/*|application/json) "$EDITOR" "$f";; + image/*) "$IVIEWER" "$f";; + *) xdg-open "$f";; +esac + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/open.sh b/home-manager/config/lf/cmds/open.sh deleted file mode 100644 index bcfe62f4..00000000 --- a/home-manager/config/lf/cmds/open.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -case $(file --mime-type "$f" -bL) in - text/*|application/json) $EDITOR "$f";; - image/*) $IVIEWER "$f";; - *) xdg-open "$f" ;; -esac - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/open_config b/home-manager/config/lf/cmds/open_config new file mode 100755 index 00000000..342183e0 --- /dev/null +++ b/home-manager/config/lf/cmds/open_config @@ -0,0 +1,12 @@ +#! /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) + +"$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO implement this + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/open_config.sh b/home-manager/config/lf/cmds/open_config.sh deleted file mode 100644 index 4b103fe4..00000000 --- a/home-manager/config/lf/cmds/open_config.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -$EDITOR "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/restore_trash b/home-manager/config/lf/cmds/restore_trash new file mode 100755 index 00000000..02527b48 --- /dev/null +++ b/home-manager/config/lf/cmds/restore_trash @@ -0,0 +1,12 @@ +#! /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) + +trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/restore_trash.sh b/home-manager/config/lf/cmds/restore_trash.sh deleted file mode 100644 index fd4641eb..00000000 --- a/home-manager/config/lf/cmds/restore_trash.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/set_wall_paper b/home-manager/config/lf/cmds/set_wall_paper new file mode 100755 index 00000000..637dddd5 --- /dev/null +++ b/home-manager/config/lf/cmds/set_wall_paper @@ -0,0 +1,15 @@ +#! /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) + +die "No yet implemented" # TODO do what the 'die' says +#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv +#swaybg -i "$f" & +#feh --bg-max --no-fehbg "$f" + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/set_wall_paper.sh b/home-manager/config/lf/cmds/set_wall_paper.sh deleted file mode 100644 index 6ad9fc1f..00000000 --- a/home-manager/config/lf/cmds/set_wall_paper.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -die "No yet implemented" -#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv -#swaybg -i "$f" & -#feh --bg-max --no-fehbg "$f" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi 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 diff --git a/home-manager/config/lf/cmds/stripspace.sh b/home-manager/config/lf/cmds/stripspace.sh deleted file mode 100644 index 0032be26..00000000 --- a/home-manager/config/lf/cmds/stripspace.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -die "This is still TODO" -#stripspace "$f" # TODO - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/sudo_mk_file.sh b/home-manager/config/lf/cmds/sudo_mk_file.sh deleted file mode 100644 index c1443da0..00000000 --- a/home-manager/config/lf/cmds/sudo_mk_file.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -readp "File Name: " ans -sudo $EDITOR "$ans" - - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/config/lf/cmds/trash.sh b/home-manager/config/lf/cmds/trash index 57351b78..ca68cfc1 100644..100755 --- a/home-manager/config/lf/cmds/trash.sh +++ b/home-manager/config/lf/cmds/trash @@ -1,8 +1,11 @@ -#!/usr/bin/env dash +#! /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=$(printf "$fx" | tr '\n' ';') # #while [ "$files" ]; do @@ -22,6 +25,5 @@ #done thrash put "$fx"; - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/cmds/unarchive.sh b/home-manager/config/lf/cmds/unarchive index 498ae424..a28879da 100644..100755 --- a/home-manager/config/lf/cmds/unarchive.sh +++ b/home-manager/config/lf/cmds/unarchive @@ -1,8 +1,10 @@ -#!/usr/bin/env dash +#! /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) # extract the current file with the right command # (xkcd link: https://xkcd.com/1168/) @@ -20,6 +22,5 @@ case "$f" in *) die "Unsupported format" ;; esac - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/lf/default.nix b/home-manager/config/lf/default.nix index f41e3b24..0a08d99c 100644 --- a/home-manager/config/lf/default.nix +++ b/home-manager/config/lf/default.nix @@ -59,77 +59,51 @@ in { enable = true; commands = { - help = shell { - file = ./cmds/help.sh; - dependencies = []; - }; - open = shell { - file = ./cmds/open.sh; - dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils;}; - }; - mk_dir = pipe { - file = ./cmds/mk_dir.sh; - dependencies = []; - }; - mk_scr = shell { - file = ./cmds/mk_scr.sh; - dependencies = []; - }; - mk_file = shell { - file = ./cmds/mk_file.sh; - dependencies = []; - }; - chmod = pipe { - file = ./cmds/chmod.sh; - dependencies = []; - }; - mk_ln = pipe { - file = ./cmds/mk_ln.sh; - dependencies = []; - }; - sudo_mk_file = shell { - file = ./cmds/sudo_mk_file.sh; - dependencies = []; - }; - set_wall_paper = pipe { - file = ./cmds/set_wall_paper.sh; - dependencies = []; - }; - fzf_jump = shell { - file = ./cmds/fzf_jump.sh; + archive = shell { + file = ./cmds/archive; dependencies = builtins.attrValues { - inherit (pkgs) fzf; + inherit + (pkgs) + fzf + gnutar + xz + p7zip + zip + ; }; }; broot_jump = shell { - file = ./cmds/broot_jump.sh; + file = ./cmds/broot_jump; dependencies = builtins.attrValues { inherit (pkgs) broot; }; }; - open_config = shell { - file = ./cmds/open_config.sh; + chmod = pipe { + file = ./cmds/chmod; + dependencies = []; + }; + clear_trash = shell { + file = ./cmds/clear_trash; dependencies = builtins.attrValues { - #inherit - #(pkgs) - ## TODO rewrite this: bookmenu, https://github.com/jarun/buku - # - #buku - #; + inherit + (pkgs) + fzf + trashy + ; }; }; - - dragon = pipe { - file = ./cmds/dragon.sh; + dl_file = pipe { + file = ./cmds/dl_file; dependencies = builtins.attrValues { inherit (pkgs) xdragon + curl ; }; }; - dragon_stay = pipe { - file = ./cmds/dragon_stay.sh; + dragon = pipe { + file = ./cmds/dragon; dependencies = builtins.attrValues { inherit (pkgs) @@ -138,7 +112,7 @@ in { }; }; dragon_individual = pipe { - file = ./cmds/dragon_individual.sh; + file = ./cmds/dragon_individual; dependencies = builtins.attrValues { inherit (pkgs) @@ -146,78 +120,96 @@ in { ; }; }; - dl_file = pipe { - file = ./cmds/dl_file.sh; + dragon_stay = pipe { + file = ./cmds/dragon_stay; dependencies = builtins.attrValues { inherit (pkgs) xdragon - curl ; }; }; - - unarchive = pipe { - file = ./cmds/unarchive.sh; + fzf_jump = shell { + file = ./cmds/fzf_jump; dependencies = builtins.attrValues { - inherit - (pkgs) - gnutar - unzip - # TODO this is unfree! unrar - - p7zip - ; + inherit (pkgs) fzf; }; }; - archive = pipe { - file = ./cmds/archive.sh; + help = shell { + file = ./cmds/help; + dependencies = []; + }; + mk_dir = pipe { + file = ./cmds/mk_dir; + dependencies = []; + }; + mk_file = shell { + file = ./cmds/mk_file; + dependencies = []; + }; + mk_ln = pipe { + file = ./cmds/mk_ln; + dependencies = []; + }; + mk_scr = shell { + file = ./cmds/mk_scr; + dependencies = []; + }; + open = shell { + file = ./cmds/open; + dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils;}; + }; + open_config = shell { + file = ./cmds/open_config; dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - gnutar - xz - p7zip - zip - ; + #inherit + #(pkgs) + ## TODO rewrite this: bookmenu, https://github.com/jarun/buku + # + #buku + #; }; }; - - trash = pipe { - file = ./cmds/trash.sh; + restore_trash = shell { + file = ./cmds/restore_trash; dependencies = builtins.attrValues { inherit (pkgs) + fzf trashy ; }; }; - clear_trash = pipe { - file = ./cmds/clear_trash.sh; + set_wall_paper = pipe { + file = ./cmds/set_wall_paper; + dependencies = []; + }; + stripspace = pipe { + file = ./cmds/stripspace; + dependencies = []; + }; + trash = pipe { + file = ./cmds/trash; dependencies = builtins.attrValues { inherit (pkgs) - fzf trashy ; }; }; - restore_trash = shell { - file = ./cmds/restore_trash.sh; + unarchive = pipe { + file = ./cmds/unarchive; dependencies = builtins.attrValues { inherit (pkgs) - fzf - trashy + gnutar + unzip + # TODO this is unfree! unrar + + p7zip ; }; }; - - stripspace = pipe { - file = ./cmds/stripspace.sh; - dependencies = []; - }; }; keybindings = { # Remove some defaults @@ -257,7 +249,7 @@ in { #dc = "cpdragon"; dl = "dlfile"; - ss = "stripspace"; + cs = "stripspace"; # Vim keys h = "updir"; |