W3m

From wikinotes

w3m is a terminal web browser. It supports displaying images, and has fairly customizable keybindings.

Documentation

man w3m https://manpages.debian.org/buster/w3m/w3m.1.en.html
github https://github.com/shinh/w3m

Locations

~/.w3m/config configuration
~/.w3m/keymap keys
~/.w3m/mailcap configure default programs
/usr/share/doc/w3m/ readmes, defaults, list of all available commands etc.

Configuration

keymaps

# ~/.w3m/keymap
# see /usr/share/doc/w3m/README.func
# for a list of all available functions

# Address Navigation
keymap H PREV
keymap L NEXT
keymap o GOTO
keymap C-D NEXT_PAGE
keymap C-U PREV_PAGE

# Tab Navigation
keymap C-T NEW_TAB
keymap C-W CLOSE_TAB
keymap C-n PREV_TAB
keymap C-p NEXT_TAB


# Line Navigation
keymap 0 LINE_BEGIN
keymap $ LINE_END
keymap M CENTER_H
keymap j UP
keymap k DOWN
keymap J MOVE_DOWN
keymap K MOVE_UP

#keymap : COMMAND
keymap : GOTO_LINE

#keymap f    LIST_MENU       # show all links
keymap  f    MOVE_LIST_MENU  # jump to links
keymap  M-t  TAB_MENU        # menu of tabs


# open in external browser
keymap O EXTERN

#keymap * MARK_WORD
#keymap M-n NEXT_MARK
#keymap M-p NEXT_MARK

keymap w NEXT_WORD
keymap b PREV_WORD

config

# ~/.w3m/config
editor vim

commands

w3m allows you to define your own 'dict' commands, assigning keywords to commands like search engines.
See README.dict.

Usage

w3m \
  -T text/html         # force mimetype
  -o confirm_qq=false  # do not confirm on quit
  FILE/URL

Troubleshooting

Flickering Images

Unresolved. It works in xterm/tty, I have not been able to make it work for st or alacritty. A reddit poster suggested it might be anti-aliasing.

w3mimgdisplay works by rendering the image overtop of the X11 window.
When the window redraws, a race condition occurs which may cause the image to disappear on some terminals
A user on alacritty's issue tracker proposed a workaround (delay image rendering).
works within ranger image display.

#!/bin/bash
{ 
  while read line; do 
    firstchar=${line:0:1}
    if [[ $firstchar = '0' ]]; then
      # Showing a picture - pause for a moment, in case the terminal has a pending redraw.
      sleep 0.1
    fi
    echo "$line"
  done; 
} | /usr/lib/w3m/w3mimgdisplay

https://github.com/alacritty/alacritty/issues/1021