aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/lf
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/lf')
-rwxr-xr-xmodules/by-name/lf/lf/commands/base.sh7
-rw-r--r--modules/by-name/lf/lf/commands/default.nix20
-rwxr-xr-xmodules/by-name/lf/lf/commands/scripts/cd_lf_make_map.sh27
-rwxr-xr-xmodules/by-name/lf/lf/commands/scripts/trash_restore.sh6
-rw-r--r--modules/by-name/lf/lf/ctpv/prev/application/archive/default.nix4
-rw-r--r--modules/by-name/lf/lf/ctpv/prev/audio/default.nix2
-rw-r--r--modules/by-name/lf/lf/keybindings/default.nix174
-rw-r--r--modules/by-name/lf/lf/module.nix46
-rwxr-xr-xmodules/by-name/lf/lf/wrappers/ll/ll.sh14
9 files changed, 201 insertions, 99 deletions
diff --git a/modules/by-name/lf/lf/commands/base.sh b/modules/by-name/lf/lf/commands/base.sh
index 0c2f391a..e0b6216c 100755
--- a/modules/by-name/lf/lf/commands/base.sh
+++ b/modules/by-name/lf/lf/commands/base.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
# nixos-config - My current NixOS configuration
#
@@ -41,7 +41,7 @@ prompt() {
# set -- "$@" "$file"
# done < "$(echo "$fx" | tmp)"
tmp() {
- __base_tmp_temporary_file="$(mktemp -t --tmpdir="$__base_tmp_temporary_directory" lf_commands_tmp_fun_XXXXXXXX )"
+ __base_tmp_temporary_file="$(mktemp -t --tmpdir="$__base_tmp_temporary_directory" lf_commands_tmp_fun_XXXXXXXX)"
cat >"$__base_tmp_temporary_file"
echo "$__base_tmp_temporary_file"
}
@@ -60,6 +60,9 @@ trap 'rm --recursive "$__base_tmp_temporary_directory"' EXIT
lf_cmd() {
arguments=""
for arg in "$@"; do
+ # We _can_ use the fancy bash syntax, but it's really hard to correctly quote the
+ # single quote in bash, and I don't really feel like it's worth it.
+ # shellcheck disable=SC2001
arg="$(echo "$arg" | sed "s/'/\\\'/g")"
if [ -z "$arguments" ]; then
diff --git a/modules/by-name/lf/lf/commands/default.nix b/modules/by-name/lf/lf/commands/default.nix
index b6baf1df..98b3119f 100644
--- a/modules/by-name/lf/lf/commands/default.nix
+++ b/modules/by-name/lf/lf/commands/default.nix
@@ -16,7 +16,14 @@
pkgs.writeShellApplication {
inherit name;
text = builtins.readFile ./base.sh + builtins.readFile ./scripts/${name}.sh;
- runtimeInputs = [pkgs.lf pkgs.mktemp pkgs.coreutils] ++ dependencies;
+ runtimeInputs =
+ [
+ pkgs.lf
+ pkgs.mktemp
+ pkgs.coreutils
+ pkgs.gnused
+ ]
+ ++ dependencies;
inheritPath = keepPath;
}
+ "/bin/${name}";
@@ -61,7 +68,7 @@ in {
name = "archive_decompress";
dependencies = [
pkgs.gnutar
- pkgs.openjdk
+ pkgs.openjdk_headless
pkgs.p7zip
pkgs.xz
pkgs.gzip
@@ -72,6 +79,12 @@ in {
name = "cd_project_root";
dependencies = [pkgs.git];
};
+ cd_lf_make_map = shell {
+ name = "cd_lf_make_map";
+ dependencies = [
+ pkgs.lf-make-map
+ ];
+ };
chmod = pipe {
name = "chmod";
@@ -156,9 +169,6 @@ in {
dependencies = [
pkgs.conceal
pkgs.fzf
- pkgs.gawk
- pkgs.trashy
- pkgs.gnused
];
};
diff --git a/modules/by-name/lf/lf/commands/scripts/cd_lf_make_map.sh b/modules/by-name/lf/lf/commands/scripts/cd_lf_make_map.sh
new file mode 100755
index 00000000..00befd3f
--- /dev/null
+++ b/modules/by-name/lf/lf/commands/scripts/cd_lf_make_map.sh
@@ -0,0 +1,27 @@
+# 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>.
+
+# shellcheck shell=sh
+
+# shellcheck disable=SC2269
+f="$f"
+# shellcheck disable=SC2269
+fx="$fx"
+# shellcheck disable=SC2269
+fs="$fs"
+# shellcheck disable=SC2269
+id="$id"
+
+root="$(lf-make-map --depth 4 interactive ~/media ~/repos ~/documents ~/.config ~/.local)"
+if [ "$root" ]; then
+ lf_cmd cd "$root" || die "Bug: Failed to cd to selected path at '$root'"
+fi
+
+# vim: ft=sh
diff --git a/modules/by-name/lf/lf/commands/scripts/trash_restore.sh b/modules/by-name/lf/lf/commands/scripts/trash_restore.sh
index 7b078c26..789ab59a 100755
--- a/modules/by-name/lf/lf/commands/scripts/trash_restore.sh
+++ b/modules/by-name/lf/lf/commands/scripts/trash_restore.sh
@@ -19,9 +19,5 @@ fs="$fs"
# shellcheck disable=SC2269
id="$id"
-while IFS="$(printf '\n')" read -r file; do
- set -- "$@" "$(pwd)/$file"
-done <"$(conceal list | fzf --multi --ansi | awk '{$1="";$2=""; print $0}' | sed 's/^\s*//' | tmp)"
-
-[ "$#" -ne 0 ] && trash restore --match=exact "$@"
+conceal restore --finder=fzf
# vim: ft=sh
diff --git a/modules/by-name/lf/lf/ctpv/prev/application/archive/default.nix b/modules/by-name/lf/lf/ctpv/prev/application/archive/default.nix
index d64c9572..a5fc2c50 100644
--- a/modules/by-name/lf/lf/ctpv/prev/application/archive/default.nix
+++ b/modules/by-name/lf/lf/ctpv/prev/application/archive/default.nix
@@ -94,6 +94,10 @@
pkgs.xz
pkgs.zip
+ pkgs.cabextract
+
+ pkgs.coreutils
+
# Unfree stuff
# pkgs.lha
# pkgs.rar
diff --git a/modules/by-name/lf/lf/ctpv/prev/audio/default.nix b/modules/by-name/lf/lf/ctpv/prev/audio/default.nix
index 08a2f9d6..b9d4ff0d 100644
--- a/modules/by-name/lf/lf/ctpv/prev/audio/default.nix
+++ b/modules/by-name/lf/lf/ctpv/prev/audio/default.nix
@@ -14,7 +14,7 @@
matches.mime = ["audio/*"];
dependencies = [
pkgs.ffmpegthumbnailer
- pkgs.ffmpeg
+ pkgs.ffmpeg-headless
pkgs.chafa
pkgs.exiftool
diff --git a/modules/by-name/lf/lf/keybindings/default.nix b/modules/by-name/lf/lf/keybindings/default.nix
index fbc33f6f..bd4b2a2c 100644
--- a/modules/by-name/lf/lf/keybindings/default.nix
+++ b/modules/by-name/lf/lf/keybindings/default.nix
@@ -11,54 +11,103 @@
uid,
downloadDir,
}: {
- # Remove some defaults
- "'\"'" = null;
- ";" = null;
- "\"'\"" = null;
- c = null;
- d = null;
- e = null;
- j = null;
- k = null;
- m = null;
- f = null;
+ # v o visual-change
+ # v <esc> visual-discard
+ # v o visual-change
+ # v V visual-accept
+
+ "\\!" = "shell-wait";
+ "\\$" = "shell";
+ "\\%" = "shell-pipe";
+ "\\&" = "shell-async";
+ "\\:" = "read";
+
+ "<f-1>" = "help";
+
+ "<left>" = "updir";
+ "<right>" = "open";
+ "<down>" = "down";
+ "<up>" = "up";
+
+ "<c-f>" = "page-down";
+ "<pgdn>" = "page-down";
+ "<pgup>" = "page-up";
+ "<c-b>" = "page-up";
+
+ "[" = "jump-prev";
+ "]" = "jump-next";
+ q = "quit";
# Sorting
- kn = ":set sortby natural; set info";
- ks = ":set sortby size; set info size";
- kt = ":set sortby time; set info time";
- ka = ":set sortby atime; set info atime";
- kc = ":set sortby ctime; set info ctime";
- ke = ":set sortby ext; set info";
+ k = {
+ a = ":{{ set sortby atime; set info atime; }}";
+ b = ":{{ set sortby btime; set info btime; }}";
+ c = ":{{ set sortby ctime; set info ctime; }}";
+ e = ":{{ set sortby ext; set info; }}";
+ n = ":{{ set sortby natural; set info; }}";
+ s = ":{{ set sortby size; set info size; }}";
+ t = ":{{ set sortby time; set info time; }}";
+ };
+ z = {
+ a = "set info size:time";
+ h = "set hidden!";
+ n = "set info";
+ r = "set reverse!";
+ s = "set info size";
+ t = "set info time";
+ };
# Searching
l = "search-next";
L = "search-prev";
- # File Openers
- ee = "\$\$EDITOR \"$f\"";
- es = "\$ nvim -S \"$f\"";
+ "/" = "search";
+ "?" = "search-back";
+ F = "find-back";
+ "," = "find-prev";
+
+ # File edit
+ e = {
+ e = "\${{ $EDITOR \"$f\" }}";
+ s = "\${{ nvim -S \"$f\" }}";
+ };
+
u = "view_file";
- cc = "\$sudo -e \"$f\"";
- fe = "execute";
- fl = "follow_link";
- cp = "set_clipboard_path";
+
+ f = {
+ e = "execute";
+ l = "follow_link";
+ };
+
+ c = {
+ h = "chmod";
+ p = "set_clipboard_path";
+ s = "stripspace";
+ };
# Archive Mappings
- au = "archive_decompress";
- aa = "archive_compress";
+ a = {
+ a = "archive_compress";
+ u = "archive_decompress";
+ };
- # Trash Mappings
- dd = "trash";
- jc = "trash_clear";
- jr = "trash_restore";
+ D = {
+ D = "delete";
+ };
+ d = {
+ # Trash Mappings
+ d = "trash";
- # Dragon Mapping
- dr = "dragon";
- ds = "dragon_stay";
- di = "dragon_individual";
+ # Dragon Mapping
+ i = "dragon_individual";
+ r = "dragon";
+ s = "dragon_stay";
+ };
- cs = "stripspace";
+ j = {
+ c = "trash_clear";
+ r = "trash_restore";
+ };
# Vim keys
h = "updir";
@@ -67,37 +116,48 @@
s = "open";
# Basic Functions
- "." = "set hidden!";
- DD = "delete";
p = "paste";
x = "cut";
y = "copy";
"<enter>" = "open";
- mk = "mk_link";
- mf = "mk_file";
- md = "mk_directory";
- ms = "mk_script";
-
- ch = "chmod";
- bg = "set_wallpaper";
- r = ":rename; cmd-end";
- H = "cd_project_root";
- R = "reload";
+ # Selecting
+ v = "invert";
+ V = "visual";
+ "<space>" = ":{{ toggle; down; }}";
C = "clear";
U = "unselect";
- # Movement
- gjr = "cd ~/.local/share/Trash/files";
- gus = "cd /run/user/${builtins.toString uid}";
+ m = {
+ d = "mk_directory";
+ f = "mk_file";
+ l = "mk_link";
+ s = "mk_script";
+ };
+
+ b = {
+ g = "set_wallpaper";
+ };
+
+ r = ":{{ rename; cmd-end; }}";
+ "<c-r>" = "reload";
+ R = "reload";
+ "<c-l>" = "redraw";
- gc = "cd ~/.config";
- gl = "cd ~/.local";
- gE = "cd /etc";
- gD = "cd ${downloadDir}";
+ # Change cursor position
+ G = "bottom";
+ H = "high";
+ M = "middle";
- "gU." = "cd /usr";
- gUs = " cd /usr/share";
+ # (walking) Movement
+ w = {
+ d = "cd ${downloadDir}";
+ e = "cd /etc";
+ H = "cd ~";
+ h = "cd_project_root";
+ t = "cd /tmp";
+ u = "cd /run/user/${builtins.toString uid}";
+ };
- gt = "cd /tmp";
+ g = "cd_lf_make_map";
}
diff --git a/modules/by-name/lf/lf/module.nix b/modules/by-name/lf/lf/module.nix
index 8dfd0c52..4205771e 100644
--- a/modules/by-name/lf/lf/module.nix
+++ b/modules/by-name/lf/lf/module.nix
@@ -14,10 +14,35 @@
shell_library,
system,
lib,
+ libraries,
...
}: let
- commands = import ./commands {inherit pkgs sysLib shell_library system;};
- keybindings = import ./keybindings {inherit (cfg.keymaps) uid downloadDir;};
+ real_commands = import ./commands {inherit pkgs sysLib shell_library system;};
+ keybindings_raw = import ./keybindings {inherit (cfg.keymaps) uid downloadDir;};
+
+ # NOTE: There is no (easy) way for me to make sure, that the `clearmaps` command is
+ # generated in the lf config before the keymapping commands.
+ # This command injection works around that. <2026-07-21>
+ commands = libraries.extra.warnMerge real_commands {
+ __clearmaps_injection = ''
+ :{{
+ clearmaps
+ }};
+ clearmaps
+ '';
+ } "lf command map";
+
+ process = prefix: attrs:
+ lib.mapAttrsToList (name: value:
+ if (builtins.isAttrs value)
+ then
+ (process name value)
+ ++ [(lib.nameValuePair name null)]
+ else if prefix == null
+ then (lib.nameValuePair name value)
+ else (lib.nameValuePair (prefix + name) value))
+ attrs;
+ keybindings = builtins.listToAttrs (lib.lists.flatten (process null keybindings_raw));
packages = import ./wrappers {inherit pkgs;};
@@ -85,7 +110,6 @@ in {
drawbox = true;
- # errorfmt = "\\033[1;91m==> ERROR:\\033[0m\\033[1;93m%s\\033[0m";
errorfmt = "\\033[1;91m%s\\033[0m";
hidden = true; # show hidden files
icons = true;
@@ -94,22 +118,6 @@ in {
shell = "${lib.getExe pkgs.dash}";
shellopts = "-eu"; # e: exit on error; u: error for unset variables
};
- extraConfig = ''
- # Dynamically generate the cd mappings.
- # This code dependends on the fact, that the lf server was started previously
- # and keep running through `autoquit = false`.
- # (Otherwise, the remote command is silently dropped: https://github.com/gokcehan/lf/issues/495)
- &{{
- tmp="$(mktemp -t lf_make_map_dynamic_mapping_source_XXXXX)"
- ${lib.getExe pkgs.lf-make-map} --depth 4 generate ~/media ~/repos ~/documents >"$tmp"
-
- lf -remote "send $id source $tmp"
- sleep 1
- lf -remote "send $id source $tmp"
-
- rm "$tmp"
- }}
- '';
};
};
};
diff --git a/modules/by-name/lf/lf/wrappers/ll/ll.sh b/modules/by-name/lf/lf/wrappers/ll/ll.sh
index ce29fd97..9bb314c6 100755
--- a/modules/by-name/lf/lf/wrappers/ll/ll.sh
+++ b/modules/by-name/lf/lf/wrappers/ll/ll.sh
@@ -10,20 +10,14 @@
# 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 -t ll_last_directory_XXXXXXX)"
-cleanup() {
- rm "$last_directory"
-}
-trap cleanup EXIT
+[ -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
- [ -d "$XDG_RUNTIME_DIR/ll" ] || mkdir "$XDG_RUNTIME_DIR/ll"
- echo "$dir" >"$XDG_RUNTIME_DIR/ll/last_directory"
-else
- die "$dir does not exist!"
+if ! cd "$dir"; then
+ die "ll: Failed to cd to '$dir'. Does it exist?"
fi
# vim: ft=sh