Overview
Ranger is a console-based file manager with vim-style keybindings. It provides a three-column view where the left column shows the parent directory, the middle column is the current directory, and the right column shows a preview of the selected file or subdirectory. Ranger aims to be visually pleasing and efficient, making file navigation fast without leaving the terminal.
Ranger is written in Python and supports file previews for text, images (in compatible terminals), PDFs, archives, and more through external tools. It features tabs, bookmarks, tagging, custom commands, and extensive configuration through Python-based config files.
Installation
# Ubuntu/Debian
sudo apt install ranger
# Fedora
sudo dnf install ranger
# Arch Linux
sudo pacman -S ranger
# macOS via Homebrew
brew install ranger
# pip (any platform)
pip install ranger-fm
# Install optional preview dependencies
sudo apt install w3m-img highlight atool mediainfo poppler-utils
Preview Dependencies
| Tool | Purpose |
|---|
w3m-img / ueberzug | Image previews in terminal |
highlight / bat | Syntax-highlighted text preview |
atool | Archive content listing |
pdftotext (poppler) | PDF text preview |
mediainfo | Audio/video metadata |
ffmpegthumbnailer | Video thumbnail previews |
First-Time Setup
# Generate default config files
ranger --copy-config=all
# Creates:
# ~/.config/ranger/rc.conf - Keybindings and settings
# ~/.config/ranger/rifle.conf - File opener rules
# ~/.config/ranger/scope.sh - File preview script
# ~/.config/ranger/commands.py - Custom commands
Navigation
| Key | Action |
|---|
h | Move to parent directory |
j | Move down |
k | Move up |
l | Open file/enter directory |
gg | Go to top of list |
G | Go to bottom of list |
H | Go back in history |
L | Go forward in history |
~ | Go to home directory |
gh | Go to home directory |
gd | Go to /dev |
ge | Go to /etc |
gm | Go to /media |
gM | Go to /mnt |
gt | Go to /tmp |
gu | Go to /usr |
gv | Go to /var |
gR | Go to ranger config dir |
File Operations
Selection
| Key | Action |
|---|
Space | Toggle selection on current file |
v | Invert selection |
V | Enter visual (select) mode |
uv | Clear all selections |
Cut, Copy, Paste
| Key | Action |
|---|
yy | Copy (yank) selected files |
dd | Cut selected files |
pp | Paste files |
po | Paste with overwrite |
pl | Create symlinks to copied files |
pL | Create relative symlinks |
ud | Clear cut buffer |
uy | Clear copy buffer |
File Management
| Key | Action |
|---|
:touch filename | Create new file |
:mkdir dirname | Create new directory |
:rename newname | Rename selected file |
cw | Rename (opens rename prompt) |
a | Rename - append before extension |
A | Rename - append at end |
I | Rename - insert at beginning |
:delete | Delete selected files (confirms) |
dD | Delete selected files (confirms) |
Bulk Rename
# Select files then run:
:bulkrename
# Opens filenames in $EDITOR, edit and save to apply
Search and Filter
| Key | Action |
|---|
/ | Search for file by name |
n | Next search result |
N | Previous search result |
f | Quick filter/find |
zf | Toggle filter (regex) |
:filter pattern | Filter files by regex |
:filter_inode_type d | Show only directories |
:filter_inode_type f | Show only files |
Tabs
| Key | Action |
|---|
Ctrl+N | Open new tab |
Ctrl+W | Close current tab |
Tab | Next tab |
Shift+Tab | Previous tab |
Alt+1-Alt+9 | Go to tab N |
Bookmarks
| Key | Action |
|---|
m<key> | Set bookmark to current directory |
'<key> | Go to bookmark |
um<key> | Delete bookmark |
Sorting
| Key | Action |
|---|
or | Sort by natural order (default) |
os | Sort by size |
ot | Sort by file type |
oa | Sort by access time |
oc | Sort by change time |
om | Sort by modification time |
on | Sort by name |
oe | Sort by extension |
Display Options
| Key | Action |
|---|
zh | Toggle hidden files |
zp | Toggle previews |
zP | Toggle directory previews |
zi | Toggle image previews |
S | Open shell in current directory |
W | View task manager |
Configuration (rc.conf)
# ~/.config/ranger/rc.conf
# Show hidden files
set show_hidden true
# Preview settings
set preview_files true
set preview_directories true
set preview_images true
set preview_images_method ueberzug
# Column ratios (parent:current:preview)
set column_ratios 1,3,4
# Appearance
set draw_borders both
set unicode_ellipsis true
set confirm_on_delete multiple
# VCS integration (git, hg, svn)
set vcs_aware true
set vcs_backend_git enabled
# Mouse support
set mouse_enabled true
# Sorting
set sort natural
set sort_case_insensitive true
set sort_directories_first true
# Custom keybindings
map <C-f> fzf_select
map X shell -f extract %f
map Z shell tar -czf %f.tar.gz %s
map mkd console mkdir%space
map crf console touch%space
# Bookmarks
map gD cd ~/Downloads
map gP cd ~/Projects
File Opener Configuration (rifle.conf)
# Text files
mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@"
# Images
mime ^image, has feh = feh -- "$@"
mime ^image, has sxiv = sxiv -- "$@"
# Video/Audio
mime ^video, has mpv = mpv -- "$@"
mime ^audio, has mpv = mpv -- "$@"
# Documents
ext pdf, has zathura = zathura -- "$@"
ext docx?, has libreoffice = libreoffice -- "$@"
# Archives
ext tar|gz|bz2|xz|zip|rar|7z, has atool = atool -x -- "$@"
Custom Commands (commands.py)
from ranger.api.commands import Command
import os
class fzf_select(Command):
def execute(self):
import subprocess
fzf = self.fm.execute_command(
"find . -type f 2>/dev/null | fzf",
stdout=subprocess.PIPE
)
stdout, _ = fzf.communicate()
if fzf.returncode == 0:
selected = os.path.abspath(stdout.decode('utf-8').strip())
if os.path.isdir(selected):
self.fm.cd(selected)
else:
self.fm.select_file(selected)
Shell Commands
| Prefix | Behavior |
|---|
!command | Run command and wait for input |
@command | Run command in background |
#command | Run command and page output |
s / S | Open shell in current directory |
Macros
| Macro | Meaning |
|---|
%f | Current file |
%d | Current directory |
%s | Selected files |
%t | Tagged files |
Troubleshooting
| Issue | Solution |
|---|
| No image previews | Install ueberzug or w3m-img; set preview_images_method |
| Slow startup | Reduce scope.sh complexity; disable VCS |
| No syntax highlighting | Install highlight or bat |
| Colors look wrong | Check terminal color support; set TERM=xterm-256color |
| Cannot delete files | Check file permissions |
| Custom commands not loading | Check commands.py syntax; restart ranger |
| Key mappings not working | Check for conflicts in rc.conf |
| Previews not updating | Press zp to toggle; check scope.sh permissions |