From 6f9b26e63384e6fd32b3879b23905e10e0dace81 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 2 Jun 2026 21:52:36 +0200 Subject: modules/lf: Use the new lf-make-map interactive mode That also forced some changes to other cd key mappings. --- modules/by-name/lf/lf/commands/default.nix | 6 +++++ .../lf/lf/commands/scripts/cd_lf_make_map.sh | 27 ++++++++++++++++++++++ modules/by-name/lf/lf/keybindings/default.nix | 18 +++++---------- modules/by-name/lf/lf/module.nix | 17 -------------- 4 files changed, 39 insertions(+), 29 deletions(-) create mode 100755 modules/by-name/lf/lf/commands/scripts/cd_lf_make_map.sh (limited to 'modules/by-name/lf') diff --git a/modules/by-name/lf/lf/commands/default.nix b/modules/by-name/lf/lf/commands/default.nix index ae02c45b..42dc548e 100644 --- a/modules/by-name/lf/lf/commands/default.nix +++ b/modules/by-name/lf/lf/commands/default.nix @@ -79,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"; 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 +# 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 . + +# 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/keybindings/default.nix b/modules/by-name/lf/lf/keybindings/default.nix index fbc33f6f..5d8ad78f 100644 --- a/modules/by-name/lf/lf/keybindings/default.nix +++ b/modules/by-name/lf/lf/keybindings/default.nix @@ -82,22 +82,16 @@ ch = "chmod"; bg = "set_wallpaper"; r = ":rename; cmd-end"; - H = "cd_project_root"; R = "reload"; C = "clear"; U = "unselect"; # Movement - gjr = "cd ~/.local/share/Trash/files"; - gus = "cd /run/user/${builtins.toString uid}"; + Gu = "cd /run/user/${builtins.toString uid}"; + Ge = "cd /etc"; + Gd = "cd ${downloadDir}"; + Gt = "cd /tmp"; + Gh = "cd_project_root"; - gc = "cd ~/.config"; - gl = "cd ~/.local"; - gE = "cd /etc"; - gD = "cd ${downloadDir}"; - - "gU." = "cd /usr"; - gUs = " cd /usr/share"; - - 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..daa236e6 100644 --- a/modules/by-name/lf/lf/module.nix +++ b/modules/by-name/lf/lf/module.nix @@ -85,7 +85,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 +93,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" - }} - ''; }; }; }; -- cgit v1.3.1