mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 10:30:44 +02:00
added custom man script
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
documentation.man.generateCaches = true; # used for the man script
|
||||||
|
|
||||||
# grub theme
|
# grub theme
|
||||||
boot.loader.grub = {
|
boot.loader.grub = {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user