8

I have installed ranger file manager and rxvt-unicode terminal, and I want ranger to display previews of images in the terminal. I have also installed w3m, but I can't get images to preview. I think this is an issue for w3m, because when I load webpages with w3m, no images appear.

edit: w3m will now display images when i load webpages and images, but ranger does not preview....

I am running Ubuntu 18.04.4 LTS x86_64 I think I need to get urxvt with pixbuf support, but I have no idea how to get that. I have tried searching to find out how to get urxvt with pixbuf support, but only results for arch etc. is available it seem like.

2
  • What version Ubuntu is this?
    – heynnema
    Mar 31, 2020 at 19:42
  • I am running 18.04 (Ubuntu 18.04.4 LTS x86_64)
    – fdfdsd
    Apr 1, 2020 at 18:22

3 Answers 3

12

TL;DR

  1. On the default Ubuntu terminal I installed ueberzug with: pip3 install ueberzug
  2. On rangers configurations at ~/.config/ranger/rc.conf I added( or edited already existing) these two lines :
set preview_images true
set preview_images_method  ueberzug 
  1. Worked like a charm(and it will work on any other terminal as well)

My other trials

I just had the same experience as you and I couldn't make it work but I have a few notes on your trial and a pretty easy alternative that actually worked

First thing first w3m package of ubuntu doesn't contain image preview so you need to explicitly type sudo apt install w3m-img then you need to locate it on the path at a place like /usr/lib/w3m/w3mimagedisplay and add it to your path .Though this installation of w3mimagedisplay seems broken to me you might have better luck.Also kitty as suggested by the other answer worked for me , though I didn't have time to change my default terminal as I have a lot of configurations on it. So I count these solution more "lightweight" as it just needs one python script to run. Even though kitty is a handy terminal and many people might prefer it.

Update 1 December 2022

This solution is not suggested anymore as it is quite difficult to install ueberzug now that the project is not under active development.

But..

If one insists on using this method you can build ueberzug manually with:

sudo apt install libxext-dev libx11-dev -y
git clone --depth 1 --branch 18.1.9 https://github.com/seebye/ueberzug.git
cd ueberzug
python3 setup.py install
5
  • 1
    first part worked like a charm in manjaro xfce with xfce4-terminal.
    – alexzander
    May 17, 2021 at 19:33
  • The ueberzug project has been archived by the developer. pip3 install ueberzug doesn't work anymore. github.com/seebye/ueberzug
    – Guillaume
    Nov 30, 2022 at 14:10
  • @Guillaume As I have the most liked answer now I feel like I have to find another easy solution, I'll come back Dec 1, 2022 at 11:12
  • 1
    I had to sudo apt install libxext-dev libx11-dev -y for this to install properly on Ubuntu 20.04.
    – Dave
    Dec 19, 2022 at 1:12
  • @Dave I will add those to my answer, and I will wait for other people to report missing dependencies Dec 22, 2022 at 15:23
10

Ranger does not have image previewing enabled by default. You need to enable it in its configuration file.

First, in case you do not already have a user-specific config file, create one by copying the default config file:

mkdir -pv ~/.config/ranger/
cp -vi /usr/share/doc/ranger/config/rc.conf ~/.config/ranger/rc.conf

Then open ~/.config/ranger/rc.conf using your favorite text editor.

To enable image previews, find the preview_images option and change it to true. i.e. the line would read:

set preview_images true

Then, find the option preview_images_method, and set it according to your terminal to one of the values enumerated and explained in the comment block preceding it. In your case, it's urxvt. So the line should read:

set preview_images_method urxvt

After that, quit ranger and start it again for the new configuration to take effect.

If all fails, I personally use it with the Kitty terminal and it works. If you want to try it out, first install Kitty, change the aforementioned preview_images_method option to kitty, then launch kitty and start ranger in it.

1
  • 2
    Adding this part, 'set preview_images_method urxvt' fixed an issue for me where a black line would be drawn through the image when changing focus to a new screen (using Awesome WM on my setup). Thanks! :)
    – jbrock
    Sep 9, 2021 at 17:09
0

I have Ubuntu 22.04 and I managed to use image preview with ranger and foot terminal.

First I installed sixel:

sudo apt install libsixel-bin libsixel-dev libsixel1

Sixel requires a recent ranger, so I removed the package and I downloaded and installed the latest from source:

sudo apt remove ranger
git clone https://github.com/ranger/ranger.git
cd ranger
sudo make install

If you have not already done, copy the default ranger config:

mkdir -pv ~/.config/ranger/
cp -vni /usr/local/share/doc/ranger/config/rc.conf ~/.config/ranger/rc.conf

I enabled image preview as some other answers correctly stated in ~/.config/ranger/rc.conf:

set preview_images true

Then I configured it to preview with sixel

set preview_images_method sixel

Now start ranger and it will correctly render image previews.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .