1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00
Files
niveum/packages/scripts/rfc.sh

25 lines
549 B
Bash

#!/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