コンテンツにスキップ

nnn Cheat Sheet

Overview

nnn (n-cubed) is a full-featured, blazing fast terminal file manager written in C with an extremely small footprint. It uses less than 3.5MB of resident memory and starts up instantly. nnn provides a clean, keyboard-driven interface for file navigation, search, bulk operations, and integrates with the system clipboard, desktop opener, and a rich plugin ecosystem.

nnn supports sessions, bookmarks, contexts (virtual workspaces), disk usage analysis, batch renaming, and extensive type-based file filtering. It follows the Unix philosophy, delegating operations to external tools when appropriate, and can be extended with shell-based plugins for everything from file preview to cloud sync.

Installation

# macOS
brew install nnn

# Ubuntu/Debian
sudo apt install nnn

# Arch Linux
sudo pacman -S nnn

# Fedora
sudo dnf install nnn

# FreeBSD
pkg install nnn

# From source
git clone https://github.com/jarun/nnn.git
cd nnn && make O_NERD=1
sudo make install

# Verify
nnn -V

Core Navigation

KeyAction
h or LeftParent directory
l or Right or EnterOpen file/enter directory
j or DownNext entry
k or UpPrevious entry
Home or gFirst entry
End or GLast entry
~Go to home directory
-Go to last visited directory
@Go to start directory
.Toggle hidden files
qQuit
QQuit and cd to current dir

File Operations

KeyAction
SpaceSelect/deselect entry
aSelect all
AInvert selection
pCopy selected to current dir
vMove selected to current dir
xDelete selected
XDelete current entry
eEdit file in $EDITOR
nCreate new file/directory
rRename entry
Ctrl+RRename using $EDITOR
yCopy file path(s)
YCopy entry name
dToggle detail mode
DShow disk usage

Contexts (Virtual Workspaces)

KeyAction
1-4Switch to context 1-4
TabNext context
Shift+TabPrevious context
# nnn supports 4 contexts (like virtual desktops)
# Each context remembers its own directory and selections
# Switch with keys 1-4

Search and Filter

KeyAction
/Filter entries (as you type)
EscapeClear filter
Ctrl+LOpen filter (and close on match)
# Type / then start typing to filter
# Fuzzy matching by default
# Regex supported

Sorting

KeyAction
tToggle sort order
Ctrl+TToggle sort by time
sToggle sort by size
SToggle sort by extension
vToggle sort by version

Bookmarks

# Set up bookmarks via environment variable
export NNN_BMS='h:~/;d:~/Documents;p:~/Projects;D:~/Downloads;c:~/.config'

# In nnn:
# B - open bookmark
# Then press the shortcut key (h, d, p, etc.)
KeyAction
B or bShow bookmarks

Plugins

# Install plugins
curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh

# Plugins are installed to ~/.config/nnn/plugins/

# Set plugin keybindings
export NNN_PLUG='f:finder;o:fzopen;p:preview-tui;d:diffs;t:nmount;v:imgview'

# In nnn, press ; then the plugin key

Essential Plugins

PluginKeyDescription
preview-tuipFile preview in terminal
fzopenoFuzzy open with fzf
finderfFind files with fzf
diffsdDiff two files
dragdropDrag and drop files
nmounttMount/unmount drives
imgviewvImage viewer
autojumpIntegration with autojump/zoxide

Preview Configuration

# Enable file preview with preview-tui plugin
export NNN_PLUG='p:preview-tui'

# Dependencies for preview
# bat (syntax highlighting), pistol or scope.sh
# chafa or catimg (image preview)
# ffmpegthumbnailer (video thumbnails)
# atool (archive preview)

# Use preview: press ; then p

Configuration via Environment Variables

# Add to ~/.bashrc or ~/.zshrc
export NNN_OPTS="deH"                    # d=detail, e=open in $EDITOR, H=hidden
export NNN_BMS='h:~/;d:~/Documents;p:~/Projects'
export NNN_PLUG='f:finder;o:fzopen;p:preview-tui'
export NNN_FIFO='/tmp/nnn.fifo'          # For preview plugin
export NNN_ARCHIVE="\\.(7z|bz2|gz|tar|tgz|zip|zst)$"  # Archive patterns
export NNN_FCOLORS='c1e2272e006033f7c6d6abc4'  # File colors
export NNN_TRASH=1                       # Use trash instead of delete

# Colors (file type colors)
export NNN_FCOLORS='0000E63100000000F7C6D6ABC4'

# Open nnn with configuration
alias n='nnn -deH'

Command Line Options

FlagDescription
-aAuto NNN_FIFO
-ANo directory auto-enter
-b keyOpen bookmark key on start
-cCLI-only opener
-CColor by context
-dDetail mode
-DDirectories in context
-eOpen text in $EDITOR
-EUse $EDITOR for undetected
-fUse stdin for selection
-gRegex filter
-HShow hidden files
-JDisable auto-jump on select
-KTest for keyboard input
-nNav-as-you-type mode
-oOpen files only on Enter
-p fileCopy selection to file
-P keyRun plugin key on start
-QNo quit confirmation
-rShow cp/mv progress
-RNo rollover at edges
-s nameSession name
-SPersistent session
-t secsIdle timeout
-T keySort key on start
-uUse selection (no prompt)
-UShow user/group
-xSelection notification

Advanced Usage

Shell Integration (cd on quit)

# Bash/Zsh function for cd on quit
n() {
  if [ -n "$NNNLVL" ] && [ "${NNNLVL:-0}" -ge 1 ]; then
    echo "nnn is already running"
    return
  fi
  NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
  nnn "$@"
  if [ -f "$NNN_TMPFILE" ]; then
    . "$NNN_TMPFILE"
    rm -f "$NNN_TMPFILE" > /dev/null
  fi
}

Batch Rename

# Select files with Space
# Press Ctrl+R to batch rename in $EDITOR
# Modify filenames in editor
# Save and close to apply

Sessions

# Start a named session
nnn -s work

# Resume a session
nnn -s work

# Persistent session (auto-save)
nnn -S

Troubleshooting

IssueSolution
No color outputCheck terminal color support; set NNN_FCOLORS
Plugins not workingInstall with getplugs; set NNN_PLUG variable
Preview not showingInstall bat, less; set NNN_FIFO; use -a flag
Cannot delete filesSet NNN_TRASH=1 for trash; check file permissions
cd not working on quitUse the n() shell function, not raw nnn command
Slow on network drivesUse filter to narrow view; avoid -D flag
Key bindings differCheck version; some keys changed between versions
Opener not workingSet $VISUAL or $EDITOR; check xdg-open on Linux