From 59e6edd4fd818c60ca4ea416ae4d23163254dfa5 Mon Sep 17 00:00:00 2001 From: ene Date: Sun, 12 Mar 2023 01:29:28 +0100 Subject: Fix(hm/conf/lf): Rewrite some of the cmds --- home-manager/config/lf/cmds/archive | 39 +++++++++++++++++++++ home-manager/config/lf/cmds/archive.sh | 38 --------------------- home-manager/config/lf/cmds/broot_jump | 21 ++++++++++++ home-manager/config/lf/cmds/broot_jump.sh | 19 ----------- home-manager/config/lf/cmds/chmod | 21 ++++++++++++ home-manager/config/lf/cmds/chmod.sh | 17 ---------- home-manager/config/lf/cmds/clear_trash | 13 +++++++ home-manager/config/lf/cmds/clear_trash.sh | 11 ------ home-manager/config/lf/cmds/dl_file | 38 +++++++++++++++++++++ home-manager/config/lf/cmds/dl_file.sh | 36 -------------------- home-manager/config/lf/cmds/dragon | 12 +++++++ home-manager/config/lf/cmds/dragon.sh | 11 ------ home-manager/config/lf/cmds/dragon_individual | 12 +++++++ home-manager/config/lf/cmds/dragon_individual.sh | 10 ------ home-manager/config/lf/cmds/dragon_stay | 12 +++++++ home-manager/config/lf/cmds/dragon_stay.sh | 11 ------ home-manager/config/lf/cmds/fzf_jump | 18 ++++++++++ home-manager/config/lf/cmds/fzf_jump.sh | 17 ---------- home-manager/config/lf/cmds/help | 12 +++++++ home-manager/config/lf/cmds/help.sh | 9 ----- home-manager/config/lf/cmds/mk_dir | 13 +++++++ home-manager/config/lf/cmds/mk_dir.sh | 12 ------- home-manager/config/lf/cmds/mk_file | 13 +++++++ home-manager/config/lf/cmds/mk_file.sh | 11 ------ home-manager/config/lf/cmds/mk_ln | 41 ++++++++++++++++++++++ home-manager/config/lf/cmds/mk_ln.sh | 43 ------------------------ home-manager/config/lf/cmds/mk_scr | 38 +++++++++++++++++++++ home-manager/config/lf/cmds/mk_scr.sh | 30 ----------------- home-manager/config/lf/cmds/open | 16 +++++++++ home-manager/config/lf/cmds/open.sh | 16 --------- home-manager/config/lf/cmds/open_config | 12 +++++++ home-manager/config/lf/cmds/open_config.sh | 10 ------ home-manager/config/lf/cmds/restore_trash | 12 +++++++ home-manager/config/lf/cmds/restore_trash.sh | 11 ------ home-manager/config/lf/cmds/set_wall_paper | 15 +++++++++ home-manager/config/lf/cmds/set_wall_paper.sh | 15 --------- home-manager/config/lf/cmds/stripspace | 36 ++++++++++++++++++++ home-manager/config/lf/cmds/stripspace.sh | 11 ------ home-manager/config/lf/cmds/sudo_mk_file.sh | 13 ------- home-manager/config/lf/cmds/trash | 29 ++++++++++++++++ home-manager/config/lf/cmds/trash.sh | 27 --------------- home-manager/config/lf/cmds/unarchive | 26 ++++++++++++++ home-manager/config/lf/cmds/unarchive.sh | 25 -------------- 43 files changed, 449 insertions(+), 403 deletions(-) create mode 100755 home-manager/config/lf/cmds/archive delete mode 100644 home-manager/config/lf/cmds/archive.sh create mode 100755 home-manager/config/lf/cmds/broot_jump delete mode 100644 home-manager/config/lf/cmds/broot_jump.sh create mode 100755 home-manager/config/lf/cmds/chmod delete mode 100644 home-manager/config/lf/cmds/chmod.sh create mode 100755 home-manager/config/lf/cmds/clear_trash delete mode 100644 home-manager/config/lf/cmds/clear_trash.sh create mode 100755 home-manager/config/lf/cmds/dl_file delete mode 100644 home-manager/config/lf/cmds/dl_file.sh create mode 100755 home-manager/config/lf/cmds/dragon delete mode 100644 home-manager/config/lf/cmds/dragon.sh create mode 100755 home-manager/config/lf/cmds/dragon_individual delete mode 100644 home-manager/config/lf/cmds/dragon_individual.sh create mode 100755 home-manager/config/lf/cmds/dragon_stay delete mode 100644 home-manager/config/lf/cmds/dragon_stay.sh create mode 100755 home-manager/config/lf/cmds/fzf_jump delete mode 100644 home-manager/config/lf/cmds/fzf_jump.sh create mode 100755 home-manager/config/lf/cmds/help delete mode 100644 home-manager/config/lf/cmds/help.sh create mode 100755 home-manager/config/lf/cmds/mk_dir delete mode 100644 home-manager/config/lf/cmds/mk_dir.sh create mode 100755 home-manager/config/lf/cmds/mk_file delete mode 100644 home-manager/config/lf/cmds/mk_file.sh create mode 100755 home-manager/config/lf/cmds/mk_ln delete mode 100644 home-manager/config/lf/cmds/mk_ln.sh create mode 100755 home-manager/config/lf/cmds/mk_scr delete mode 100644 home-manager/config/lf/cmds/mk_scr.sh create mode 100755 home-manager/config/lf/cmds/open delete mode 100644 home-manager/config/lf/cmds/open.sh create mode 100755 home-manager/config/lf/cmds/open_config delete mode 100644 home-manager/config/lf/cmds/open_config.sh create mode 100755 home-manager/config/lf/cmds/restore_trash delete mode 100644 home-manager/config/lf/cmds/restore_trash.sh create mode 100755 home-manager/config/lf/cmds/set_wall_paper delete mode 100644 home-manager/config/lf/cmds/set_wall_paper.sh create mode 100755 home-manager/config/lf/cmds/stripspace delete mode 100644 home-manager/config/lf/cmds/stripspace.sh delete mode 100644 home-manager/config/lf/cmds/sudo_mk_file.sh create mode 100755 home-manager/config/lf/cmds/trash delete mode 100644 home-manager/config/lf/cmds/trash.sh create mode 100755 home-manager/config/lf/cmds/unarchive delete mode 100644 home-manager/config/lf/cmds/unarchive.sh (limited to 'home-manager/config/lf/cmds') diff --git a/home-manager/config/lf/cmds/archive b/home-manager/config/lf/cmds/archive new file mode 100755 index 00000000..b25cb3e1 --- /dev/null +++ b/home-manager/config/lf/cmds/archive @@ -0,0 +1,39 @@ +#! /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) + +# Option '-f' disables pathname expansion which can be useful when $f, $fs, and +# $fx variables contain names with '*' or '?' characters. However, this option +# is used selectively within individual commands as it can be limiting at +# times. +set -f + +archivers=$(mktmp) +echo "gzip xz 7z zip" > $archivers; + +readp "File Name: " name + + +case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in + "gzip") + tar -czf "$name".tar.gz "$fx" + ;; + "xz") + tar -cf "$name".tar "$fx" + xz -z -9 -e -T0 "$name".tar + ;; + "7z") + 7z a "$name".7z "$fx" + ;; + "zip") + zip -r "$name".zip "$fx" + ;; +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/archive.sh b/home-manager/config/lf/cmds/archive.sh deleted file mode 100644 index 86c3d12d..00000000 --- a/home-manager/config/lf/cmds/archive.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/home/dt/.local/lib/shell/lib -. %SHELL_LIBRARY_PATH - - -# Option '-f' disables pathname expansion which can be useful when $f, $fs, and -# $fx variables contain names with '*' or '?' characters. However, this option -# is used selectively within individual commands as it can be limiting at -# times. -set -f - -archivers=$(mktmp) -echo "tar+zip tar+xz 7z zip" > $archivers; - -readp "File Name: " name - - -case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in - "tar+zip") - tar -czf "$name".tar.gz "$fx" - ;; - "tar+xz") - tar -cf "$name".tar "$fx" - xz -z -9 -e -T0 "$name".tar - ;; - "7z") - 7z a "$name".7z "$fx" - ;; - "zip") - zip -r "$name".zip "$fx" - ;; -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/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 b/home-manager/config/lf/cmds/clear_trash new file mode 100755 index 00000000..1de81b7f --- /dev/null +++ b/home-manager/config/lf/cmds/clear_trash @@ -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) + +# could also use --force, for instand removal +trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --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/clear_trash.sh b/home-manager/config/lf/cmds/clear_trash.sh deleted file mode 100644 index d732756f..00000000 --- a/home-manager/config/lf/cmds/clear_trash.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -# 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 diff --git a/home-manager/config/lf/cmds/dl_file b/home-manager/config/lf/cmds/dl_file new file mode 100755 index 00000000..dfd11f69 --- /dev/null +++ b/home-manager/config/lf/cmds/dl_file @@ -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) + +# Provides the ability to download a file by dropping it into a window + +url=$(dragon -t -x) + +if [ -n "$url" ]; then + printf "File Name: " + name="" + while [ -z $name ] || [ -e $name ] + do + read -r name + if [ -e "$name" ]; then + printf "File already exists, overwrite (y|n): " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + printf "File Name: " + fi + fi + done + + # Download the file with curl + [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" +else + die "Url is not valid!" +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.sh deleted file mode 100644 index ac6d6ded..00000000 --- a/home-manager/config/lf/cmds/dl_file.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -# Provides the ability to download a file by dropping it into a window - -url=$(dragon -t -x) - -if [ -n "$url" ]; then - printf "File Name: " - name="" - while [ -z $name ] || [ -e $name ] - do - read -r name - if [ -e "$name" ]; then - printf "File already exists, overwrite (y|n): " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - printf "File Name: " - fi - fi - done - - # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || exit 1 -else - exit 1 -fi - - - -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 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 b/home-manager/config/lf/cmds/mk_ln new file mode 100755 index 00000000..6b9e2b30 --- /dev/null +++ b/home-manager/config/lf/cmds/mk_ln @@ -0,0 +1,41 @@ +#! /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')" + +mode="$1" +shift + +if [ "$#" -lt 1 ]; then + msg "no files to link" + exit 0 +fi + +case "$mode" in + copy) + while [ "$#" -gt 0 ]; do + file="$1" + ans="$(basename "$file")" + + while [ -e "$ans" ];do + printf "\"%s\" already exists, new name for link: " "$ans" + read -r ans + done + + ln -s "$file" "$(pwd)/$ans" + shift + done + ;; +esac +rm ~/.local/share/lf/files +# lf -remote "send clear" + +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_ln.sh b/home-manager/config/lf/cmds/mk_ln.sh deleted file mode 100644 index f2129763..00000000 --- a/home-manager/config/lf/cmds/mk_ln.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -while IFS= read -r i;do - set -- "$@" "$i" -done < "$(tmp 'cat ~/.local/share/lf/files')" - -mode="$1" -shift - -if [ "$#" -lt 1 ]; then - msg "no files to link" - 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 - printf "\"%s\" already exists, new name for link: " "$ans" - read -r ans - done - - ln -s "$file" "$(pwd)/$ans" - - - shift - done - ;; -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 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 b/home-manager/config/lf/cmds/trash new file mode 100755 index 00000000..ca68cfc1 --- /dev/null +++ b/home-manager/config/lf/cmds/trash @@ -0,0 +1,29 @@ +#! /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 +# # extract the substring from start of string up to delimiter. +# # this is the first "element" of the string. +# file=${files%%;*} +# +# trash-put "$(basename "$file")" +# # if there's only one element left, set `files` to an empty string. +# # this causes us to exit this `while` loop. +# # else, we delete the first "element" of the string from files, and move onto the next. +# if [ "$files" = "$file" ]; then +# files='' +# else +# files="${files#*;}" +# fi +#done +thrash put "$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/trash.sh b/home-manager/config/lf/cmds/trash.sh deleted file mode 100644 index 57351b78..00000000 --- a/home-manager/config/lf/cmds/trash.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - -#files=$(printf "$fx" | tr '\n' ';') -# -#while [ "$files" ]; do -# # extract the substring from start of string up to delimiter. -# # this is the first "element" of the string. -# file=${files%%;*} -# -# trash-put "$(basename "$file")" -# # if there's only one element left, set `files` to an empty string. -# # this causes us to exit this `while` loop. -# # else, we delete the first "element" of the string from files, and move onto the next. -# if [ "$files" = "$file" ]; then -# files='' -# else -# files="${files#*;}" -# fi -#done -thrash put "$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/unarchive b/home-manager/config/lf/cmds/unarchive new file mode 100755 index 00000000..a28879da --- /dev/null +++ b/home-manager/config/lf/cmds/unarchive @@ -0,0 +1,26 @@ +#! /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/) +set -f +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" ;; +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/unarchive.sh b/home-manager/config/lf/cmds/unarchive.sh deleted file mode 100644 index 498ae424..00000000 --- a/home-manager/config/lf/cmds/unarchive.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env dash -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. %SHELL_LIBRARY_PATH - - -# extract the current file with the right command -# (xkcd link: https://xkcd.com/1168/) -set -f -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" ;; -esac - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi -- cgit 1.4.1