about summary refs log tree commit diff stats
path: root/hm/soispha/conf/lf/commands
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
committerSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
commit3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch)
tree7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/conf/lf/commands
parentStyle(treewide): Format all lua-files makes lua ➛ nix easier (diff)
downloadnixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/conf/lf/commands')
-rw-r--r--hm/soispha/conf/lf/commands/default.nix241
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/archive54
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/broot_jump16
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/chmod13
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/clear_trash8
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/dl_file33
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/dragon11
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/dragon_individual11
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/dragon_stay11
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/fzf_jump16
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/go_project_root13
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_dir24
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_file24
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_file_and_edit25
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_ln36
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_scr_default31
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_scr_temp31
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/open11
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/open_config7
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/restore_trash7
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/set_wall_paper10
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/stripspace31
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/trash26
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/unarchive22
24 files changed, 712 insertions, 0 deletions
diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix
new file mode 100644
index 00000000..a52cb2f0
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/default.nix
@@ -0,0 +1,241 @@
+{
+  pkgs,
+  sysLib,
+  shell_library,
+  system,
+  lf_rename,
+  ...
+}: let
+  functionCall = {
+    file,
+    dependencies,
+    replacementStrings,
+    ...
+  }:
+    sysLib.writeShellScriptWithLibraryAndKeepPath {
+      name = "${builtins.baseNameOf file}";
+      src = file;
+      dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;});
+      inherit replacementStrings;
+    }
+    + "/bin/${builtins.baseNameOf file}";
+
+  shell = {
+    file,
+    dependencies,
+    replacementStrings ? null,
+    ...
+  }: ''
+    ''${{
+      ${functionCall {inherit file dependencies replacementStrings;}}
+    }}
+  ''; # closes the lf tui
+  pipe = {
+    file,
+    dependencies,
+    replacementStrings ? null,
+    ...
+  }: ''
+    %{{
+      ${functionCall {inherit file dependencies replacementStrings;}}
+    }}
+  ''; # runs the command in the ui/term bar
+  async = {
+    file,
+    dependencies,
+    replacementStrings ? null,
+    ...
+  }: ''
+    &{{
+      ${functionCall {inherit file dependencies replacementStrings;}}
+    }}
+  ''; # runs the command in the background
+  wait = {
+    file,
+    dependencies,
+    replacementStrings ? null,
+    ...
+  }: ''
+    !{{
+      ${functionCall {inherit file dependencies replacementStrings;}}
+    }}
+  ''; # adds a prompt after the command has run
+in {
+  archive = shell {
+    file = ./scripts/archive;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        gnutar
+        xz
+        p7zip
+        zip
+        ;
+    };
+  };
+  broot_jump = shell {
+    file = ./scripts/broot_jump;
+    dependencies = builtins.attrValues {
+      inherit (pkgs) broot;
+    };
+  };
+  chmod = pipe {
+    file = ./scripts/chmod;
+    dependencies = [];
+  };
+  clear_trash = shell {
+    file = ./scripts/clear_trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        trashy
+        ;
+    };
+  };
+  dl_file = pipe {
+    file = ./scripts/dl_file;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        curl
+        ;
+    };
+  };
+  dragon = pipe {
+    file = ./scripts/dragon;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  dragon_individual = pipe {
+    file = ./scripts/dragon_individual;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  dragon_stay = pipe {
+    file = ./scripts/dragon_stay;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  fzf_jump = shell {
+    file = ./scripts/fzf_jump;
+    dependencies = builtins.attrValues {
+      inherit (pkgs) fzf lf gnused;
+    };
+  };
+  mk_dir = pipe {
+    file = ./scripts/mk_dir;
+    dependencies = [];
+  };
+  mk_file = shell {
+    file = ./scripts/mk_file;
+    dependencies = [];
+  };
+  mk_file_and_edit = shell {
+    file = ./scripts/mk_file_and_edit;
+    dependencies = [];
+  };
+  mk_ln = pipe {
+    file = ./scripts/mk_ln;
+    dependencies = [];
+  };
+  mk_scr_default = shell {
+    file = ./scripts/mk_scr_default;
+    dependencies = builtins.attrValues {};
+    replacementStrings = {
+      SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}";
+    };
+  };
+  mk_scr_temp = shell {
+    file = ./scripts/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
+    };
+  };
+  open = shell {
+    file = ./scripts/open;
+    dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils;};
+  };
+  go_project_base_directory = async {
+    file = ./scripts/go_project_root;
+    dependencies = [];
+  };
+  open_config = shell {
+    file = ./scripts/open_config;
+    dependencies = builtins.attrValues {
+      #inherit
+      #(pkgs)
+      ## TODO: rewrite this:  bookmenu, https://github.com/jarun/buku
+      #
+      #buku
+      #;
+    };
+  };
+  restore_trash = shell {
+    file = ./scripts/restore_trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        trashy
+        ;
+    };
+  };
+  set_wall_paper = pipe {
+    file = ./scripts/set_wall_paper;
+    dependencies = [];
+  };
+  /*
+  FIXME:
+  The c code fails, when stdout/-in is piped.
+  rename = ''
+    %{{
+      ${lf_rename.packages."${system}".default}/bin/rename
+    }}
+  '';
+  */
+  stripspace = pipe {
+    file = ./scripts/stripspace;
+    dependencies = [];
+  };
+  trash = pipe {
+    file = ./scripts/trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        trashy
+        trash-cli
+        findutils
+        ;
+    };
+  };
+  unarchive = pipe {
+    file = ./scripts/unarchive;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        gnutar
+        unzip
+        # TODO: this is unfree! unrar
+        
+        p7zip
+        ;
+    };
+  };
+}
diff --git a/hm/soispha/conf/lf/commands/scripts/archive b/hm/soispha/conf/lf/commands/scripts/archive
new file mode 100755
index 00000000..48fe25fc
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/archive
@@ -0,0 +1,54 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %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="$(tmp 'echo "gzip xz 7z zip"')";
+
+prompt "Archive name: "
+name=""
+while [ -z "$name" ] || [ -e "$name" ]
+do
+  read -r name
+  if [ -e "$name" ]; then
+    prompt "Archive already exists, overwrite [y|N]: "
+    read -r ans
+
+    if [ "$ans" = "y" ]; then
+      break
+    else
+      prompt "Archive name: "
+    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 "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in
+    "gzip")
+        tar -czf "$name".tar.gz "$@"
+        ;;
+    "xz")
+        tar -cf "$name".tar "$@"
+        xz -z -9 -e -T0 "$name".tar
+        ;;
+    "7z")
+        7z a "$name".7z "$@"
+        ;;
+    "zip")
+        zip --symlinks -r "$name".zip "$@"
+        ;;
+esac
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/broot_jump b/hm/soispha/conf/lf/commands/scripts/broot_jump
new file mode 100755
index 00000000..abefc616
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/broot_jump
@@ -0,0 +1,16 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/chmod b/hm/soispha/conf/lf/commands/scripts/chmod
new file mode 100755
index 00000000..07bc37cc
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/chmod
@@ -0,0 +1,13 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+readp "Mode bits: " bits
+
+while read -r file; do
+    chmod "$bits" "$file"
+done < "$(tmp "echo $fx")"
+
+lf -remote 'send reload'
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/clear_trash b/hm/soispha/conf/lf/commands/scripts/clear_trash
new file mode 100755
index 00000000..f2571fcc
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/clear_trash
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %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/hm/soispha/conf/lf/commands/scripts/dl_file b/hm/soispha/conf/lf/commands/scripts/dl_file
new file mode 100755
index 00000000..54518049
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/dl_file
@@ -0,0 +1,33 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+# 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
+  [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed"
+else
+  die "URL is null!"
+fi
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/dragon b/hm/soispha/conf/lf/commands/scripts/dragon
new file mode 100755
index 00000000..7e2d9ba6
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/dragon
@@ -0,0 +1,11 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+while read -r file; do
+    set -- "$@" "$file"
+done < "$(tmp "echo '$fx'")"
+
+dragon -a -x "$@"
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_individual b/hm/soispha/conf/lf/commands/scripts/dragon_individual
new file mode 100755
index 00000000..5d55aaa8
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/dragon_individual
@@ -0,0 +1,11 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+while read -r file; do
+    set -- "$@" "$file"
+done < "$(tmp "echo '$fx'")"
+
+dragon "$@"
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_stay b/hm/soispha/conf/lf/commands/scripts/dragon_stay
new file mode 100755
index 00000000..f3483483
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/dragon_stay
@@ -0,0 +1,11 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+while read -r file; do
+    set -- "$@" "$file";
+done < "$(tmp "echo '$fx'")"
+
+dragon -a "$@"
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump b/hm/soispha/conf/lf/commands/scripts/fzf_jump
new file mode 100755
index 00000000..0e53d7ca
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/fzf_jump
@@ -0,0 +1,16 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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\""
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/go_project_root b/hm/soispha/conf/lf/commands/scripts/go_project_root
new file mode 100755
index 00000000..555caaf9
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/go_project_root
@@ -0,0 +1,13 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/mk_dir b/hm/soispha/conf/lf/commands/scripts/mk_dir
new file mode 100755
index 00000000..4dca06dc
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_dir
@@ -0,0 +1,24 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/mk_file b/hm/soispha/conf/lf/commands/scripts/mk_file
new file mode 100755
index 00000000..5f245396
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_file
@@ -0,0 +1,24 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit
new file mode 100755
index 00000000..2e5a2deb
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit
@@ -0,0 +1,25 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/mk_ln b/hm/soispha/conf/lf/commands/scripts/mk_ln
new file mode 100755
index 00000000..1e97517f
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_ln
@@ -0,0 +1,36 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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 -s "$file" "$(pwd)/$ans"
+            shift
+        done
+        ;;
+esac
+rm ~/.local/share/lf/files
+# lf -remote "send clear"
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default b/hm/soispha/conf/lf/commands/scripts/mk_scr_default
new file mode 100755
index 00000000..b13ca9f5
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default
@@ -0,0 +1,31 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+
+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"
+
+cat "%SHELL_LIBRARY_TEMPLATE" > "$script"
+chmod +x "$script"
+"$VISUAL" "$script"
+
+
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp
new file mode 100755
index 00000000..a520469c
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp
@@ -0,0 +1,31 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+
+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"
+chmod +x "$script"
+"$VISUAL" "$script"
+
+
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/open b/hm/soispha/conf/lf/commands/scripts/open
new file mode 100755
index 00000000..c507482b
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/open
@@ -0,0 +1,11 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+case $(file --mime-type "$f" -bL) in
+    text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";;
+    image/*) "$IVIEWER" "$f";;
+    *) xdg-open "$f";;
+esac
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/open_config b/hm/soispha/conf/lf/commands/scripts/open_config
new file mode 100755
index 00000000..35e5165d
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/open_config
@@ -0,0 +1,7 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+"$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO: implement this
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/restore_trash b/hm/soispha/conf/lf/commands/scripts/restore_trash
new file mode 100755
index 00000000..a7bf0094
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/restore_trash
@@ -0,0 +1,7 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact
+# vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/set_wall_paper b/hm/soispha/conf/lf/commands/scripts/set_wall_paper
new file mode 100755
index 00000000..c493e773
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/set_wall_paper
@@ -0,0 +1,10 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/stripspace b/hm/soispha/conf/lf/commands/scripts/stripspace
new file mode 100755
index 00000000..91714712
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/stripspace
@@ -0,0 +1,31 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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/hm/soispha/conf/lf/commands/scripts/trash b/hm/soispha/conf/lf/commands/scripts/trash
new file mode 100755
index 00000000..8dd6033d
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/trash
@@ -0,0 +1,26 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+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, trough nix because both trashy and trash-cli provide a trash command, which conflicts
+nix run nixpkgs#trashy -- put "$@" 2> "$trash_output";
+
+cat << EOF > "$expected_error_output";
+error: 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/hm/soispha/conf/lf/commands/scripts/unarchive b/hm/soispha/conf/lf/commands/scripts/unarchive
new file mode 100755
index 00000000..ee97f3b1
--- /dev/null
+++ b/hm/soispha/conf/lf/commands/scripts/unarchive
@@ -0,0 +1,22 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+# extract the current file with the right command
+# (xkcd link: https://xkcd.com/1168/)
+set -f
+# TODO: add support for multiple files at once
+case "$f" in
+    *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";;
+    *.tar.gz|*.tgz) tar xzvf "$f";;
+    *.tar.xz|*.txz) tar xJvf "$f";;
+    *.zip) unzip "$f";;
+    *.rar)
+        die "rar is a unfree format!"
+        #unrar x $f
+        ;;
+    *.7z) 7z x "$f";;
+    *) die "Unsupported format" ;;
+esac
+# vim: ft=sh