about summary refs log tree commit diff stats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/by-name/lf/lf/module.nix7
-rw-r--r--modules/by-name/lf/lf/wrappers/default.nix4
-rw-r--r--modules/by-name/lf/lf/wrappers/ll/default.nix18
-rwxr-xr-xmodules/by-name/lf/lf/wrappers/ll/ll.sh29
-rw-r--r--modules/by-name/lf/lf/wrappers/lm/default.nix18
-rwxr-xr-xmodules/by-name/lf/lf/wrappers/lm/lm.sh28
-rw-r--r--modules/by-name/zs/zsh/module.nix5
7 files changed, 104 insertions, 5 deletions
diff --git a/modules/by-name/lf/lf/module.nix b/modules/by-name/lf/lf/module.nix
index 2e6669e8..ea9970ef 100644
--- a/modules/by-name/lf/lf/module.nix
+++ b/modules/by-name/lf/lf/module.nix
@@ -19,6 +19,8 @@
   commands = import ./commands {inherit pkgs sysLib shell_library system;};
   keybindings = import ./keybindings {inherit (cfg.keymaps) uid downloadDir;};
 
+  packages = import ./wrappers {inherit pkgs;};
+
   cfg = config.soispha.programs.lf;
 in {
   imports = [
@@ -58,6 +60,11 @@ in {
         "lf/colors".source = ./colors;
       };
 
+      programs.zsh.shellAliases = {
+        ll = ". ${lib.getExe packages.ll}";
+        lm = ". ${lib.getExe packages.lm}";
+      };
+
       programs.lf = {
         enable = true;
 
diff --git a/modules/by-name/lf/lf/wrappers/default.nix b/modules/by-name/lf/lf/wrappers/default.nix
new file mode 100644
index 00000000..7257a66e
--- /dev/null
+++ b/modules/by-name/lf/lf/wrappers/default.nix
@@ -0,0 +1,4 @@
+{pkgs}: {
+  ll = pkgs.callPackage ./ll {};
+  lm = pkgs.callPackage ./lm {};
+}
diff --git a/modules/by-name/lf/lf/wrappers/ll/default.nix b/modules/by-name/lf/lf/wrappers/ll/default.nix
new file mode 100644
index 00000000..6e4ee336
--- /dev/null
+++ b/modules/by-name/lf/lf/wrappers/ll/default.nix
@@ -0,0 +1,18 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{writeShellApplication}:
+writeShellApplication {
+  name = "ll";
+  text = builtins.readFile ./ll.sh;
+
+  # This is sourced in the shell
+  inheritPath = true;
+  bashOptions = [];
+}
diff --git a/modules/by-name/lf/lf/wrappers/ll/ll.sh b/modules/by-name/lf/lf/wrappers/ll/ll.sh
new file mode 100755
index 00000000..e012cffa
--- /dev/null
+++ b/modules/by-name/lf/lf/wrappers/ll/ll.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env dash
+
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+last_directory="$(mktemp)"
+cleanup() {
+    rm "$last_directory"
+}
+trap cleanup EXIT
+
+command lf -last-dir-path="$last_directory" "$@"
+
+dir="$(cat "$last_directory")"
+if cd "$dir"; then
+    [ -d "$XDG_RUNTIME_DIR/ll" ] || mkdir "$XDG_RUNTIME_DIR/ll"
+    echo "$dir" >"$XDG_RUNTIME_DIR/ll/last_directory"
+else
+    die "$dir does not exist!"
+fi
+
+# vim: ft=sh
diff --git a/modules/by-name/lf/lf/wrappers/lm/default.nix b/modules/by-name/lf/lf/wrappers/lm/default.nix
new file mode 100644
index 00000000..42bdc687
--- /dev/null
+++ b/modules/by-name/lf/lf/wrappers/lm/default.nix
@@ -0,0 +1,18 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{writeShellApplication}:
+writeShellApplication {
+  name = "lm";
+  text = builtins.readFile ./lm.sh;
+
+  # This is sourced in the shell
+  inheritPath = true;
+  bashOptions = [];
+}
diff --git a/modules/by-name/lf/lf/wrappers/lm/lm.sh b/modules/by-name/lf/lf/wrappers/lm/lm.sh
new file mode 100755
index 00000000..71213721
--- /dev/null
+++ b/modules/by-name/lf/lf/wrappers/lm/lm.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env dash
+
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+die() {
+    echo "ERROR: $1"
+    exit 1
+}
+
+msg() {
+    echo "$1"
+}
+
+if [ -f "$XDG_RUNTIME_DIR/ll/last_directory" ]; then
+    last_dir="$(cat "$XDG_RUNTIME_DIR/ll/last_directory")"
+    cd "$last_dir" || die "$last_dir does not exist!"
+else
+    msg "No last directory saved (try using ll instead)."
+fi
+# vim: ft=sh
diff --git a/modules/by-name/zs/zsh/module.nix b/modules/by-name/zs/zsh/module.nix
index 038048da..bf7e2a71 100644
--- a/modules/by-name/zs/zsh/module.nix
+++ b/modules/by-name/zs/zsh/module.nix
@@ -138,11 +138,6 @@ in {
           HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND = "bg=cyan,fg=white";
           HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND = "fg=red,underline,standout,bold";
         };
-
-        shellAliases = {
-          ll = ". ${lib.getExe pkgs.ll}";
-          lm = ". ${lib.getExe pkgs.lm}";
-        };
       };
     };
   };