Image preview doesn't work in ranger

w3m
10,891

Solution 1

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

Solution 2

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

First, ensure that you do have a user-specific config file (~/.config/ranger/rc.conf). If you don't, create the config directory (by running mkdir -p ~/.config/ranger/) and copy the default one into it (by running cp /usr/share/doc/ranger/config/rc.conf ~/.config/ranger/), then open it (the user-specific one, that is) with 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 would 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.

Share:
10,891

Related videos on Youtube

fdfdsd
Author by

fdfdsd

Updated on September 18, 2022

Comments

  • fdfdsd
    fdfdsd almost 2 years

    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.

    • Boris Hamanov
      Boris Hamanov about 4 years
      What version Ubuntu is this?
    • fdfdsd
      fdfdsd about 4 years
      I am running 18.04 (Ubuntu 18.04.4 LTS x86_64)
  • alexzander
    alexzander about 3 years
    first part worked like a charm in manjaro xfce with xfce4-terminal.
  • jbrock
    jbrock almost 3 years
    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! :)