added custom man script

This commit is contained in:
Tomas Rivera
2026-03-08 18:41:34 +01:00
parent 4f7d85fd6b
commit 3b5ffc09e7
4 changed files with 46 additions and 0 deletions
+1
View File
@@ -16,6 +16,7 @@
]; ];
documentation.man.generateCaches = true; # used for the man script
# grub theme # grub theme
boot.loader.grub = { boot.loader.grub = {
+1
View File
@@ -73,6 +73,7 @@ home.packages = [
(pkgs.callPackage ../../modules/scripts/performance-mode.nix {}) (pkgs.callPackage ../../modules/scripts/performance-mode.nix {})
(pkgs.callPackage ../../modules/scripts/btm.nix {}) (pkgs.callPackage ../../modules/scripts/btm.nix {})
(pkgs.callPackage ../../modules/scripts/manix.nix {}) (pkgs.callPackage ../../modules/scripts/manix.nix {})
(pkgs.callPackage ../../modules/scripts/man.nix {})
#pkgs #pkgs
pkgs.gruvbox-gtk-theme pkgs.gruvbox-gtk-theme
# # Adds the 'hello' command to your environment. It prints a friendly # # Adds the 'hello' command to your environment. It prints a friendly
+1
View File
@@ -27,6 +27,7 @@ custom-cat() {
pomodoro = "custom-tomato"; pomodoro = "custom-tomato";
librewolf = "kitty --class \"custom-librewolfprofiles\" --name \"Select LibreWolf profile\" --hold custom-librewolfprofiles"; librewolf = "kitty --class \"custom-librewolfprofiles\" --name \"Select LibreWolf profile\" --hold custom-librewolfprofiles";
manix = "custom-manix"; manix = "custom-manix";
man = "custom-man";
}; };
}; };
} }
+43
View File
@@ -0,0 +1,43 @@
{ writeShellApplication, man, ripgrep, fzf, ... }:
let
cacheTime = "10";
in
writeShellApplication {
name = "custom-man";
runtimeInputs = [
man
ripgrep
fzf
];
text = ''
CACHE_DIR="''${XDG_CACHE_HOME:-$HOME/.cache}"
CACHE_FILE="$CACHE_DIR/custom-man-options.txt"
mkdir -p "$CACHE_DIR"
REGENERATE=0
# check if -r flag was passed
if [ "''${1:-}" = "-r" ]; then
REGENERATE=1
fi
# regenerate if file does not exist or is older than cacheTime days
if [ ! -f "$CACHE_FILE" ] || [ "$(find "$CACHE_FILE" -mtime +${cacheTime} -print)" ]; then
REGENERATE=1
fi
if [ $REGENERATE -eq 1 ]; then
echo "(Re)building custom-manix cache..."
mkdir -p "$(dirname "$CACHE_FILE")"
man -k . > "$CACHE_FILE"
fi
# read from cache and pipe into fzf
cat "$CACHE_FILE" \
| fzf --preview "man {1}" \
| xargs man
'';
}