Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
============

Expand All @@ -190,6 +200,7 @@ $ termpdf -h
termpdf <options> <file/directory>
-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
Expand Down Expand Up @@ -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
------------------
Expand Down
Binary file added screenshot_tty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion termpdf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
###########################################################################
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -864,6 +868,7 @@ function clihelp() {
$(basename $0) <options> <file/directory>
-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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1515,6 +1523,10 @@ while [[ "$1" == '-'* ]]; do
protocol="sixel"
shift
;;
-imgcat|--imgcat)
protocol="imgcat"
shift
;;
-kitty|--kitty)
protocol="kitty"
shift
Expand Down