From 8d8bc982564fc5af477869bf8a4e682550dec67a Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 23 Aug 2026 21:08:16 +0200 Subject: modules/lf: Rewrite `ll` and `lm` to fish's syntax These need to be written in fish, so that they can work with the `.` command. --- modules/by-name/lf/lf/module.nix | 12 ++++++------ modules/by-name/lf/lf/wrappers/default.nix | 4 ---- modules/by-name/lf/lf/wrappers/ll.fish | 23 ++++++++++++++++++++++ modules/by-name/lf/lf/wrappers/ll/default.nix | 18 ----------------- modules/by-name/lf/lf/wrappers/ll/ll.sh | 23 ---------------------- modules/by-name/lf/lf/wrappers/lm.fish | 20 +++++++++++++++++++ modules/by-name/lf/lf/wrappers/lm/default.nix | 18 ----------------- modules/by-name/lf/lf/wrappers/lm/lm.sh | 28 --------------------------- 8 files changed, 49 insertions(+), 97 deletions(-) delete mode 100644 modules/by-name/lf/lf/wrappers/default.nix create mode 100644 modules/by-name/lf/lf/wrappers/ll.fish delete mode 100644 modules/by-name/lf/lf/wrappers/ll/default.nix delete mode 100755 modules/by-name/lf/lf/wrappers/ll/ll.sh create mode 100644 modules/by-name/lf/lf/wrappers/lm.fish delete mode 100644 modules/by-name/lf/lf/wrappers/lm/default.nix delete mode 100755 modules/by-name/lf/lf/wrappers/lm/lm.sh (limited to 'modules') diff --git a/modules/by-name/lf/lf/module.nix b/modules/by-name/lf/lf/module.nix index c47599bd..a95bdb03 100644 --- a/modules/by-name/lf/lf/module.nix +++ b/modules/by-name/lf/lf/module.nix @@ -83,11 +83,11 @@ in { # fish '' function ll - . ${lib.getExe packages.ll} + . ${./wrappers/ll.fish} end function lm - . ${lib.getExe packages.lm} + . ${./wrappers/lm.fish} end ''; @@ -97,10 +97,10 @@ in { "lf/colors".source = ./colors; }; - programs.zsh.shellAliases = { - ll = ". ${lib.getExe packages.ll}"; - lm = ". ${lib.getExe packages.lm}"; - }; + # 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 deleted file mode 100644 index 7257a66e..00000000 --- a/modules/by-name/lf/lf/wrappers/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{pkgs}: { - ll = pkgs.callPackage ./ll {}; - lm = pkgs.callPackage ./lm {}; -} diff --git a/modules/by-name/lf/lf/wrappers/ll.fish b/modules/by-name/lf/lf/wrappers/ll.fish new file mode 100644 index 00000000..7a146993 --- /dev/null +++ b/modules/by-name/lf/lf/wrappers/ll.fish @@ -0,0 +1,23 @@ +#!/usr/bin/env fish + +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz +# 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 . + +begin + test -d "$XDG_RUNTIME_DIR/ll"; or mkdir "$XDG_RUNTIME_DIR/ll" + set last_directory "$XDG_RUNTIME_DIR/ll/last_directory" + + command lf -last-dir-path="$last_directory" "$argv" + + set dir "$(cat "$last_directory")" + if not cd "$dir" + echo "ll: Failed to cd to '$dir'. Does it exist?" + end +end diff --git a/modules/by-name/lf/lf/wrappers/ll/default.nix b/modules/by-name/lf/lf/wrappers/ll/default.nix deleted file mode 100644 index 6e4ee336..00000000 --- a/modules/by-name/lf/lf/wrappers/ll/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# 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 . -{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 deleted file mode 100755 index 9bb314c6..00000000 --- a/modules/by-name/lf/lf/wrappers/ll/ll.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env dash - -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# 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 . - -[ -d "$XDG_RUNTIME_DIR/ll" ] || mkdir "$XDG_RUNTIME_DIR/ll" -last_directory="$XDG_RUNTIME_DIR/ll/last_directory" - -command lf -last-dir-path="$last_directory" "$@" - -dir="$(cat "$last_directory")" -if ! cd "$dir"; then - die "ll: Failed to cd to '$dir'. Does it exist?" -fi - -# vim: ft=sh diff --git a/modules/by-name/lf/lf/wrappers/lm.fish b/modules/by-name/lf/lf/wrappers/lm.fish new file mode 100644 index 00000000..b590c143 --- /dev/null +++ b/modules/by-name/lf/lf/wrappers/lm.fish @@ -0,0 +1,20 @@ +#!/usr/bin/env fish + +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz +# 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 . + +begin + if test -f "$XDG_RUNTIME_DIR/ll/last_directory" + set last_dir "$(cat "$XDG_RUNTIME_DIR/ll/last_directory")" + cd "$last_dir"; or echo "$last_dir does not exist!" + else + echo "No last directory saved (try using ll instead)." + end +end diff --git a/modules/by-name/lf/lf/wrappers/lm/default.nix b/modules/by-name/lf/lf/wrappers/lm/default.nix deleted file mode 100644 index 42bdc687..00000000 --- a/modules/by-name/lf/lf/wrappers/lm/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# 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 . -{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 deleted file mode 100755 index 71213721..00000000 --- a/modules/by-name/lf/lf/wrappers/lm/lm.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env dash - -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# 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 . - -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 -- cgit v1.3.1