View Images in Mutt

My favorite email application is mutt. This is because of all the features mutt is offering. But since I receive regularly pictures via email and mutt can’t display them I was looking for an alternative. During the last weeks I found a way to display Pictures inside of mutt without the need of opening an extra window with the help of w3mimgdisplay, the picture-viewer of mutt.

Images in mutt

Set up to display images

First you need an w3m-Installation which is enabled to show pictures. All big distributions should offer one: “` aptitude install w3m-img ”’ Now you need an script that calls w3mimgdisplay.

1
2
3
4
5
6
7
8
#! /bin/sh

#### Determine size of Terminal
height=`stty  size | awk 'BEGIN {FS = " "} {print $1;}'`
width=`stty  size | awk 'BEGIN {FS = " "} {print $2;}'`

### Display Image / offset with mutt bar
echo -e "2;3;\n0;1;210;20;$((width*7-250));$((height*14-100));0;0;0;0;$1\n4;\n3;" |  /usr/local/libexec/w3m/w3mimgdisplay &

This script determines first the height and width of the running terminal. I’m using mutt with side-bar patch, so the script places the Image right of the bar.

After this you will need to add this script to your mailcap.

1
image/*; ~/bin/muttimage.sh %s ; copiousoutput