1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat(scripts): pimp rfc script

This commit is contained in:
2021-03-11 10:26:19 +01:00
parent 3aabeea2c3
commit 68e60b93ff
4 changed files with 30 additions and 1 deletions

View File

@@ -302,6 +302,11 @@ in rec {
unicodmenu = pkgs.callPackage ./unicodmenu.nix { };
rfc = wrapScript {
script = ./rfc.sh;
name = "rfc";
packages = [ pkgs.curl pkgs.pup pkgs.gnused pkgs.gawk pkgs.gnugrep pkgs.fzf ];
};
bvg = pkgs.callPackage ./bvg.nix { };
nav = pkgs.callPackage ./nav.nix { };

24
packages/scripts/rfc.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -efu
cache_file=/tmp/rfc-index.txt
fetch_index() {
if [ -f "$cache_file" ]
then cat "$cache_file"
else curl -sSL https://tools.ietf.org/rfc/index | tee "$cache_file"
fi
}
rfc_list="$(fetch_index \
| pup 'pre text{}' \
| awk '$0 != "" {printf "%s",$0} $0 == "" {printf "\n"}' \
| sed 's/\s\+/ /g' \
| sed 'n;d' \
| grep '^RFC[[:digit:]]' \
| sed 's/RFC\([[:digit:]]\+\)/\1\t/;s/\. .*//'
)"
selection="$(echo "$rfc_list" | fzf | awk '{print $1}')"
curl -sSL "https://tools.ietf.org/rfc/rfc$selection.txt" | less