diff options
Diffstat (limited to 'modules/home/conf/lf/commands')
26 files changed, 0 insertions, 1045 deletions
diff --git a/modules/home/conf/lf/commands/default.nix b/modules/home/conf/lf/commands/default.nix deleted file mode 100644 index 933769ac..00000000 --- a/modules/home/conf/lf/commands/default.nix +++ /dev/null @@ -1,227 +0,0 @@ -{ - pkgs, - sysLib, - shell_library, - system, - ... -}: let - functionCall = { - name, - dependencies, - replacementStrings, - ... - }: - sysLib.writeShellScript { - inherit name; - src = ./scripts/${name}.sh; - keepPath = true; - dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;}); - inherit replacementStrings; - } - + "/bin/${name}"; - - shell = { - name, - dependencies, - replacementStrings ? null, - ... - }: '' - ''${{ - ${functionCall {inherit name dependencies replacementStrings;}} - }} - ''; # closes the lf tui - pipe = { - name, - dependencies, - replacementStrings ? null, - ... - }: '' - %{{ - ${functionCall {inherit name dependencies replacementStrings;}} - }} - ''; # runs the command in the ui/term bar - async = { - name, - dependencies, - replacementStrings ? null, - ... - }: '' - &{{ - ${functionCall {inherit name dependencies replacementStrings;}} - }} - ''; # runs the command in the background - wait = { - name, - dependencies, - replacementStrings ? null, - ... - }: '' - !{{ - ${functionCall {inherit name dependencies replacementStrings;}} - }} - ''; # adds a prompt after the command has run -in { - archive = shell { - name = "archive"; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - gnutar - xz - p7zip - zip - ; - }; - }; - broot_jump = shell { - name = "broot_jump"; - dependencies = builtins.attrValues { - inherit (pkgs) broot; - }; - }; - chmod = pipe { - name = "chmod"; - dependencies = []; - }; - clear_trash = shell { - name = "clear_trash"; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - trashy - ; - }; - }; - dl_file = pipe { - name = "dl_file"; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - curl - ; - }; - }; - dragon = pipe { - name = "dragon"; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - dragon_individual = pipe { - name = "dragon_individual"; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - dragon_stay = pipe { - name = "dragon_stay"; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - execute = shell { - name = "execute"; - dependencies = []; - }; - follow_link = pipe { - name = "follow_link"; - dependencies = with pkgs; [lf]; - }; - fzf_jump = shell { - name = "fzf_jump"; - dependencies = builtins.attrValues { - inherit (pkgs) fzf lf gnused; - }; - }; - mk_dir = pipe { - name = "mk_dir"; - dependencies = []; - }; - mk_file = shell { - name = "mk_file"; - dependencies = []; - }; - mk_file_and_edit = shell { - name = "mk_file_and_edit"; - dependencies = []; - }; - mk_ln = pipe { - name = "mk_ln"; - dependencies = []; - }; - mk_scr_default = shell { - name = "mk_scr_default"; - dependencies = builtins.attrValues {}; - replacementStrings = { - SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; - }; - }; - mk_scr_temp = shell { - name = "mk_scr_temp"; - dependencies = builtins.attrValues {}; - replacementStrings = { - SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; - TO_BE_SHELL_LIBRARY_PATH = "%SHELL_LIBRARY_PATH"; # replacement is not recursive - }; - }; - view_file = async { - name = "view_file"; - dependencies = builtins.attrValues {inherit (pkgs) file;}; - }; - go_project_base_directory = async { - name = "go_project_root"; - dependencies = []; - }; - restore_trash = shell { - name = "restore_trash"; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - trashy - ; - }; - }; - set_wall_paper = pipe { - name = "set_wall_paper"; - dependencies = []; - }; - stripspace = pipe { - name = "stripspace"; - dependencies = []; - }; - trash = pipe { - name = "trash"; - dependencies = builtins.attrValues { - inherit - (pkgs) - trashy - trash-cli - findutils - ; - }; - }; - unarchive = pipe { - name = "unarchive"; - dependencies = builtins.attrValues { - inherit - (pkgs) - gnutar - unzip - p7zip - ; - }; - }; -} diff --git a/modules/home/conf/lf/commands/scripts/archive.sh b/modules/home/conf/lf/commands/scripts/archive.sh deleted file mode 100755 index 25f40534..00000000 --- a/modules/home/conf/lf/commands/scripts/archive.sh +++ /dev/null @@ -1,77 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - -# shellcheck disable=SC2269 -f="$f" -# shellcheck disable=SC2269 -fx="$fx" -# shellcheck disable=SC2269 -fs="$fs" - -archivers="$(tmp echo gzip xz 7z zip)" -archiver="$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" - -case "$archiver" in -"gzip") - ext=tar.gz - ;; -"xz") - ext=tar.xz - ;; -"7z") - ext=7z - ;; -"zip") - ext=zip - ;; -esac - -prompt "Archive name: " -name="" -while [ -z "$name" ] || [ -e "$name" ]; do - read -r name_base - name="$name_base.$ext" - 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 -done - -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")" - -case "$archiver" in -"gzip") - tar --create --gzip -file="$name" "$@" - ;; -"xz") - tar --create --file="$name" "$@" - xz --compress -9 --extreme --threads=0 "$name" - ;; -"7z") - 7z a "$name" "$@" - ;; -"zip") - zip --symlinks -9 -r "$name" "$@" - ;; -esac -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/broot_jump.sh b/modules/home/conf/lf/commands/scripts/broot_jump.sh deleted file mode 100755 index 8f40ba01..00000000 --- a/modules/home/conf/lf/commands/scripts/broot_jump.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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")" - -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/modules/home/conf/lf/commands/scripts/chmod.sh b/modules/home/conf/lf/commands/scripts/chmod.sh deleted file mode 100755 index 9859127b..00000000 --- a/modules/home/conf/lf/commands/scripts/chmod.sh +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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")" - -lf -remote 'send reload' -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/clear_trash.sh b/modules/home/conf/lf/commands/scripts/clear_trash.sh deleted file mode 100755 index 9052bb5f..00000000 --- a/modules/home/conf/lf/commands/scripts/clear_trash.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# could also use --force, for instand removal -trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/cow_cp.sh b/modules/home/conf/lf/commands/scripts/cow_cp.sh deleted file mode 100755 index 98675b9e..00000000 --- a/modules/home/conf/lf/commands/scripts/cow_cp.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 -# backtrack <2023-08-29> - -# # This was very helpful for debugging: -# log_file="$HOME/lf-reflink-log-$(date +'%Y-%m-%d_%H-%M-%S')" -# [ -f "$log_file" ] || touch "$log_file" -# exec 1>> $log_file 2>&1 -# set -x - -# In theory, this may fail, -# but I tested it on selection with 10k files - everything worked (bash) -# FIXME: This will very likely fail on dash, when the file number > 255 <2023-08-29> -set -- "$(cat ~/.local/share/lf/files)" - -mode="$1" -shift - -if [ "$mode" = 'copy' ]; then - # Reflink if all items of selection and the destination are on the - # same mount point and it is CoW fs. - # (to make sure reflink never fails in first place, so we don't have to - # clean up) - - 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)) && - [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then - - echo 'selected copy and cp reflink paste' - - start=$(date '+%s') - - # Handle same names in dst - # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... - for i in "$@"; do - name="${i##*/}" - original="$name" - - count=0 - while [ -w "$PWD/$name" ]; do - count=$((count + 1)) - name="$original.~$count~" - done - - set +e - cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" - set -e - - if [ -n "$cp_out" ]; then - lf -remote "send $id echoerr $cp_out" - exit 0 - fi - done - - finish=$(($(date '+%s') - start)) - t='' - if ((finish > 2)); then - t="${finish}s" - fi - - # Or just skip a file when names are the same. - # (A LOT faster if you e.g. pasting selection of 10k files) - # cp -rn --reflink=always -- "$@" . - - lf -remote "send clear" - - green=$'\u001b[32m' - reset=$'\u001b[0m' - lf -remote "send $id echo ${green}reflinked!${reset} $t" - else - 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 - -# # for debug -# set +x - -lf -remote "send load" - -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/dl_file.sh b/modules/home/conf/lf/commands/scripts/dl_file.sh deleted file mode 100755 index c7e3d8b2..00000000 --- a/modules/home/conf/lf/commands/scripts/dl_file.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - - if [ "$ans" = "y" ]; then - break - else - prompt "File Name: " - fi - fi - done - - # Download the file with curl - if [ -n "$name" ]; then - curl -o "$name" "$url" || die "curl failed" - fi -else - die "URL is null!" -fi -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/dragon.sh b/modules/home/conf/lf/commands/scripts/dragon.sh deleted file mode 100755 index cf3c3176..00000000 --- a/modules/home/conf/lf/commands/scripts/dragon.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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")" - -dragon -a -x "$@" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/dragon_individual.sh b/modules/home/conf/lf/commands/scripts/dragon_individual.sh deleted file mode 100755 index 2465cdfa..00000000 --- a/modules/home/conf/lf/commands/scripts/dragon_individual.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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")" - -dragon "$@" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/dragon_stay.sh b/modules/home/conf/lf/commands/scripts/dragon_stay.sh deleted file mode 100755 index 066b4c75..00000000 --- a/modules/home/conf/lf/commands/scripts/dragon_stay.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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")" - -dragon -a "$@" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/execute.sh b/modules/home/conf/lf/commands/scripts/execute.sh deleted file mode 100755 index aa97fd7f..00000000 --- a/modules/home/conf/lf/commands/scripts/execute.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# shellcheck disable=SC2269 -f="$f" -# shellcheck disable=SC2269 -fx="$fx" -# shellcheck disable=SC2269 -fs="$fs" -# shellcheck disable=SC2269 -id="$id" - -dir="$(realpath "$f")" - -"$dir" - -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/follow_link.sh b/modules/home/conf/lf/commands/scripts/follow_link.sh deleted file mode 100755 index 80413990..00000000 --- a/modules/home/conf/lf/commands/scripts/follow_link.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# shellcheck disable=SC2269 -f="$f" -# shellcheck disable=SC2269 -fx="$fx" -# shellcheck disable=SC2269 -fs="$fs" -# shellcheck disable=SC2269 -id="$id" - -dir="$(realpath "$f")" - -lf -remote "send $id cd \"$dir\"" - -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/fzf_jump.sh b/modules/home/conf/lf/commands/scripts/fzf_jump.sh deleted file mode 100755 index ad1633fb..00000000 --- a/modules/home/conf/lf/commands/scripts/fzf_jump.sh +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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/modules/home/conf/lf/commands/scripts/go_project_root.sh b/modules/home/conf/lf/commands/scripts/go_project_root.sh deleted file mode 100755 index 5f7746d3..00000000 --- a/modules/home/conf/lf/commands/scripts/go_project_root.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# 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" -fi - -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_dir.sh b/modules/home/conf/lf/commands/scripts/mk_dir.sh deleted file mode 100755 index 150f7eed..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_dir.sh +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - - if [ "$ans" = "y" ]; then - break - else - prompt "Directory Name: " - fi - fi -done - -mkdir "$name" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_file.sh b/modules/home/conf/lf/commands/scripts/mk_file.sh deleted file mode 100755 index 41d5cf1a..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_file.sh +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " - fi - fi -done - -touch "$name" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_file_and_edit.sh b/modules/home/conf/lf/commands/scripts/mk_file_and_edit.sh deleted file mode 100755 index 19fc51db..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_file_and_edit.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " - fi - fi -done - -touch "$name" -"$EDITOR" "$name" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_ln.sh b/modules/home/conf/lf/commands/scripts/mk_ln.sh deleted file mode 100755 index 7fab8e22..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_ln.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# 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 - -mode="$1" -shift - -if [ "$#" -eq 0 ]; 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 - prompt "$ans already exists, new name for link: " - read -r ans - done - - ln --symbolic --relative "$file" "$(pwd)/$ans" - shift - done - ;; -esac -rm ~/.local/share/lf/files -# lf -remote "send clear" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_scr_default.sh b/modules/home/conf/lf/commands/scripts/mk_scr_default.sh deleted file mode 100755 index 47d05080..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_scr_default.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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_base - name="$name_base.sh" - 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 -done - -script="$(pwd)"/"$name" - -cat "%SHELL_LIBRARY_TEMPLATE" >"$script" -chmod +x "$script" -"$VISUAL" "$script" - -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/mk_scr_temp.sh b/modules/home/conf/lf/commands/scripts/mk_scr_temp.sh deleted file mode 100755 index 512b5d0b..00000000 --- a/modules/home/conf/lf/commands/scripts/mk_scr_temp.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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: " - fi - fi -done - -script="$(pwd)"/"$name" - -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/modules/home/conf/lf/commands/scripts/restore_trash.sh b/modules/home/conf/lf/commands/scripts/restore_trash.sh deleted file mode 100755 index b4ef492f..00000000 --- a/modules/home/conf/lf/commands/scripts/restore_trash.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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/modules/home/conf/lf/commands/scripts/set_wall_paper.sh b/modules/home/conf/lf/commands/scripts/set_wall_paper.sh deleted file mode 100755 index 2e607d33..00000000 --- a/modules/home/conf/lf/commands/scripts/set_wall_paper.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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" -#feh --bg-max --no-fehbg "$f" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/stripspace.sh b/modules/home/conf/lf/commands/scripts/stripspace.sh deleted file mode 100755 index 33b1cbcf..00000000 --- a/modules/home/conf/lf/commands/scripts/stripspace.sh +++ /dev/null @@ -1,40 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# shellcheck disable=SC2269 -f="$f" -# shellcheck disable=SC2269 -fx="$fx" -# shellcheck disable=SC2269 -fs="$fs" -# shellcheck disable=SC2269 -id="$id" - -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" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/trash.sh b/modules/home/conf/lf/commands/scripts/trash.sh deleted file mode 100755 index f4878c49..00000000 --- a/modules/home/conf/lf/commands/scripts/trash.sh +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# 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")" - -# 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" - -# FIXME: Find a way, that does not depend on parsing an error message <2023-08-29> -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" - # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this - trash-put "$@" -fi -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/unarchive.sh b/modules/home/conf/lf/commands/scripts/unarchive.sh deleted file mode 100755 index d4835f6b..00000000 --- a/modules/home/conf/lf/commands/scripts/unarchive.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %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 - -unarchive() { - case "$1" in - *.tar.bz | *.tar.bz2 | *.tbz | *.tbz2) tar xjvf "$1" ;; - *.tar.gz | *.tgz) tar xzvf "$1" ;; - *.tar.xz | *.txz) tar xJvf "$1" ;; - *.zip) unzip "$1" ;; - *.rar) - die "rar is a unfree format!" - ;; - *.7z) 7z x "$1" ;; - *) die "Unsupported format" ;; - esac -} - -while read -r file; do - unarchive "$file" -done <"$fx" -# vim: ft=sh diff --git a/modules/home/conf/lf/commands/scripts/view_file.sh b/modules/home/conf/lf/commands/scripts/view_file.sh deleted file mode 100755 index 6258d755..00000000 --- a/modules/home/conf/lf/commands/scripts/view_file.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# shellcheck disable=SC2269 -f="$f" -# shellcheck disable=SC2269 -fx="$fx" -# shellcheck disable=SC2269 -fs="$fs" - -mime_type="$(file --mime-type --brief --dereference "$f")" -case "$mime_type" in -application/pdf) - "$READER" "$f" - ;; -image/*) - "$IVIEWER" "$f" - ;; -*) - die "Mime-Type: '$mime_type' not supported" - ;; -esac - -# vim: ft=sh |