diff --git a/README.md b/README.md index 01de779..ef6097e 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Right now, it runs in And has experimental support for - [libsixel](https://github.com/saitoha/libsixel) +- The linux TTY It is a ridiculous hack---a bash script wrapped around some special terminal escape codes and a bunch of command line tools. But it works well enough for me to be useful. @@ -175,6 +176,15 @@ Here is a screenshot of the best results I can get using a version of xterm buil ![sixel screenshot](screenshot_xterm.png) +w3m-imgcat +---------- + +If you want to try out the experimental w3m-imgcat support, be sure you have `w3m-img` for debian or `w3m-imgcat` for arch installed. + +Here is a screenshot of the best results I can get using w3m-imgcat on linux 6.3.3: + +![TTY screenshot](screenshot_tty.png) + Installation ============ @@ -190,6 +200,7 @@ $ termpdf -h termpdf -d n, --depth N how deep to search directories for images -sixel use libsixel to (badly) display graphics + -imgcat use w3m-imgcat to display graphics -kitty force using kitty to display graphics -iterm force using iterm to display graphics -k list keyboard shortcuts @@ -217,7 +228,7 @@ depth of `find`'s recursive search. By default, `termpdf` uses Kitty's image rendering if it is available, and otherwise tries to use iTerm's image rendering. You can override this behavior -by specifying one of `-sixel`, `-kitty`, or `-iterm`. +by specifying one of `-sixel`, `imgcat`, `-kitty`, or `-iterm`. Keyboard Shortcuts ------------------ diff --git a/screenshot_tty.png b/screenshot_tty.png new file mode 100644 index 0000000..1e2da89 Binary files /dev/null and b/screenshot_tty.png differ diff --git a/termpdf b/termpdf index 6478518..aa4dbd4 100755 --- a/termpdf +++ b/termpdf @@ -10,7 +10,7 @@ fi ########################################################################### # termpdf is a barebones inline pdf and djvu viewer. It currently works # in iTerm 2.9 or later, Kitty, and (very badly) in terminals that support -# libsixel, +# libsixel, and the tty with w3m-imgcat. # # It is a ridiculous hack, but it usually works for me. ########################################################################### @@ -270,6 +270,10 @@ function second_setup() { ;; linux*) guiviewer="xdg-open" + imgcat="w3m-img" + if ! type "w3m-img" > /dev/null; then + imgcat="imgcat" + fi ;; *) guiviewer="unknown" @@ -864,6 +868,7 @@ function clihelp() { $(basename $0) -d n, --depth N % how deep to search directories for images -sixel % use libsixel to (badly) display graphics + -imgcat % use w3m-imgcat to display graphics -kitty % force using kitty to display graphics -iterm % force using iterm to display graphics -k % list keyboard shortcuts @@ -1401,6 +1406,9 @@ function extract_and_display_page() { "sixel") img2sixel -h $target_height -w $target_width -q full -b vt340color "$image" ;; + "imgcat") + $imgcat "$image" + ;; "iterm") tput cup 0 0 print_image_iterm "$image" 1 "$(base64 < "$image")" $width $(echo 'scale=0;'"$height" \* "$zoom" / 100 | bc -l) @@ -1515,6 +1523,10 @@ while [[ "$1" == '-'* ]]; do protocol="sixel" shift ;; + -imgcat|--imgcat) + protocol="imgcat" + shift + ;; -kitty|--kitty) protocol="kitty" shift