Revision as of 00:51, 25 February 2013

ranger is a text-based file manager written in Python with vi-style key bindings. It has an extensive set of features , and you can accomplish file management tasks with a few keystrokes with no need for the mouse.

Running

To start ranger, launch a terminal such as xterm, and type the command ranger. Or, you can use the command

xterm -e ranger

Comparison with other File Managers

Compared to graphical mouse-based file managers, ranger is much more efficient, but still visually appealing. ranger has one pane with multiple columns for different directories in the path, and file previews on the right. Compared to double-pane file managers, ranger shows more directory and file information. You can quickly move between directories using keystrokes, bookmarks or the command history. Previews of files and directory contents automatically show up for the current selection. ranger's features include: vi-style key bindings, bookmarks, selections, tagging, tabs, command history, the ability to make symbolic links, several console modes, and a task view. ranger has customizable commands and key bindings, including bindings to external scripts. The closest competitor is Vifm, which has two panes and vi-style key bindings, but has fewer features overall.

Documentation

ranger's man page can be opened by typing ?. You can also press 1? for a list of key bindings, 2? for a list of commands and 3? for a list of settings.

Customization

After startup, ranger creates a directory ~/.config/ranger/. You can copy the default configuration files to this directory with the following command:

ranger --copy-config=all

They can be then customized. Some basic knowledge of python is useful.

rc.conf controls startup commands and key bindings

commands.py controls the commands which are launched with the ":" key

rifle.conf controls the applications used when a given type of file is launched.

You can launch files with "l" (ell) or "<Enter>". You need only include changes from the default files, but be sure to include any necessary headers. Also, if you change part of a function, be sure to include the whole thing, since you're redefining that function.

Binding keys

Use the file ~/.config/ranger/rc.conf to modify key bindings. There are many keybindings already defined, and you can learn the syntax by reading the file.

The following example shows how to use "DD" to move selected files to a directory ~/.Trash/. Put this code in ~/.config/ranger/rc.conf

To use it, you would type ":empty<Enter>", using tab completion if desired.

Warning: Note that [^.] is an essential part of the above command. Otherwise, it will remove all files and directories of the form ..*, thereby wiping out everything in your home directory.

Automatically opening files with a given application

Modify ~/.config/ranger/rifle.conf. Since the beginning lines are executed first, you should put your modifications at the beginning of the file. For example, the following entry will open a tex file with kile.

est tex = kile

Useful commands

External Drives

External drives can be automatically mounted with an Udev rule or with the help of an automounting Udev wrapper. Drives mounted under /media can be easily accessed by pressing Template:Keypress (go, media).

Compression

The following command allows the user to compress several files on the current directory by marking them and then calling ":compress <package name>". It supports name suggestions by getting the basename of the current directory and appending several possibilities for the extension.

Image Mounting

The following command assumes you are using cdemu as your image mounter and some kind of system like autofs which mounts the virtual drive to a specified location ('/media/virtualrom' in this case). Don't forget to change mountpath to reflect your system settings.

To mount an image (or images) to a cdemud virtual drive from ranger you select the image files and then type ':mount' on the console. The mounting may actually take some time depending on your setup (in mine it may take as long as one minute) so the command uses a custom loader that waits until the mount directory is mounted and then opens it on the background in tab 9.