File: README.md
nnn - *Supercharge your productivity!*
[[Features](https://github.com/jarun/nnn#features)] [[Quickstart](https://github.com/jarun/nnn#quickstart)] [[Plugins](https://github.com/jarun/nnn/tree/master/plugins#nnn-plugins)] [[Wiki](https://github.com/jarun/nnn/wiki)]
nnn (n³) is a full-featured terminal file manager. It's tiny (~150 KiB), nearly 0-config and incredibly fast.
It is designed to be unobtrusive with smart workflows to match the trains of thought.
nnn can analyze disk usage, batch rename, launch apps and pick files. The plugin repository has tons of plugins to extend the capabilities further e.g. live previews, (un)mount disks, find & list, file/dir diff, upload files. A patch framework hosts sizable user-submitted patches which are subjective in nature.
Independent (neo)vim plugins - nnn.vim, vim-floaterm nnn wrapper and nnn.nvim (neovim exclusive).
Runs on the Pi, Termux (Android), Linux, macOS, BSD, Haiku, Cygwin, WSL, across DEs or a strictly CLI env.
Features
- Quality
- Privacy-aware (no unconfirmed user data collection)
- POSIX-compliant, follows Linux kernel coding style
- Highly optimized, static analysis integrated code
- Frugal
- Typically needs less than 3.5MB resident memory
- Works with 8 colors (and xterm 256 colors)
- Disk-IO sensitive (few disk reads and writes)
- No FPU usage (all integer maths, even for file size)
- Minimizes screen refresh with fast line redraws
- Tiny binary (typically around 100KB)
- 1-column mode for smaller terminals and form factors
- Hackable - compile in/out features and dependencies
- Portable
- Language-agnostic plugins
- Static binary available (no need to install)
- Minimal library deps, easy to compile
- No config file, minimal config with sensible defaults
- Plugin to backup configuration
- Widely available on many packagers
- Touch enabled, handheld-friendly shortcuts
- Unicode support
- Modes
- Light (default), detail
- Disk usage analyzer (block/apparent)
- File picker, (neo)vim plugin
- Navigation
- Filter with automatic dir entry on unique match
- Type-to-nav (turbo navigation/always filter) mode
- Jump to an entry with visible relative offset
- Contexts (aka tabs/workspaces) with custom colors
- Sessions, bookmarks, mark and visit a dir
- Remote mounts (needs
sshfs,rclone) - Familiar shortcuts (arrows, ~, -, @), quick look-up
cdon quit (easy shell integration)- Proceed to next file on file open and selection
- Search
- Instant filtering with search-as-you-type
- Fuzzy, regex (POSIX/PCRE2) and string (default) filters
- Subtree search plugin to open or edit files
- Sort
- Ordered pure numeric names by default (visit
/proc) - Case-insensitive version (aka natural) sort
- By name, access/change/mod (default) time, size, extn
- Reverse sort
- Directory-specific ordering
- Ordered pure numeric names by default (visit
- Mimes
- Built-in previewer for directory and text files
- FIFO-based previewer plugins with extensive mime support
- Open with desktop opener or specify a custom opener
- File-specific colors (or minimal dirs in context color)
- Icons and Emojis support (customize and compile-in)
- Plugin for image, video and audio thumbnails
- Create, list, extract (to), mount (FUSE based) archives
- Option to open all text files in
$EDITOR
- Convenience
- Detailed file stats and mime information
- Run plugins and custom commands with hotkeys
- FreeDesktop compliant trash utility integration
- Cross-dir file/all/range selection
- Create (with parents), rename, duplicate files and dirs
- Create new file or directory (tree) on startup
- Batch renamer for selection or dir
- List input stream of file paths from stdin or plugin
- Copy (as), move (as), delete, archive, link selection
- Easily copy, move paths in system clipboard to current dir
- Dir updates, notification on
cp,mv,rmcompletion - Copy file paths to system clipboard on select
- Launch apps, run commands, spawn a shell, toggle exe
- Access context paths/files at prompt or spawned shell
- Lock terminal after configurable idle timeout
- Capture and show output of a program in help screen
- Basic support for screen readers and braille displays
Quickstart
Beginners
- Install
nnn, preferbly using the package manager. - Run the following command to generate (and optionally add to your rc file) a shell function to start with.sh
sh -c "$(curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/misc/quickstart.sh)"
Use the shell function name you chose to run nnn with your preferred configuration.
Power users
- Install
nnnand the dependencies you need. - The desktop opener is default. Use
-eto open text files in the terminal. Optionally open detached. - Configure cd on quit.
- Sync subshell
$PWDtonnn. - Install plugins.
- Use
-xto sync selection to clipboard, show notis oncp,mv,rmand set xterm title. - For a CLI-only environment, set
NNN_OPENERtonuke. Use option-c. - Bid
lsgoodbye!alias ls='nnn -de':sunglasses: - Visit the Live previews and Troubleshooting Wiki pages.
Don't memorize! Arrows, /, q suffice. Tab creates and/or cycles contexts. ? lists shortcuts.
Videos
- nnn file manager on Termux (Android)
- NNN File Manager
- This Week in Linux 114 - TuxDigital
- nnn file manager basics - Linux
- I'M GOING TO USE THE NNN FILE BROWSER! 😮
- NNN: Is This Terminal File Manager As Good As People Say?
- nnn - A File Manager (By Uoou, again.)
Elsewhere
- AddictiveTips
- ArchWiki
- FOSSMint
- gHacks Tech News
- Hacker News [1] [2]
- It's FOSS
- Linux Format Issue 265; Manage files with nnn
- LinuxLinks [1] [2] [3]
- Linux Magazine; FOSSPicks
- Make Tech Easier
- Opensource.com
- Open Source For You
- PCLinuxOS Magazine Issue June 2021
- Suckless Rocks
- Ubuntu Full Circle Magazine Issue 135; Review: nnn
- Using and Administering Linux: Volume 2: Zero to SysAdmin: Advanced Topics
- Wikipedia
Developers
- Arun Prakash Jana (Copyright © 2016-2026)
- 0xACE
- Anna Arad
- KlzXS
- Léo Villeveygoux
- Luuk van Baal
- NRK
- Sijmen J. Mulder
- and other contributors
Visit the Tracker thread for a list of features in progress and anything up for grabs. Feel free to discuss new ideas or enhancement requests.
File: patches/README.md
User Patch Framework
This directory contains sizable user submitted patches that were rejected from mainline as they tend to be more subjective in nature.
The patches will be adapted on each release when necessary (v4.1 onwards). Each patch can be applied through its respective make variable during compilation. In case inter-patch merge conflicts occur, a compatibility patch is provided and will automatically be applied.
List of patches
| Patch (a-z) | Description | Make var |
|---|---|---|
| colemak | Key bindings for Colemak keyboard layout | O_COLEMAK |
| gitstatus | Add git status column to the detail view. Provides command line flag -G to show column in normal mode. |
O_GITSTATUS |
| namefirst | Print filenames first in the detail view. Print user/group columns when a directory contains different users/groups. | O_NAMEFIRST |
| restorepreview | Add pipe to close and restore preview-tui for internal undetached edits (e key) |
O_RESTOREPREVIEW |
To apply a patch, use the corresponding make variable, e.g.:
make O_NAMEFIRST=1When contributing/adding a new patch, make sure to add the make variable to the patches array in ./misc/test/check-patches.sh as well so that patch failures can be easily tested.
Resolving patch conflicts
Patch conflicts can be checked locally by running make checkpatches or by running ./patches/check-patches.sh manually.
Whenever patch conflicts occur on the latest master, pull requests resolving them are welcome. Let's say a conflict occurs in the restorepreview patch. The best way to resolve this conflict would be something along the lines of:
- Ensure you're on latest master and run
PATCH_OPTS="--merge" make O_RESTOREPREVIEW=1. This will generate the conflict markers insrc/nnn.c. - Next edit
src/nnn.c, resolve the conflicts around the conflict markers(<<<<<<<), and save. - Then run
git diff > patch.diff && sed -i -e "/^$/{r patch.diff" -e "q;}" patches/restorepreview/mainline.diffto update the patch.
File: plugins/README.md
nnn plugins
Introduction
Plugins extend the capabilities of nnn. They are executable scripts (or binaries) nnn can communicate with and trigger. This mechanism fits perfectly with the fundamental design to keep the core file manager lean and fast, by delegating repetitive (but not necessarily file manager-specific) tasks to the plugins which can be run with custom hotkeys.
nnn is language-agnostic when it comes to plugins. You can write a plugin in any (scripting) language you are comfortable in!
List of plugins
| Plugin (a-z) | Description [Clears selection1] | Lang | Dependencies |
|---|---|---|---|
| .cbcp | Internal: Copy selection to system clipboard | sh | see in-file docs |
| .nmv | Internal: Feature-rich batch renamer | bash | see in-file docs |
| .npreview | Internal: Text-based preview handler | sh | see in-file docs |
| .ntfy | Internal: Notify on copy, move, remove completion | sh | see in-file docs |
| autojump | Navigate to dir/path | sh | jump/autojump/zoxide/z/z.lua |
| boom | Play random music from dir | sh | moc |
| bulknew | Create multiple files/dirs at once | bash | sed, xargs, mktemp |
| cbcopy-mac | Copy the hovered file to MacOS clipboard | applescript | macos |
| cbpaste-mac | Pastes files from MacOS clipboard into currect directory | macos | |
| cdpath | cd to the directory from CDPATH |
sh | fzf |
| chksum | Create and verify checksums [✓] | sh | md5sum,sha256sum |
| cmusq | Queue/play files/dirs in cmus player [✓] | sh | cmus, pgrep |
| diffs | Diff for selection (limited to 2 for directories) [✓] | sh | vimdiff, mktemp |
| dragdrop | Drag/drop files from/into nnn | sh | dragon |
| dups | List non-empty duplicate files in current dir | bash | find, md5sum,sort uniq xargs |
| finder | Run custom find command (stored in histfile) and list | sh | - |
| fixname | Clean filename to be more shell-friendly [✓] | bash | sed |
| fzcd | Fuzzy search multiple dirs (or $PWD) and visit file |
sh | fzf, (find) |
| fzhist | Fuzzy-select a cmd from history, edit in $EDITOR and run |
sh | fzf, mktemp |
| fzopen | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open/open |
| fzplug | Fuzzy find, preview and run other plugins | sh | fzf |
| getplugs | Update plugins to installed nnn version |
sh | curl |
| gitroot | Cd to the root of current git repo | sh | git |
| gpge | Encrypt/decrypt files using GPG [✓] | sh | gpg |
| gpgs | Digitally sign files using GPG [✓] | sh | gpg |
| gpgv | Verify signature files using GPG [✓] | sh | gpg |
| gutenread | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3mepr (optional) |
| gsconnect | GNOME's implementation of kdeconnect [✓] | sh | gsconnect |
| imgresize | Batch resize images in dir to screen resolution | sh | imgp |
| imgur | Upload an image to imgur (from imgur-screenshot) | bash | - |
| imgview | View (thumbnail)images, set wallpaper, rename and more | sh | see in-file docs |
| ipinfo | Fetch external IP address and whois information | sh | curl, whois |
| kdeconnect | Send selected files to an Android device [✓] | sh | kdeconnect-cli |
| launch | GUI application launcher | sh | fzf |
| mimelist | List files by mime in subtree | sh | file/mimetype |
| moclyrics | Show lyrics of the track playing in moc | sh | ddgr, moc |
| mocq | Queue/play selection/dir/file in moc [✓] | sh | moc |
| mp3conv | Extract audio from multimedia as mp3 | sh | ffmpeg |
| mtpmount | Toggle mount of MTP device (eg. Android) | sh | gvfs-mtp |
| nbak | Backs up nnn config |
sh | tar, awk, mktemp |
| nmount | Toggle mount status of a device as normal user | bash | pmount (optional), udisks2 |
| nuke | Sample file opener (CLI-only by default) | sh | see in-file docs |
| oldbigfile | List large files by access time | sh | find, sort |
| openall | Open selected files together or one by one [✓] | bash | - |
| organize | Auto-organize files in directories by file type [✓] | sh | file |
| pdfread | Read a PDF or text file aloud | sh | pdftotext, mpv,pico2wave |
| preview-tabbed | Preview files with Tabbed/xembed | bash | see in-file docs |
| preview-tui | Preview with Tmux/kitty/QuickLook/xterm/$TERMINAL |
sh | see in-file docs |
| pskill | Fuzzy list by name and kill process or zombie | sh | fzf, ps, sudo/doas |
| renamer | Batch rename selection or files in dir [✓] | sh | qmv/vidir |
| ringtone | Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg |
| rsynccp | Gives copy-paste verbose progress percentage [✓] | sh | rsync |
| splitjoin | Split file or join selection [✓] | sh | split, cat |
| stats | Show file stats in a pager | sh | file, stat, pager |
| suedit | Edit file using superuser permissions | sh | sudoedit/sudo/doas |
| tnp | Opens files in a Tmux Neovim pane (Tmux session only) | sh | tmux, nvim |
| togglex | Toggle executable mode for selection [✓] | sh | chmod |
| umounttree | Unmount a remote mountpoint from within | sh | fusermount |
| upload | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | ffsend, curl, jq, tr |
| wallpaper | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
| x2sel | Copy file list from system clipboard to selection | sh | see in-file docs |
| xdgdefault | Set the default app for the hovered file type | sh | xdg-utils, fzf/dmenu |
Notes:
- A plugin has to explicitly request
nnnto clear the selection e.g. after operating on the selected files. - Files starting with a dot in the
pluginsdirectory are internal files, listed at the top of the table, and should not be used as plugins directly.
Table of contents
- Installation
- Configuration
- Running commands as plugin
- Access level of plugins
- Create your own plugins
- Examples
- Contributing plugins
Installation
The following command installs or updates (after backup) all plugins:
sh -c "$(curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs)"Plugins are installed to ${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins.
Configuration
Set environment variable NNN_PLUG to assign keybinds and invoke plugins directly using the plugin shortcut (;) followed by the assigned key character. E.g., with the below config:
export NNN_PLUG='f:finder;o:fzopen;p:mocq;d:diffs;t:nmount;v:imgview'plugin finder can be invoked with the keybind ;f, fzopen can be run with ;o and so on... The key vs. plugin pairs are shown in the help and config screen.
Alternatively, combine with Alt (i.e. Alt+key).
To pick and run an unassigned plugin, press Enter (to enter the plugin dir) at the plugin prompt.
To run a plugin at startup, use the option -P followed by the plugin key.
If the plugins list gets too long, try breaking them up into sections:
NNN_PLUG_PERSONAL='g:personal/convert2zoom;p:personal/echo'
NNN_PLUG_WORK='j:work/prettyjson;d:work/foobar'
NNN_PLUG_INLINE='e:!go run "$nnn"*'
NNN_PLUG_DEFAULT='1:ipinfo;p:preview-tui;o:fzz;r:!ratio | sort -nr > ratio*;b:nbak'
NNN_PLUG="$NNN_PLUG_PERSONAL;$NNN_PLUG_WORK;$NNN_PLUG_DEFAULT;$NNN_PLUG_INLINE"
export NNN_PLUGNote:
'g:personal/convert2zoom'will look in the personal sub-folder inside the plugin folder.'b:boom;b:bulknewwill result in only the first definition of b (b:boom) being used.- A keybinding definition of more than 1 character will prevent nnn from starting.
Skip directory refresh after running a plugin [`-`]
nnn refreshes the directory after running a plugin to reflect any changes by the plugin. To disable this add a - before the plugin name:
export NNN_PLUG='p:-plugin'Running commands as plugin [`!`]
To assign keys to arbitrary non-background cli commands and invoke like plugins, add ! before the command.
export NNN_PLUG='x:!chmod +x "$nnn";g:!git log;s:!smplayer "$nnn"'Now ;x can be used to make a file executable, ;g can be used to the git log of a git project directory, ;s can be used to preview a partially downloaded media file.
Skip user confirmation after command execution [`*`]
nnn waits for user confirmation (the prompt Press Enter to continue) after it executes a command as plugin (unlike plugins which can add a read to wait). To skip this, add a * after the command.
export NNN_PLUG='s:!smplayer "$nnn"*;n:-!vim /home/vaio/Dropbox/Public/synced_note*'Now there will be no prompt after ;s and ;n.
Note: Do not use * with programs that run and exit e.g. cat.
Run a GUI app as plugin [`&`]
To run a GUI app as plugin, add a & after !.
export NNN_PLUG='m:-!&mousepad "$nnn"'Page non-interactive command output [`|`]
To show the output of run-and-exit commands which do not need user input, add | (pipe) after !.
export NNN_PLUG='m:-!|mediainfo "$nnn";t:-!|tree -ps;l:-!|ls -lah --group-directories-first'This option is incompatible with & (terminal output is masked for GUI programs) and ignores * (output is already paged for user).
Notes:
- Place
$nnn(or exported variables) in double quotes ("$nnn") - Use single quotes for
$NNN_PLUGso"$nnn"is not interpreted - (Again) add
!before the command - To disable directory refresh after running a command as plugin, prefix with
-!
Non-interactive command output in a floating window [`>`]
To show the output of run-and-exit commands in a floating window, add > (right arrow) after !.
export NNN_PLUG='m:!>mediainfo "$nnn";t:!>tree -ps;l:!>ls -lah --group-directories-first'This option is incompatible with & (terminal output is masked for GUI programs) and ignores * (output is rendered in a floating window).
Option - is ignored with this option. The directory is always refreshed.
Some useful key-command examples
| Key:Command | Description |
|---|---|
c:!convert "$nnn" png:- | xclip -sel clipboard -t image/png* |
Copy image to clipboard |
C:!cp -rv "$nnn" "$nnn".cp |
Create a copy of the hovered file |
e:-!sudo -E vim "$nnn"* |
Edit file as root in vim |
g:-!git diff |
Show git diff |
h:-!hx "$nnn"* |
Open hovered file in hx hex editor |
k:-!fuser -kiv "$nnn"* |
Interactively kill process(es) using hovered file |
l:-!git log |
Show git log |
n:-!vi /home/user/Dropbox/dir/note* |
Take quick notes in a synced file/dir of notes |
p:-!less -iR "$nnn"* |
Page through hovered file in less |
s:-!&smplayer -minigui "$nnn" |
Play hovered media file, even unfinished download |
x:!chmod +x "$nnn" |
Make the hovered file executable |
y:-!sync* |
Flush cached writes |
Access level of plugins
When nnn executes a plugin, it does the following:
- Changes to the directory where the plugin is to be run (
$PWDpointing to the active directory) - Passes three arguments to the script:
$1: The hovered file's name.$2: The working directory (might differ from$PWDin case of symlinked paths; non-canonical).$3: The picker mode output file (-for stdout) ifnnnis executed as a file picker.
- Sets the environment variable
NNN_PIPEused to controlnnnactive directory. - Sets the environment variable
NNN_INCLUDE_HIDDENto1if hidden files are active,0otherwise. - Sets the environment variable
NNN_PREFER_SELECTIONto1if user prefers to use selection (see nnn's-uflag),0otherwise. - Exports the special variables.
Plugins can also read the .selection file in the config directory.
Create your own plugins
Plugins can be written in any scripting language. However, POSIX-compliant shell scripts runnable in sh are preferred.
Make the file executable. Drop it in the plugin directory. Optionally add a hotkey in $NNN_PLUG for frequent usage.
Send data to `nnn`
nnn provides a mechanism for plugins to send data to nnn to control its active directory or invoke the list mode.
The way to do so is by writing to the pipe pointed by the environment variable NNN_PIPE.
The plugin should write a single string in the format (<->)<ctxcode><opcode><data> without a newline at the end. For example, 1c/etc.
The optional - at the beginning of the stream instructs nnn to clear the selection.
In cases where the data transfer to nnn has to happen while the selection file is being read (e.g. in a loop), the plugin should
create a tmp copy of the selection file, inform nnn to clear the selection and then do the subsequent processing with the tmp file.
A paged [|] or GUI [&] cmd run as plugin cannot clear selection.
The ctxcode indicates the context to change the active directory of.
| Context code | Meaning |
|---|---|
+ |
smart context (next inactive else current) |
0 |
current context |
1-4 |
context number |
The opcode indicates the operation type.
| Opcode | Operation |
|---|---|
c |
change directory |
l |
list files in list mode |
p |
picker file overwritten |
For convenience, we provided a helper script named .nnn-plugin-helper and a function named nnn_cd to ease this process. nnn_cd receives the path to change to as the first argument, and the context as an optional second argument.
If a context is not provided, it is asked for explicitly. To skip this and choose the current context, set the CUR_CTX variable in .nnn-plugin-helper (or in the specific plugin after sourcing .nnn-plugin-helper) to 1.
Usage examples can be found in the Examples section below.
Get notified on file hover
If NNN_FIFO is set, nnn will open it and write every hovered files. This can be used in plugins and external scripts, e.g. to implement file previews.
Don't forget to fork in the background to avoid blocking nnn.
For more details on configuration and usage of the preview plugins, visit Live Previews.
Examples
There are many plugins provided by nnn which can be used as examples. Here are a few simple selected examples.
Show the git log of changes to the particular file along with the code for a quick and easy review.
#!/usr/bin/env sh
git log -p -- "$1"Change to directory in clipboard using helper script
#!/usr/bin/env sh
. $(dirname $0)/.nnn-plugin-helper
nnn_cd "$(xsel -ob)"Change directory to the location of a link using helper script with specific context (current)
#!/usr/bin/env sh
. $(dirname $0)/.nnn-plugin-helper
nnn_cd "$(dirname $(readlink -fn $1))" 0Change to arbitrary directory without helper script
#!/usr/bin/env sh
printf "cd to: "
read -r dir
printf "%s" "0c$dir" > "$NNN_PIPE"Send every hovered file to X selection
#!/usr/bin/env sh
if [ -z "$NNN_FIFO" ] ; then
exit 1
fi
while read FILE ; do
printf "%s" "$FILE" | xsel
done < "$NNN_FIFO" &
disownQuick `find` the first match in subtree and open in `nuke`
#!/usr/bin/env sh
NUKE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke"
printf "file name: "
read -r pattern
entry=$(find . -type f -iname "$pattern" -print -quit 2>/dev/null)
if [ -n "$entry" ]; then
"$NUKE" "$entry"
fiQuick find (using `fd`)
#!/usr/bin/env sh
. "$(dirname "$0")"/.nnn-plugin-helper
printf "pattern: "
read -r pattern
if [ -n "$pattern" ]; then
printf "%s" "+l" > "$NNN_PIPE"
eval "fd -HI $pattern -0" > "$NNN_PIPE"
fiQuick grep (using `rg`)
#!/usr/bin/env sh
. "$(dirname "$0")"/.nnn-plugin-helper
printf "pattern: "
read -r pattern
if [ -n "$pattern" ]; then
printf "%s" "+l" > "$NNN_PIPE"
eval "rg -l0 --hidden -S $pattern" > "$NNN_PIPE"
fiChange directory
NNN_PLUG='c:!read -p "full path: " -r to && [ -n "$to" ] && printf "0c%s" "${to}" > "$NNN_PIPE"*'Contributing plugins
- Add informative sections like Description, Notes, Dependencies, Shell, Author etc. in the plugin.
- Add an entry in the table above. Note that the list is alphabetically ordered by plugin name.
- Keep non-portable commands (like
notify-send) commented so users from any other OS/DE aren't surprised. - The plugin file should be executable.
- If your plugin stores data, use
${XDG_CACHE_HOME:-$HOME/.cache}/nnn. Document it in-file.