Ranger is a popular file manager that allows you to easily navigate and manage your files from your terminal with an intuitive and user-friendly interface.
With its intuitive interface, Ranger can effectively replace your GUI file manager as it can also be operated using a mouse. However, for the most efficient navigation through Ranger, it’s recommended to use a keyboard.
Adding an image preview to Ranger can significantly enhance your experience when dealing with image files. It allows you to quickly view the selected picture in the preview window directly inside the terminal.
In this article, you will learn how to enable image preview on Ranger file manager, making your experience with Ranger much more seamless.
Why You Should Enable Image Preview
By default, image preview is disabled in the Ranger file manager. I have compelling reasons why you should consider enabling it.
First and foremost, enabling image preview will significantly speed up your workflow when working with images, allowing you to quickly assess the contents of image files.
Furthermore, you can preview a wide range of image formats, including JPG, PNG, WEBP, and even SVG files. This is especially convenient when working with multiple image formats.
Additionally, the Ranger file manager supports the preview of video files, which can greatly facilitate your work with such files. However, it does require additional configuration, which we will cover in a later part of this article.
Enable Image Preview on Ranger
Okay, let’s get started on enabling image previews in the Ranger file manager to enhance your workflow when navigating through various image files.
But before that, there are some requirements that you need to do. You will need to install the necessary dependency that will be needed in order to display images inside the terminal window.
Requirements
In order to be able to display preview images in the terminal window, you need to install some necessary packages on your Linux system. These packages are:
These packages are:
- w3m
- w3m-img
You can install them easily with just a single line of command:
On Ubuntu, you can install them by using the apt package manager:
sudo apt install w3m w3m-img
On Arch Linux or Manjaro, you can use the pacman package manager:
sudo pacman -S w3m
And on Fedora, you can use dnf package manager:
sudo dnf install w3m w3m-img
Once the packages are installed, you are ready to proceed to the next section where you will finally configure the ranger to display the image preview.
Configuration
First, you need to obtain the rc.conf
file in order to configure Ranger to display image preview. You can do this easily by running this simple command:
ranger --copy-config=rc
This command will copy the default rc.conf
file into the ~/.config/ranger/
directory.
Now that you already have the rc.conf
file, you open it using the nano or vim text editor.
nano ~/.config/ranger/rc.conf
inside the rc.conf
file, search for the line that contains set images_preview
.
With nano, you can use the search function by pressing CTRL + W
By default, the preview_images
is set to false
. To enable image previews in Ranger, change the value of preview_images
to true
.
Once you’ve made this change, save the rc.conf
file by pressing CTRL + O and exit from nano by pressing CTRL + X.
Testing the Image Preview
Now it’s time to test whether the image preview feature in the Ranger file manager works as expected. If you followed the previous steps correctly, the image preview should function as intended. However, if there were any incorrect steps along the way, you may encounter issues.
Allright, to test the functionality of image preview, you can simply navigate to a folder that contains any images. Then scroll through those image files.
If the image preview is working properly, it should display the selected image in the preview section.
As mentioned earlier, Ranger can display image previews for various image formats, so feel free to explore different image files to confirm its functionality.
Enable Video Preview on Ranger
Ranger not only allows you to preview images but also supports previewing video files. Although it provides a still image preview, it can be quite useful for quickly assessing videos before opening them.
I highly recommend enabling video preview in Ranger, especially if you work with various types of files, including videos.
Requirements
To enable video preview in Ranger, you’ll need to install some dependencies, including:
To install all of them, simply run the command below depending on your Linux distribution:
On Ubuntu:
sudo apt install w3m ffmpeg ffmpegthumbnailer
On Manjaro or Arch Linux:
sudo pacman -S w3m ffmpeg ffmpegthumbnailer
On Fedora:
sudo dnf install w3m ffmpeg ffmpegthumbnailer
Configuration
Before proceeding, ensure that you have already enabled the image preview option. If you haven’t done so yet, please refer to the previous section on enabling image previews in Ranger.
Next, copy the default rc.conf
and scope.sh
files by running the following command:
ranger --copy-config=rc,scope
This command will copy the default rc.conf
and scope.sh
files into the ~/.config/ranger/
directory. If these files already exist, the command won’t overwrite them.
Once you have the configuration files, open the scope.sh
file using the nano text editor:
nano ~/.config/ranger/scope.sh
Inside the scope.sh
file, search for the line that contains ## Video
Use the Nano search function by pressing CTRL + W
Uncomment the lines by removing the hash (#) characters as shown in the image above.
After uncommenting them, save the scope.sh
file by pressing CTRL + O and exit the nano editor by pressing CTRL + X.
Testing the Video Preview
If you have followed the configuration steps correctly, the video preview should function smoothly. However, if there were any mistakes in the configuration process, you may encounter issues.
To test if the video preview works as you expected, simply just open ranger file manager and navigate to any video files on your computer. When you highlight the video files, it should display the video preview on the right side.
And that’s it! Now you can easily navigate through your video files and quickly preview their content before opening them.
Conclusion
To wrap up, enabling image previews in the Ranger file manager is essential if you frequently work with image files. With this option enabled, your ability to navigate through image files becomes much more efficient and user-friendly.
Having the convenience of quick image previews while navigating through image files can save you valuable time. It’s a feature that can truly enhance your workflow.
If you encounter any difficulties or have questions while following this tutorial, please don’t hesitate to reach out and leave a comment below. I’m here to provide assistance and address any concerns you may have.