Terminal GuideTerminal Guide
lf icon

lf

File Managers
macOSLinuxWindows
Go

Lightweight and fast terminal file manager.

Official Website

Features

LightweightFastCustom CommandsPreview

Installation

Homebrew
brew install lf
Pacman (Arch)
pacman -S lf

Why use lf?

Lightweight & Fast

Single binary written in Go. Works without dependencies, starts very quickly, uses minimal memory.

Highly Customizable

Simple config file allows full customization of keybindings, commands, and preview methods.

Shell Integration

Execute shell commands directly. Supports pipes and redirects, combine with existing tools.

Cross-Platform

Supports Linux, macOS, and Windows. Use the same config file in any environment.

Installation

Installation Commands
# Homebrew (macOS/Linux)
brew install lf

# Pacman (Arch Linux)
sudo pacman -S lf

# Install directly with Go
go install github.com/gokcehan/lf@latest

# Download binary directly
# https://github.com/gokcehan/lf/releases

Screen Layout

lf uses a simple two-pane (or custom ratio) layout. File list on the left, preview on the right.

┌─ lf ────────────────────────────────────────────────────────┐
│  ~/.config/lf                                               │
│                                                             │
│   ..                                                       │
│   colors                                                   │
│   icons                                                    │
│ > lfrc                    # lf config file                │
│   preview.sh              # Preview script                │
│                                                             │
│                           set hidden true                   │
│                           set icons true                    │
│                           set preview true                  │
│                           ...                               │
│                                                             │
├─────────────────────────────────────────────────────────────┤
│ 5 items | ~/.config/lf                                      │
└─────────────────────────────────────────────────────────────┘

Basic Operations

KeyAction
hGo to parent directory
j / kMove up/down
l / EnterEnter directory / Open file
gg / GGo to start / end
/Search
:Command mode
$Execute shell command
qQuit

File Operations

KeyAction
SpaceSelect/deselect file
vInvert selection
yCopy
dCut
pPaste
cClear selection
rRename
DDelete (requires configuration)

Configuration & Customization

Configure lf using ~/.config/lf/lfrc. Simple syntax for defining keybindings and custom commands.

~/.config/lf/lfrc
# ~/.config/lf/lfrc

# Basic settings
set hidden true          # Show hidden files
set icons true           # Show icons
set ignorecase true      # Ignore case in search
set preview true         # Enable preview
set ratios 1:2:3         # Pane ratios

# Shell settings
set shell bash
set shellopts '-eu'
set ifs "\n"

# Custom commands
cmd open ${{
    case $(file --mime-type "$f" -bL) in
        text/*|application/json) $EDITOR "$f";;
        image/*) sxiv "$f";;
        video/*) mpv "$f";;
        application/pdf) zathura "$f";;
        *) xdg-open "$f" ;;
    esac
}}

# Create directory
cmd mkdir %{{
    printf "Directory Name: "
    read ans
    mkdir -p "$ans"
}}

# Create file
cmd touch %{{
    printf "File Name: "
    read ans
    touch "$ans"
}}

# Move to trash
cmd trash %{{
    files=$(printf "$fx" | tr '\n' ';')
    while [ "$files" ]; do
        file=${files%%;*}
        trash-put "$(basename "$file")"
        if [ "$files" = "$file" ]; then
            files=''
        else
            files="${files#*;}"
        fi
    done
}}

Keybinding Configuration

~/.config/lf/lfrc
# ~/.config/lf/lfrc (Keybinding configuration)

# Basic operations
map <enter> open
map o open
map e $$EDITOR "$f"

# File operations
map D delete
map T trash
map a push :touch<space>
map A push :mkdir<space>

# Navigation
map gh cd ~
map gd cd ~/Documents
map gD cd ~/Downloads
map gc cd ~/.config
map gr cd /

# Selection
map <space> toggle
map u unselect
map U clear

# Copy & Move
map y copy
map d cut
map p paste

# Search
map / search
map n search-next
map N search-prev

# Display toggle
map zh set hidden!
map zr set reverse!
map zn set info
map zs set info size

Preview Functionality

lf preview is fully customizable with shell scripts. Below is an example of a common preview script.

~/.config/lf/preview.sh
#!/bin/bash
# ~/.config/lf/preview.sh

case "$1" in
    *.tar*) tar tf "$1";;
    *.zip) unzip -l "$1";;
    *.rar) unrar l "$1";;
    *.7z) 7z l "$1";;
    *.pdf) pdftotext "$1" -;;
    *.jpg|*.jpeg|*.png|*.gif)
        chafa -f sixel -s "${2}x${3}" "$1" 2>/dev/null ||
        chafa "$1" -s "${2}x${3}"
        ;;
    *) bat --color=always --style=plain "$1" 2>/dev/null ||
       cat "$1";;
esac

Make the preview script executable: chmod +x ~/.config/lf/preview.sh

Icon Settings

Install a Nerd Font to display icons based on file types.

~/.config/lf/icons
# ~/.config/lf/icons

# Directory
di
# File
fi
# Link
ln
# Executable
ex
# Images
*.jpg
*.jpeg
*.png
*.gif
# Documents
*.pdf
*.doc
*.txt
# Code
*.js
*.ts
*.py
*.go
*.rs
# Archives
*.zip
*.tar
*.gz

Tips

Shell Integration

To preserve current directory when exiting, add this function to your shell:lfcd() { cd "$(command lf -print-last-dir "$@")" }

fzf Integration

Launch a shell with $ and use fzf for search. You can also implement fzf jump with custom commands.

Image Preview

Image preview is available with chafa, ueberzug,kitty icat and others.

Server Mode

Start server mode with lf -serverto share copy/paste state between multiple clients.

Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More