Ranger

From The World according to Vissie
Jump to navigation Jump to search

Installation

sudo apt-get install ranger caca-utils highlight atool w3m poppler-utils mediainfo

It's quite common to use

ranger --copy-config=all

to copy the default config files to ~/.config/ranger and modify them there. Be aware that for rc.conf and commands.py, ranger reads both the global and the user's config (in that order). It allows the user to maintain only a small config which sets only the things not set in the default one. For scope.sh and rifle.conf, ranger reads either the users or the global config.

atool for archives.
highlight for syntax highlighting.
libcaca (img2txt) for image previews in ASCII.
mediainfo or perl-image-exiftool for media file information.
poppler (pdftotext) for PDF.
transmission-cli for BitTorrent information.
w3m for image previews and html.

Keyboard shortcuts

Alt-number or Tab

Ranger allows you to create new tabs (like in a web browser) and switch between them. If you open just two tabs, ranger's tabs effectively behave just like mc's panels. And you can even open more if such need arises.

yy pp 

To copy a file, highlight it, press "yy" to mark it for copying (analogously to copying a line in vim with "yy"), then navigate to a target directory (or switch a tab if you decided to do it the "mc way") and then press "pp" to paste it (again, almost like in vim).

dd pp 

Moving a file differs very little from copying it: just use "dd" instead of "yy" at the beginning. To copy/move multiple files, just mark them with Space then use "dd/yy".

ya pp
da pp

If you want to operate on multiple files stored in different directories, you may use "ya/da" to add them to the list of files to be copied/moved before pasting them.

yr
yt

"yr" to remove files again, or "yt" for toggling

v

Use V to perform visual selection. Lowercase v reverses current selection. For instance, you can run :delete after selecting multiple files and folders.

i

To fullscreen a preview window, hit i. Hit i again to return the preview window to it’s normal size.

g

Vi’s gg and G allow you to jump to the top and bottom of the file list respectively. g gives you some nice jump to places. Try it.

zh

Hit zh to toggle hidden files display.

/

As in Vim, / searches for a file in a current buffer, while n and N let you navigate to the next and previous

:filter

Similarly, :filter allows you to only limit your view to the files matching a pattern. It’s also interactive - changes are applied as you type.

cd c (followed by d) will drop you to :cd space , easy way to cd.

f Even quicker...Quickly navigate by entering a part of the filename.

S

Open a shell in the current directory

pl pL

Create symlinks (absolute or relative) to the copied files

phl Create hardlinks to the copied files

oX Change the sort method (like in mutt)

Bookmarks

m Set a bookmark
` Jump to the set bookmark

Type m<key> to bookmark the current directory. You can re-enter this directory by typing `<key>. <key> can be any letter or digit. Unlike vim, both lowercase and uppercase bookmarks are persistent.

Each time you jump to a bookmark, the special bookmark at key ` will be set to the last directory. So typing "``" gets you back to where you were before.

Bookmarks are selectable when tabbing in the :cd command.

Note: The bookmarks ' (Apostrophe) and ` (Backtick) are the same.


= File tagging

By pressing "t" you may mark a file with an asterisk ("*"). It is persistent and will be there until you remove it manually. It may be used for example for marking the already read e-books, or files that need some action.

You can actually mark files with almost any other character besides the asterisk. Pressing a quotation mark (' " ') followed by any other character marks the file with that character.


Configuration files

Ranger uses 4 main configuration files:

commands.py contains various functions' implementation, written in Python, used to modify ranger's behavior,
rc.conf is used for setting various options and binding the keys to functions,
rifle.conf decides which program to use for opening which file,
scope.sh is a shell script used to generate the previews for various file types.

Change to directory

Add the following to your .bashrc or /etc/bash.bashrc

alias ranger='ranger --choosedir=$HOME/rangerdir;cd $(cat $HOME/rangerdir)'