Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to preview images in Ranger

📅 2014-Sep-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ image, preview, ranger, w3m ⬩ 📚 Archive

Ranger is a great console tool to explore directories and files. You can find the instructions to install and configure it in this post. As you explore files in the center column, Ranger displays a preview of the file contents in the right column. If the file is an image, then Ranger displays a color ASCII version of the image using the Caca library.

However, if you use XTerm or a terminal with similar capabilities, Ranger can show an actual image preview with full color and pixels! Remember that this works only on XTerm or similar terminals.

To preview images like this, Ranger requires the w3mimgdisplay program. You can get it by installing:

$ sudo apt install w3m-img

After this, you need to set the preview_images option to true in the .config/ranger/rc.conf file. You will have this file only if you followed the instructions given above during Ranger installation.

Once you have done this, open an XTerm and enjoy full-color image previews! Note that this did not work in RXVT for me.

Tried with: W3m-Img 0.5.3-15, Ranger 1.6.0 and Ubuntu 14.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧