about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/lf/commands/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/home.legacy/conf/lf/commands/default.nix')
-rw-r--r--modules/home.legacy/conf/lf/commands/default.nix227
1 files changed, 227 insertions, 0 deletions
diff --git a/modules/home.legacy/conf/lf/commands/default.nix b/modules/home.legacy/conf/lf/commands/default.nix
new file mode 100644
index 00000000..933769ac
--- /dev/null
+++ b/modules/home.legacy/conf/lf/commands/default.nix
@@ -0,0 +1,227 @@
+{
+  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
+        ;
+    };
+  };
+}