Linux - Ranger

Ranger is a popular and powerful file manager in console.

Installation

In archlinux, ranger can be directly installed using pacman.

  pacman -S ranger

Configuration

Ranger can be customized by 4 configuration files below.

  • rc.conf organizes various options and keybindings.
  • commands.py defines commands, which can be provoked via :.
  • rifle.conf defines the default programs to open each type of files.
  • scope.sh is a shell script to preview each type of files.

In fact, there are both global and local versions for each configuration above. The local versions are stored in ~/.config/ranger. Optionally, the global version of the configuration files can be copied as follows to ~/.config/ranger as a starting point before further customization, i.e.,

  ranger --copy-config=rc/rifle/commands/scope/all

For rc.conf and commands, ranger subsequently loads the global version first and then the local version. By default, only the options different from the default values in the global version need to be overridden in the local counterpart. The loading of global version can be skipped by setting environment variable RANGER_LOAD_DEFAULT_RC to FALSE.

For scope.sh and rifle.conf, what is different, ranger loads either the local or the global version.

Usage

Macro

Following macros are defined to facilitate the commands in range console.

MacroDescription
%fThe highlighted file
%dPath of current directory
%pFull paths of the selected files
%sSelected files in the current directory
%tTagged files in the current directory
%cFull paths of the currently copied/cut files

Tag

A tag is a single character1 displayed to the left of a filename.

KeybindingDescription
tTag/untag on current file.
utRemove tags from the selected files.
"<character>Set <character> as a tag for a file.

Filter

Command :filter <regexp> can be used to filter files matching regular expression <regexp>. Particularly, :filter can clear and reset the filter.

:filter_stack is used to combine a series of filters with desired combinator, e.g., .& for AND combinator and .| for OR combinator.

KeybindingDescription
.Prefix for filter related operations
.cClear filter_statck.

Flatten

Command :flat <n> can flatten a nested directory tree within n levels. Particularly,

  • n=-1 means infinite levels, i.e., no limit.
  • n=0 disables the flat view.

TODO Rename

Keybinding

Ranger comes up with vim-like keybindings, e.g.,

KeybindingDescription
qClose the current tabaz2.
j/kMove down/up.
hEnter parent directory.
lEnter the selected directory.
iPreview the selected file.
gGo to
r:open_with
yYank/copy
yyCopy file(s).
ydCopy directory as text.
ynCopy file name as text.
ypCopy file path (with name) as text.
yaCopy and append file(s) to the clipboard buffer.
dCut/delete
ddCut file(s).
daCut and append file(s) to the clipboard.
pPaste
oSort/order
uUndo
m<key>Bookmark the current folder with key.
'<key>Access the folder bookmarked by key.
''Move back.
Alt-<n>Create or switch to tab n.
spaceMark the current file.
vInvert the selection.
VEnter a visual mode to mark a range of files.
:mark/unmark <regexp>Mark/unmark files matching regexp.
:mark/unmark_tag <tag>Mark/unmark files by tag.
tab/shift-tabSwitch to next/previous tab.
MLinemode
+/-/=Set access right to files
zChange the settings of ranger in the current session.
zhShow/hide hidden files.
ziToggle image preview.

Get help

KeybindingDescription
?Get help.
?mMan page for ranger.
?kList of keybindings.
?cList of commands.
?sList of options and their values.

Footnotes


1

The default tag is an asterisk (*).

2

Or even quit the ranger (if it is the last tab).

Table of Contents