diff options
Diffstat (limited to 'home/home.nix')
-rw-r--r-- | home/home.nix | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/home/home.nix b/home/home.nix index 0a5072f..49b5713 100644 --- a/home/home.nix +++ b/home/home.nix @@ -101,6 +101,7 @@ agenda = "CLICOLOR_FORCE=1 almanac month ~/.cache/feedsync/* | less"; xmlpretty = "xmllint --format - | bat -l xml"; wormhole = "wormhole-rs"; + noms = "curl https://www.bahn.de/service/zug/db_lounge -s | htmlq --attribute href a | grep Speisen | xargs curl -s | pdftotext - /dev/stdout | less"; }; functions.fetchpdf.body = '' set url $argv[1] @@ -108,12 +109,13 @@ echo "No url given" return end - set choice (curl -L $url | rg -e '<a[^>]*href="([^"]*\.pdf)"[^>]*>([^<]*)</a>' -o | sed 's/<a[^>]*href="\([^"]*\)"[^>]*>\(.*\)<\/a>/"\1" "\2"/g' | fzf) + set anchors (curl -L $url | sd '\n' "" | htmlq a | rg .pdf) + set choice (paste (printf '%s\n' $anchors | htmlq -t a | psub) (printf '%s\n' $anchors | htmlq --attribute href a | psub) | fzf) if test "$status" != 0 return end - set docurl (echo $choice | sed 's/"\(.*\)" ".*"/\1/g') - set docname (echo $choice | sed 's/".*" "\(.*\)"/\1/g') + set docurl (echo $choice | cut -f 2) + set docname (echo $choice | cut -f 1) echo Fetching $docname from $docurl curl "$docurl" > ~/Downloads/news/"$docname".pdf zathura ~/Downloads/news/"$docname".pdf |