diff options
author | ene <ene@sils.li> | 2023-02-19 21:29:01 +0100 |
---|---|---|
committer | ene <ene@sils.li> | 2023-02-19 21:30:25 +0100 |
commit | 9108d474af7776767d93eb933ff4b0b09772917a (patch) | |
tree | 0f8706dd91d9f6b9242717e482e41f8b6b24ed8e | |
parent | Fix(bootstrap): Fix a copy and paste oversight (diff) | |
download | nixos-config-9108d474af7776767d93eb933ff4b0b09772917a.tar.gz nixos-config-9108d474af7776767d93eb933ff4b0b09772917a.zip |
Feat(lf): Add dependencies for the shell scripts
Diffstat (limited to '')
23 files changed, 308 insertions, 113 deletions
diff --git a/home-manager/config/lf/cmds/archive.sh b/home-manager/config/lf/cmds/archive.sh index 48544365..d319116d 100644 --- a/home-manager/config/lf/cmds/archive.sh +++ b/home-manager/config/lf/cmds/archive.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/home/dt/.local/lib/shell/lib -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH # Option '-f' disables pathname expansion which can be useful when $f, $fs, and diff --git a/home-manager/config/lf/cmds/broot_jump.sh b/home-manager/config/lf/cmds/broot_jump.sh index 188c9508..00d04b2b 100644 --- a/home-manager/config/lf/cmds/broot_jump.sh +++ b/home-manager/config/lf/cmds/broot_jump.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH f=$(mktemp) res="$(broot --outcmd $f && cat $f | sed 's/cd //')" diff --git a/home-manager/config/lf/cmds/chmod.sh b/home-manager/config/lf/cmds/chmod.sh index f6a87336..c7bb6ff8 100644 --- a/home-manager/config/lf/cmds/chmod.sh +++ b/home-manager/config/lf/cmds/chmod.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH readp "Mode Bits: " ans diff --git a/home-manager/config/lf/cmds/clear_trash.sh b/home-manager/config/lf/cmds/clear_trash.sh index c02321f2..d732756f 100644 --- a/home-manager/config/lf/cmds/clear_trash.sh +++ b/home-manager/config/lf/cmds/clear_trash.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -trash-empty +# 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.sh b/home-manager/config/lf/cmds/dl_file.sh index 9cb9023c..ac6d6ded 100644 --- a/home-manager/config/lf/cmds/dl_file.sh +++ b/home-manager/config/lf/cmds/dl_file.sh @@ -1,11 +1,11 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH # Provides the ability to download a file by dropping it into a window -url=$(dragon-drop -t -x) +url=$(dragon -t -x) if [ -n "$url" ]; then printf "File Name: " diff --git a/home-manager/config/lf/cmds/dragon.sh b/home-manager/config/lf/cmds/dragon.sh index 36e94706..be91a951 100644 --- a/home-manager/config/lf/cmds/dragon.sh +++ b/home-manager/config/lf/cmds/dragon.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -dragon-drop -a -x "$fx" +dragon -a -x "$fx" diff --git a/home-manager/config/lf/cmds/dragon_individual.sh b/home-manager/config/lf/cmds/dragon_individual.sh index abcadb13..8215a20b 100644 --- a/home-manager/config/lf/cmds/dragon_individual.sh +++ b/home-manager/config/lf/cmds/dragon_individual.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -dragon-drop "$fx" +dragon "$fx" diff --git a/home-manager/config/lf/cmds/dragon_stay.sh b/home-manager/config/lf/cmds/dragon_stay.sh index 60195d09..bf5bb7dd 100644 --- a/home-manager/config/lf/cmds/dragon_stay.sh +++ b/home-manager/config/lf/cmds/dragon_stay.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -dragon-drop -a "$fx" +dragon -a "$fx" diff --git a/home-manager/config/lf/cmds/fzf_jump.sh b/home-manager/config/lf/cmds/fzf_jump.sh index 688efdb9..7e3bb9d0 100644 --- a/home-manager/config/lf/cmds/fzf_jump.sh +++ b/home-manager/config/lf/cmds/fzf_jump.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')" if [ -f "$res" ]; then diff --git a/home-manager/config/lf/cmds/help.sh b/home-manager/config/lf/cmds/help.sh index 8fedd0ea..5eb64dd5 100644 --- a/home-manager/config/lf/cmds/help.sh +++ b/home-manager/config/lf/cmds/help.sh @@ -1,8 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib - +. %SHELL_LIBRARY_PATH cat ~/.config/lf/lfrc diff --git a/home-manager/config/lf/cmds/mk_dir.sh b/home-manager/config/lf/cmds/mk_dir.sh index bfa0627d..aaffce5f 100644 --- a/home-manager/config/lf/cmds/mk_dir.sh +++ b/home-manager/config/lf/cmds/mk_dir.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH readp "Directory Name: " ans diff --git a/home-manager/config/lf/cmds/mk_file.sh b/home-manager/config/lf/cmds/mk_file.sh index 044016a6..14fc8881 100644 --- a/home-manager/config/lf/cmds/mk_file.sh +++ b/home-manager/config/lf/cmds/mk_file.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH readp "File Name: " name diff --git a/home-manager/config/lf/cmds/mk_ln.sh b/home-manager/config/lf/cmds/mk_ln.sh index 71a70a36..f2129763 100644 --- a/home-manager/config/lf/cmds/mk_ln.sh +++ b/home-manager/config/lf/cmds/mk_ln.sh @@ -1,11 +1,11 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH while IFS= read -r i;do set -- "$@" "$i" -done < "$(tmp "cat ~/.local/share/lf/files")" +done < "$(tmp 'cat ~/.local/share/lf/files')" mode="$1" shift @@ -19,7 +19,7 @@ fi case "$mode" in copy) while [ "$#" -gt 0 ]; do - file=$1 + file="$1" ans="$(basename "$file")" while ls -a "$(pwd)" | grep --word-regexp "$ans" > /dev/null;do diff --git a/home-manager/config/lf/cmds/mk_scr.sh b/home-manager/config/lf/cmds/mk_scr.sh index 4b80e564..0441c63f 100644 --- a/home-manager/config/lf/cmds/mk_scr.sh +++ b/home-manager/config/lf/cmds/mk_scr.sh @@ -1,27 +1,27 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH star=$(mktmp) cat << EOF > $star -#!/bin/sh +#!/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) +LIB_TEMP_DIR_FOR_SCRIPT=\$(mktemp -d) -if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +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 exitst, exiting.." +[ -e $scr ] && die "$script_name exist, exiting.." cat "$star" > $scr chmod +x $scr diff --git a/home-manager/config/lf/cmds/open.sh b/home-manager/config/lf/cmds/open.sh index 8376be21..bcfe62f4 100644 --- a/home-manager/config/lf/cmds/open.sh +++ b/home-manager/config/lf/cmds/open.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH case $(file --mime-type "$f" -bL) in diff --git a/home-manager/config/lf/cmds/open_config.sh b/home-manager/config/lf/cmds/open_config.sh index 93c174d7..4b103fe4 100644 --- a/home-manager/config/lf/cmds/open_config.sh +++ b/home-manager/config/lf/cmds/open_config.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH $EDITOR "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" diff --git a/home-manager/config/lf/cmds/restore_trash.sh b/home-manager/config/lf/cmds/restore_trash.sh index 432e9e9b..fd4641eb 100644 --- a/home-manager/config/lf/cmds/restore_trash.sh +++ b/home-manager/config/lf/cmds/restore_trash.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -trash-restore +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.sh b/home-manager/config/lf/cmds/set_wall_paper.sh index 4599de2a..6ad9fc1f 100644 --- a/home-manager/config/lf/cmds/set_wall_paper.sh +++ b/home-manager/config/lf/cmds/set_wall_paper.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH die "No yet implemented" diff --git a/home-manager/config/lf/cmds/stripspace.sh b/home-manager/config/lf/cmds/stripspace.sh index c7f68767..0032be26 100644 --- a/home-manager/config/lf/cmds/stripspace.sh +++ b/home-manager/config/lf/cmds/stripspace.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH -stripspace "$f" +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 index 1f06a92f..c1443da0 100644 --- a/home-manager/config/lf/cmds/sudo_mk_file.sh +++ b/home-manager/config/lf/cmds/sudo_mk_file.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH readp "File Name: " ans diff --git a/home-manager/config/lf/cmds/trash.sh b/home-manager/config/lf/cmds/trash.sh index 4598b4fd..57351b78 100644 --- a/home-manager/config/lf/cmds/trash.sh +++ b/home-manager/config/lf/cmds/trash.sh @@ -1,26 +1,26 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib - -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 +. %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"; diff --git a/home-manager/config/lf/cmds/unarchive.sh b/home-manager/config/lf/cmds/unarchive.sh index 47a713fa..498ae424 100644 --- a/home-manager/config/lf/cmds/unarchive.sh +++ b/home-manager/config/lf/cmds/unarchive.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null -. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH # extract the current file with the right command @@ -12,9 +12,12 @@ case "$f" in *.tar.gz|*.tgz) tar xzvf $f;; *.tar.xz|*.txz) tar xJvf $f;; *.zip) unzip $f;; - *.rar) unrar x $f;; + *.rar) + die "rar is a unfree format!" + #unrar x $f + ;; *.7z) 7z x $f;; - *) warning "Unsupported format" ;; + *) die "Unsupported format" ;; esac diff --git a/home-manager/config/lf/default.nix b/home-manager/config/lf/default.nix index 5330f39f..1eb0cd6d 100644 --- a/home-manager/config/lf/default.nix +++ b/home-manager/config/lf/default.nix @@ -1,16 +1,73 @@ { config, pkgs, + sysLib, ... }: let - shell = file: - "\${{" + builtins.readFile "${file}" + "}}"; # closes the lf tui - pipe = file: - "%{{" + builtins.readFile "${file}" + "}}"; # runs the command in the ui,term bar - async = file: - "&{{" + builtins.readFile "${file}" + "}}"; # runs the command in the background - wait = file: - "!{{" + builtins.readFile "${file}" + "}}"; # adds a prompt after the command has run + shell = { + file, + dependencies, + ... + }: '' + ''${{ + ${ + builtins.readFile (sysLib.makeShellScriptWithLibrary { + name = "NAME_FOR_A_SHELL_SCRIPT"; + script = file; + inherit dependencies; + } + + /bin/NAME_FOR_A_SHELL_SCRIPT) + } + }} + ''; # closes the lf tui + pipe = { + file, + dependencies, + ... + }: '' + %{{ + ${ + builtins.readFile (sysLib.makeShellScriptWithLibrary { + name = "NAME_FOR_A_SHELL_SCRIPT"; + script = file; + inherit dependencies; + } + + /bin/NAME_FOR_A_SHELL_SCRIPT) + } + }} + ''; # runs the command in the ui/term bar + async = { + file, + dependencies, + ... + }: '' + &{{ + ${ + builtins.readFile (sysLib.makeShellScriptWithLibrary { + name = "NAME_FOR_A_SHELL_SCRIPT"; + script = file; + inherit dependencies; + } + + /bin/NAME_FOR_A_SHELL_SCRIPT) + } + }} + ''; # runs the command in the background + wait = { + file, + dependencies, + ... + }: '' + !{{ + ${ + builtins.readFile (sysLib.makeShellScriptWithLibrary { + name = "NAME_FOR_A_SHELL_SCRIPT"; + script = file; + inherit dependencies; + } + + /bin/NAME_FOR_A_SHELL_SCRIPT) + } + }} + ''; # adds a prompt after the command has run in { xdg.configFile."lf/icons".source = ./icons; xdg.configFile."lf/colors".source = ./colors; @@ -19,32 +76,165 @@ in { enable = true; commands = { - help = shell ./cmds/help.sh; - open = shell ./cmds/open.sh; - mk_dir = pipe ./cmds/mk_dir.sh; - mk_scr = shell ./cmds/mk_scr.sh; - mk_file = shell ./cmds/mk_file.sh; - chmod = pipe ./cmds/chmod.sh; - mk_ln = shell ./cmds/mk_ln.sh; # TODO could be pipe, right? - sudo_mk_file = shell ./cmds/sudo_mk_file.sh; - set_wall_paper = pipe ./cmds/set_wall_paper.sh; - fzf_jump = shell ./cmds/fzf_jump.sh; - broot_jump = shell ./cmds/broot_jump.sh; - open_config = shell ./cmds/open_config.sh; - - dragon = pipe ./cmds/dragon.sh; - dragon_stay = pipe ./cmds/dragon_stay.sh; - dragon_individual = pipe ./cmds/dragon_individual.sh; - dl_file = pipe ./cmds/dl_file.sh; - - unarchive = pipe ./cmds/unarchive.sh; - archive = pipe ./cmds/archive.sh; - - trash = pipe ./cmds/trash.sh; - clear_trash = pipe ./cmds/clear_trash.sh; - restore_trash = shell ./cmds/restore_trash.sh; - - stripspace = pipe ./cmds/stripspace.sh; + help = shell { + file = ./cmds/help.sh; + dependencies = []; + }; + open = shell { + file = ./cmds/open.sh; + dependencies = []; + }; + 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; + dependencies = builtins.attrValues { + inherit (pkgs) fzf; + }; + }; + broot_jump = shell { + file = ./cmds/broot_jump.sh; + dependencies = builtins.attrValues { + inherit (pkgs) broot; + }; + }; + open_config = shell { + file = ./cmds/open_config.sh; + dependencies = builtins.attrValues { + #inherit + #(pkgs) + ## TODO rewrite this: bookmenu, https://github.com/jarun/buku + # + #buku + #; + }; + }; + + dragon = pipe { + file = ./cmds/dragon.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + dragon_stay = pipe { + file = ./cmds/dragon_stay.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + dragon_individual = pipe { + file = ./cmds/dragon_individual.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + dl_file = pipe { + file = ./cmds/dl_file.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + curl + ; + }; + }; + + unarchive = pipe { + file = ./cmds/unarchive.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + gnutar + unzip + # TODO this is unfree! unrar + + p7zip + ; + }; + }; + archive = pipe { + file = ./cmds/archive.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + gnutar + xz + p7zip + zip + ; + }; + }; + + trash = pipe { + file = ./cmds/trash.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + trashy + ; + }; + }; + clear_trash = pipe { + file = ./cmds/clear_trash.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + trashy + ; + }; + }; + restore_trash = shell { + file = ./cmds/restore_trash.sh; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + trashy + ; + }; + }; + + stripspace = pipe { + file = ./cmds/stripspace.sh; + dependencies = []; + }; }; keybindings = { # Remove some defaults |