nixos/config/newsboat/kitty-img-pager.sh

24 lines
678 B
Bash
Raw Permalink Normal View History

2023-07-29 17:24:05 +04:00
#!/usr/bin/env bash
2023-07-29 17:08:02 +04:00
# Shows images, scaled to terminal dimensions, via kitty's icat.
# Designed for image-feeds like xkcd.com.
# by Timm Heuss (https://github.com/heussd/) - CC-BY 4.0
#
# Usage:
# 1) Define a new macro in your config:
# macro i set pager "$PATHTOTHIS/kitty-img-pager"; open; set pager internal
# 2) Now you use this pager in articleview using the hotkey <comma>+<i>
2023-07-29 17:24:05 +04:00
#set -o errexit
#set -o pipefail
#set -o nounset
2023-07-29 17:08:02 +04:00
2023-07-29 17:24:05 +04:00
image=$(grep -E -o "https?://[a-zA-Z0-9./?=_%:-]*" < "${1}" | tail -1)
2023-07-29 17:08:02 +04:00
# Detect terminal dimensions
dims="$(tput cols)x$(tput lines)@0x0"
clear
kitty +kitten icat --clear
kitty +kitten icat --hold --scale-up --place "$dims" "$image"
clear