diff options
Diffstat (limited to '')
-rw-r--r-- | home/home.nix | 8 | ||||
-rw-r--r-- | home/packages.nix | 2 |
2 files changed, 6 insertions, 4 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 diff --git a/home/packages.nix b/home/packages.nix index 998f205..49d7a02 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -43,7 +43,7 @@ in (agda.withPackages (p: [ p.standard-library p.cubical ])) # html, js & co jq html-tidy nodePackages.stylelint nodePackages.js-beautify zola - libxml2 fq + libxml2 fq htmlq # purescript spago purescript # nodePackages.purescript-language-server nodejs # rust |