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:
@@ -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
24
packages/scripts/rfc.sh
Normal 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
|
||||
Reference in New Issue
Block a user