-
-
Notifications
You must be signed in to change notification settings - Fork 763
Home
Project dir in preview
Welcome to the nnn
Wiki! It's editable. Feel free to add to the knowledge base.
nnn
(or n³) is a recursive acronym from Nnn's Not Noice!
Looking for a list of features or quickstart guide? Visit the project home.
Open multiple locations with 4 contexts. The status is shown in the top left corner:
- the current context is in reverse video
- other active contexts are underlined
- rest are inactive
Cycle contexts using Tab or Shift+Tab. A new context copies the state of the previous context.
Use context-specific colors (see configuration NNN_COLORS
) to identify each context easily.
The nnn
way is to work with multiple contexts using Tab or Shift+Tab.
For dual pane, use a terminal multiplexer e.g., to open 2 instances in dvtm
, run:
dvtm n n
You can also have an alias:
alias n2="dvtm n n"
or a Bash function (with ^\ as dvtm modifier) to handle arguments:
n2 ()
{
dvtm -m '^\' "nnn -nr $@" "nnn -nr $@"
}
Sessions are a way to save and restore states of work. A session stores the settings and contexts. All the session files are located in the ${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
directory by the session name.
Sessions can be loaded dynamically at runtime or with a program option.
Note: When a session is loaded dynamically, the last working session is saved automatically to a dedicated -- "last session" -- session file. The "last session" is also used in persistent session mode.
Filters are strings (or regex patterns) to find matching entries in the current directory instantly (search-as-you-type). Matches are case-insensitive by default. The last filter in each context is persisted at runtime or in saved sessions.
Key | Function |
---|---|
^char | Usual keybind functionality |
Esc | Exit filter prompt but skip dir refresh |
Alt+Esc | Exit filter prompt and refresh dir (same as Esc^L) |
Special keys at empty filter prompt:
Key | Function |
---|---|
? | Show help and config screen |
/ | Toggle between string and regex |
: | Toggle case-sensitivity |
^L | Clear filter (if prompt is non-empty) OR apply last filter |
Additional special keys at empty filter prompt in type-to-nav mode:
Listing 1 | Listing 2 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
- to list all matches starting with the filter expression, start with a
^
(caret) - type
\.mkv
to list all MKV files - use
.*
to match any character (sort of fuzzy search) - exclude filenames having
nnn
(with PCRE):^(?!nnn)
Use regex for case-sensitive filtering with wide chars as the function strcasestr
(used for string filters) does not work with multibyte locales (ref1, ref2).
In this mode directories are opened in filter mode, allowing continuous navigation.
When there's a unique match and it's a directory, nnn
auto selects the directory and enters it in this mode. Program option -A
disables this.
To start in type-to-nav mode, use the program option -n
or press ^N.
nnn
allows file selection across directories and contexts!
There are 3 groups of keybinds to add files to selection:
- hovered file selection toggle
- deselects if
+
is visible before the entry, else adds to selection
- deselects if
- add a range of files to selection
- repeat the range key on the same entry twice to clear selection completely
- add all files in the current directory to selection
A selection can be edited, copied, moved, removed, archived or linked. Example workflow to copy or move some files:
- add files from source dirs (you can select files from multiple dirs in
nnn
) to selection - navigate to a target directory
- use ^P (cp) or ^V (mv) to copy or move the selected files
Absolute paths of the selected files are copied to .selection
file in the config directory. The selection file is shared between multiple program instances. The most recent instance writing to the file overwrites the entries from earlier writes. If you have 2 instances of nnn
open in 2 panes of a terminal multiplexer, you can select in one pane and use the selection (e.g. to copy or move) in the other pane (if the instance doesn't have any local selection already).
nnn
clears the selection after file removal, batch-rename and link creation with selection. However, it is retained after archive creation with selection as the user may want to delete the archived files next.
To edit the selection use the edit selection key. Use this key to remove a file from selection after you navigate away from its directory or remove duplicates. Editing doesn't end the selection mode. You can add more files to the selection and edit the list again. If no file is selected in the current session, this option attempts to list the selection file.
Use the program option -x
to copy selection to the system clipboard. You must have plugins installed.
Many plugins use this method. The file paths are NUL
-terminated, so additional processing is required to make them usable.
To run ls -l
on the file paths in selection:
xargs -0 ls -l < "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection"
An special variable may be handy:
export sel=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
so you can easily handle files together (even at the nnn
command prompt!):
xargs -0 ls -l < $sel // compare 2 selected files
Notes:
- The selection file can be directly edited to remove any entries but it's not recommended.
- If an already selected file doesn't have the
+
symbol before it (say, on a directory refresh or after navigating away and back to the dir), the selection toggle key will add it again. - Window managers like i3/sway re-dimensions window and forces redraw when opening a file. So the
+
symbol disappears. To get rid of this use a CLI opener likenuke
. For example, when opening and renaming files withnuke
, the images are opened in the terminal inviu
and there is no window-manager redraw involved. See issue #464.
There are two ways to search and list:
- feed a list of file paths as input
- search using a plugin (e.g.
finder
) and list the results
File paths must be NUL-separated ('\0'). Paths can be relative to the current directory or absolute. Invalid paths in the input are ignored. Input limit is 65,536 paths or 256 MiB of data.
To list the input stream, start nnn
by writing to its standard input. E.g., to list files in current directory larger than 1M:
find -maxdepth 1 -size +1M -print0 | nnn
# fd -d 2 -S +1M -0 | nnn
or redirect a list from a file:
nnn < files.txt
Handy bash/zsh shell function to list files by mime-type in current directory:
# to show video files, run: list video
list ()
{
find . -maxdepth 1 | file -if- | grep "$1" | awk -F: '{printf "%s\0", $1}' | nnn
# fd -d 1 | file -if- | grep "$1" | awk -F: '{printf "%s\0", $1}' | nnn
}
A temporary directory will be created containing symlinks to the given paths. Any action performed on these symlinks will be performed only on their targets, after which they might become invalid.
Right or l on a symlink inside the listing dir takes to the target file. Press - to return to the listing dir. Press Enter to open the symlink.
The prompts (except the filter prompt) support readline-like command-line shortcuts. Enter or ^D at the empty prompt (except the filter prompt) exits the prompt.
Key ^L clears and Esc exits all prompts.
The run & exit command prompt understands environment variables (like $PWD
). Refer to your shell's documentation (e.g. BASH_ENV
for bash, ~/.zshenv
for zsh) to use aliases and functions. To fuzzy-select commands from your shell history at the command prompt and issue them after editing (like fc), copy the plugin fzhist
(as h
maybe?) in your $PATH
.
The special variable $nnn
denotes the hovered file name. It is accessible from the command prompt or a spawned shell.
All binary questions are confirmed by y or Y.
nnn
(the core C utility) is, generally speaking, feature-restricted. It includes features which you really need so it can remain light enough to finish your workflow accurately before your train of thought is lost.
nnn
supports plugins to extend its capabilities.
Here's a list of the design principles driving the core nnn
program:
-
nnn
complements X, doesn't substitute it- Brings the best of CLI to a GUI user
- Doesn't expect the user to abandon GUI (the GUI is well-established for a reason)
- Zero-config comfort-zone for GUI users out of the box
- Quick and distraction-free workflows
- Clean and clutter-free single-window view focused on content
- Easily switch context/tabs with (Sh)TAB
- Only directories in color, no icons
- To search/group by extension, use filter or sort by extension option
- Support external or plugin-based previewers by writing the the hovered file path to a custom FIFO.
- One utility instead of multiple utilities for related tasks e.g.
- file management, batch rename, disk usage analysis, launching apps etc.
- No configuration file and few environment variables
- Stay portable - very limited library dependencies
- support compiling out features
- Use a standard desktop opener to handle file associations
- Analyze disk usage within the same filesystem, do not follow symbolic links
- Case-insensitive alphabetic content listing instead of all uppercase first
- Directories first in all modes (even in disk usage analyzer mode)
- No navigation restriction with relative paths (let permissions handle it)
- Directory updates are disabled in the following modes:
- disk usage: re-scans are issued on every change in dir
- filter mode: content refresh is very disruptive in the workflow
- Limited (4) number of contexts; for more, use another instance
- file paths copy-paste should work seamlessly between contexts and instances of
nnn
- file paths copy-paste should work seamlessly between contexts and instances of
- Scan each directory on visit (even in disk usage analyzer mode) rather than storing all the information from the first scan. This keeps the information up to date. To compensate, use fast re-scan with highly optimized algorithms.
- The nnn magic!
- Add bookmarks
- Configure cd on quit
- Sync subshell
$PWD
- Hot-plugged drives
- Image, video, pdf
- Detached text
- Run commands
- Launch applications
- Open as root
- File picker
- Remote mounts
- Synced quick notes
- Drag and drop
- Duplicate file
- Create batch links
- Hidden files on top
- Disable bold fonts
- Themes
- Live previews
- File icons
- Custom keybinds
- CLI-only opener
- Desktop integration
- cp mv progress
- Control active dir
- Termux tips
- Pager as opener
- Working with lftp
- Power toys