Archive for April, 2012

Why Ranger File Manger Rocks

Sunday, April 1st, 2012

Ranger is a conole based file manager for LINUX with vim key bindings (like SPY or MC). You can get a copy directly from Ranger's webpage on, or you may find that it's already available in your linux distribution's software repository.

I don't plan on reviewing ranger, but I will mention a few things that are especially nice for fx artists and TD's.

Very breifly, this is how ranger is laid out. You have 3 columns. The left column represents the directory above the current working directory, the middle is the current dir, and the right column is a preview area based on your selection. If you've selected a folder, it's contents will be displayed on the right column. The whole idea is that you can traverse your file system by moving left or right. If you move "right" over a file, it opens using the default application you've configured in ranger's preferences.

Ranger's preview pane can only display text based content, but this is all we really need. (the column on the far right)

  • The first 100 lines of text based filetypes are displayed (scripts, xml, text, etc.) The amount of lines displayed is adjustable.
  • PDF's are converted to text using pdftotext and displayed
  • HTML is displayed as text using w3m, elinks or lynx
  • Archives have their contents listed using als.
  • Code can be syntax highlighted
  • Arbitrary files using arbitrary applications to output text (ascii).

In other words, you can see file contents, inside archives, and interesting metadata at lightning speed as you traverse your file system without having to actually interact with these files in any way.

Another cool part is the ability to make mimetypes for the filetypes you care about, and assign various applications to output useful ascii based information about them. Check out these examples.

ginfo's output for a BGEO file.
BGEO Output

iinfo's output for a PIC.
BGEO Output

hotl -V on an OTL
BGEO Output

I also associate the following file types with these applications, but you can use the output of any app you want. Even your own custom scripts.

  • *.bkm = brickinfo
  • *.ptx = ptxinfo
  • *.slo = sloinfo
  • *.obj = ginfo
  • *.dshad = txinfo
  • *.tex = txinfo
  • *.exr = exrinfo
  • *.tiff = tiffinfo
  • *.jpg | *.png = identify -verbose

To setup this type of usage scenario, you'll need to edit ~/.config/ranger/ and add an entry for your custom mimetypes (use the current examples as basis for your own). You may need to copy it from /usr/lib/python2.7/site-packages/ranger/data/ to this location first.

By default, uses 'file –mime-type -Lb filename' to identify mimes. Test this on your own files first to see if it works. I modified to use the output of 'mimetype -b filename' instead, as it worked better for my custom mimes.

How do you setup custom mimetypes? That's easy enough.

Add a mimetype entry to ~/.local/share/mime/packages/Overrides.xml (create the file if it doesn't exist)
It can be anything you want really, just follow the basic structure outlined here. image/extension for images. text/extension for ascii types, and application/extension for binary types, or types you don't really know. They look like this:

<mime-type type="image/x-pic">
<comment>Mantra PIC</comment>
<glob pattern="*.pic"/>

After you're finished, run 'update-mime-database ~/.local/share/mime/packages/' and then test the output of 'mimetype -b' or 'file –mime-type -Lb' to see if your custom type is returned.

On my gentoo box, update-mime-database is provided with the package 'shared-mime-info'.