Ranger file manager


Ranger is a CLI filemanager written in Python. Personally I use this program as my only file manager except for conventional Linux CLI. The program starts quickly and can be run over SSH.

It's available in Pypi and can be installed with pip3:

pip install ranger-fm

Github: ranger/ranger.

Homepage: https://ranger.github.io.

Screenshot

After installing the program, start it in the current directory by running ranger.

It follows the VIM-style of shortcuts with hjkl. These keys are used for navigation in the file system. Quit the program with q.

Keep in mind that ranger distinguishes between capital key presses and non-capital ones.

Navigate by find

To quickly open a file / directory in ranger press f and type the name of the file until it's opened. When you've typed out enough of the filename / directory to select it, it'll open.

While in the find mode, press <tab> to select between matching files / directories. Then you can press <enter> to open the selected entry.

Tabs

Use ALT-<number>. Will create a new tab in the current directory.

When you switch to a new tab, it'll be created.

If you have many tabs open, the key q will be used to close the current tab.

Copy / paste

Similar to vims line-copy and line-paste. Select a file for copy with yy and copy it to the selected directory with pp.

For cut / move operations use dd.

To to an actual remove operation run dD.

Select many files

Use <space>to select a file.

v inverts current selection (If no files are selected, the inverse selects all files). V executes a kind of visual mode like in Vim. Navigate up and down to select multiple files. Press V again to turn it off.

Deselect everything with uv.

Copy / Cut / Paste works with multiple files selected. Most operations work on multiple files.

Order files

Press o for a variety of ways to order the files.

Unlike vim, ranger is more useful when it comes to commands which are based on multiple keys. After pressing the first key of a command sequence, ranger will show a pop-up dialog with all available continuing keys.

Calculate size of directory

Run dc to collect the total size of a directory.

Follow this up with a os to order by file / directory sizes.

Bulk rename

Like vim, run commands by pressing :.

The command :bulkrename opens up an external text editor for renaming all selected files. Then after editing the file and closing the editor, ranger performs a rename operation based on what you put into the external editor.

Run commands

There are a few ways to run shell commands in ranger. The easiest is to press s. It just provides a prompt for running a shell command. When the command is done, ranger pops back up again.

To see what is printed on stdout / stderr from the program run the command by pressing # instead. After the command is done the output is display in less.

Command macros

Commands have access to macros which contain information about the current file selection:

Macros

The tab-wise scope of the macros can be selected with a number specified. Read the included manual for more about that.

Filter

Press zf to input a filter. Files that does not have the filter string in the name, will be hidden from view.

To remove the filter again, specify a empty string as filter.

Go to

There are default shortcuts to common file system paths. Press g to get the list of predefined shortcuts.

Go to bookmark

You can add your own bookmarks, they'll be in their own list. Go to a directory and press m, now press a key. This shortcut can now be accessed by pressing ' and the assigned key.

This is similar to how vim does bookmarks.

Tags

You can select files on a global scope across the file system. To mark a file with a tag press either t to mark it with the default tag (*) or press " followed by a custom key.

Unlike the selection previously mentioned, tags are not limited to the active working directory.

What's the point of tags?

You can ranger with the argument --list-tagged="X", where x is the tag you want to focus on. This command prints the path of all files selected with the specified tag.

It's useful for piping into other commands. For example:

ranger --list-tagged="*" | xargs tar cfz my_files.tar.gz

This command copies all tagged file into a compressed tar ball.

FYI: the tags are stored in the file ~/.local/share/ranger/tagged.

Image preview

This only works if the terminal emulator you are using can display bitmap graphics.

Follow the guide in the ranger wiki.

Other links:

Flat directories mode

Normally you enter or select a directory to see the content of it.

To get an expanded view of the content of all sub directories in the current working directory. Use the command :flat 1.

1 means one level of sub directories. Put any number of sub directories you want to expand. -1 expand all levels.