As seen here: http://blog.z3bra.org/2014/01/images-in-terminal.html
Install packages w3m and some terminal emulator which supports images (urxvt, terminator, termite).
sudo pacman -S w3m terminator
which w3mimgdisplay
It should show something like (in Arch Linux)
$ which w3mimgdisplay
/usr/local/bin/w3mimgdisplay
Then it is alright. If the command doesn't output anything, you should search your system for w3mimgdisplay
binary and link it:
find / | grep w3mimgdisplay
And if you installed in previous step it will show it's full path. Then you link it:
ln -s /CHANGE/THIS/WITH/PATH/w3mimgdisplay /usr/bin
#!/bin/bash
#
# z3bra -- 2014-01-21
# http://blog.z3bra.org/2014/01/images-in-terminal.html
test -z "$1" && exit
W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay"
FILENAME=$1
FONTH=14 # Size of one terminal row
FONTW=8 # Size of one terminal column
COLUMNS=`tput cols`
LINES=`tput lines`
read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
max_width=$(($FONTW * $COLUMNS))
max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt
if test $width -gt $max_width; then
height=$(($height * $max_width / $width))
width=$max_width
fi
if test $height -gt $max_height; then
width=$(($width * $max_height / $height))
height=$max_height
fi
w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;"
tput cup $(($height/$FONTH)) 0
echo -e $w3m_command|$W3MIMGDISPLAY
chmod +x img.sh
Make sure you are using a terminal emulator which supports images (urxvt, terminator, termite), and run the script passing a image file as argument:
./img.sh my_image.png
EOF
It works! At least locally I managed doing it with rxvt-unicode in Ubuntu but I'm not being able to do it over ssh. Is there something I need to configure in SSH to make it work? (same terminal)
It's in Spanish but you get the idea. Unary operator expected. I get this same error in an incompatible console when trying the command locally (LXTerminal).