Terminal-based directory navigation using standard cd, ls, and cp commands can become cumbersome when managing complex multi-tiered codebases or sorting through dense directories of assets. While traditional graphical file managers introduce heavy desktop dependencies, terminal file managers provide high-speed keyboard-driven navigation. Inspired by the classic Python-based ranger utility, lf (List Files) is a lightweight terminal file manager written in Go. It delivers instantaneous startup times, minimal memory consumption, asynchronous file operations, and deep shell script customisation.
Why Choose lf Over Other Terminal File Managers
Unlike Python or Ruby alternatives that can introduce perceptible rendering lag on large directories containing tens of thousands of files, lf compiles into a single static binary. Key architectural highlights include:
- Sub-Millisecond Startup: Zero runtime dependency overhead allows
lfto launch instantaneously over low-bandwidth SSH sessions. - Vim-Style Modal Keybindings: Default navigation follows universal
h/j/k/ldirectional controls. - Client-Server IPC Architecture: Multiple
lfwindows share a single background daemon, synchronising clipboard selections across separate terminal panes and tmux sessions. - Extensible Previews: Integrates cleanly with external syntax highlighters (such as
bat) and image renderers (such aschafa).
Installing lf on Linux Distributions
You can install lf across all modern distributions using system package managers, pre-compiled release tarballs, or Go:
# Debian / Ubuntu (via official binary releases)
curl -fsSL https://github.com/gokcehan/lf/releases/latest/download/lf-linux-amd64.tar.gz | tar -xz
sudo mv lf /usr/local/bin/
# Arch Linux / Manjaro
sudo pacman -S lf
# Fedora / RHEL
sudo dnf copr enable pennbauman/ports
sudo dnf install -y lf
# Install using Go toolchain
go install github.com/gokcehan/lf@latest
Verify that your shell detects the binary:
lf -version
Core Navigation and Essential Keybindings
Launch the manager by typing lf in your terminal. The interface presents a three-column Miller columns layout: parent directory on the left, active directory in the middle, and file preview on the right.
# Basic Vim-Style Navigation
k / Up Arrow : Move cursor up
j / Down Arrow : Move cursor down
h / Left Arrow : Ascend to parent directory
l / Right Arrow : Enter selected directory or open file
gg : Jump to top of directory listing
G : Jump to bottom of directory listing
Standard file operations mirror Unix command semantics:
# File Manipulation Shortcuts
space : Select/tag multiple files
y : Yank (copy) selected files to clipboard
d : Cut (delete/move) selected files to clipboard
p : Paste yanked/cut files into current directory
r : Open rename prompt for selected file
delete : Delete file permanently (or moves to trash if configured)
/ : Search/filter files in current directory
Configuring Custom Previews and Syntax Highlighting
By default, lf provides plain text previews. You can configure rich syntax highlighting and media inspection by creating an lfrc configuration file:
# Create configuration directory and file
mkdir -p ~/.config/lf
nano ~/.config/lf/lfrc
Add the following basic options to customize interface behaviour:
# ~/.config/lf/lfrc
# Display hidden files by default
set hidden true
# Enable mouse scrolling support
set mouse true
# Show file sizes and modification times
set info size:time
# Set custom file previewer script
set previewer ~/.config/lf/preview.sh
Create the preview script (~/.config/lf/preview.sh) to pipe content through bat, tar, or unzip:
#!/bin/sh
case "$1" in
*.tar*) tar -tf "$1" ;;
*.zip) unzip -l "$1" ;;
*.pdf) pdftotext "$1" - | head -n 100 ;;
*) bat --color=always --style=plain "$1" || cat "$1" ;;
esac
Make the preview script executable:
chmod +x ~/.config/lf/preview.sh
Configuring Shell Integration to Change Working Directory
Normally, when you exit lf, your shell remains in the directory where you initially launched it. To make your shell automatically cd into the directory selected when quitting lf, add this wrapper function to your ~/.bashrc or ~/.zshrc:
# Shell wrapper function for lf
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
if [ -d "$dir" ] && [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
}
alias lf="lfcd"
lf Command and Shortcut Reference
The table below provides a quick reference for common commands in daily workflows:
| Shortcut / Key | Action | Context Scope |
|---|---|---|
: |
Opens command mode (e.g. :mkdir folder) |
Interactive prompt |
$ |
Executes shell command and pauses for keypress | External shell |
! |
Executes shell command in background | Asynchronous |
zh |
Toggles display of hidden files (dotfiles) | Active pane |
q |
Exits lf | Session close |
Incorporating lf into your terminal toolchain provides instantaneous filesystem manipulation while maintaining seamless synergy with command-line pipes and shell scripting.