summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--home/home.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/home/home.nix b/home/home.nix
index 23e1abd..74f6bde 100644
--- a/home/home.nix
+++ b/home/home.nix
@@ -53,6 +53,30 @@
agenda = "CLICOLOR_FORCE=1 almanac month ~/.cache/feedsync/* | less";
xmlpretty = "xmllint --format - | bat -l xml";
};
+ functions.fetchpdf.body = ''
+ set url $argv[1]
+ if test "$url" = ""
+ echo "No url given"
+ return
+ end
+ set choice (curl $url | rg -e '<a[^>]*href="([^"]*\.pdf)"[^>]*>([^<]*)</a>' -o | sed 's/<a[^>]*href="\([^"]*\)"[^>]*>\(.*\)<\/a>/"\1" "\2"/g' | fzf)
+ if test "$status" != 0
+ return
+ end
+ set docurl (echo $choice | sed 's/"\(.*\)" ".*"/\1/g')
+ set docname (echo $choice | sed 's/".*" "\(.*\)"/\1/g')
+ echo Fetching $docname from $docurl
+ curl "$docurl" > ~/Downloads/news/"$docname".pdf
+ zathura ~/Downloads/news/"$docname".pdf
+ if test (read -P "move this file to archive? [y/N] ") = "y"
+ set filename (read -P "filename? [$docname] ")
+ if test "$filename" = ""
+ cp ~/Downloads/news/"$docname".pdf ~/archive/"$docname".pdf
+ else
+ cp ~/Downloads/news/"$docname".pdf ~/archive/$filename
+ end
+ end
+ '';
};
programs.kitty = {
@@ -147,6 +171,7 @@
macro v set browser "kitty @launch --type tab mpv --ytdl-format='bv[height<=1100]+ba' %u > /dev/null" ; open-in-browser ; set browser "${config.programs.newsboat.browser} %u"
macro f set browser "${pkgs.xdg_utils}/bin/xdg-open %u >/dev/null 2>&1 &" ; open-in-browser ; set browser "${config.programs.newsboat.browser} %u"
+ macro d set browser "kitty @launch --type tab fish -c 'fetchpdf %u'" ; open-in-browser ; set browser "${config.programs.newsboat.browser} %u"
bind-key j down
bind-key k up