1
1
mirror of https://github.com/jarun/nnn.git synced 2024-11-24 18:00:25 +03:00
350 Usage
Arun edited this page 2024-08-25 10:14:51 +05:30

Dependencies

A curses library with wide char support (e.g. ncursesw), libc and libreadline (optional).

Utility deps Install? Operation
xdg-open (Linux)/open(1) (macOS)/cygstart (Cygwin)/open (Haiku) base default opener
file, coreutils (cp, mv, rm), xargs, sed base file type, copy, (re)move
GNU sed (non-Linux) required copy, (re)move
tar, (un)zip [bsdtar/atool/(un)rar for more formats] base manage archives
archivemount, fusermount(3)/umount (macOS) optional (un)mount archives
sshfs/rclone, fusermount(3)/umount (macOS) optional (un)mount remotes
gio trash/trash-cli optional trash [default: rm -rf]
vlock (Linux)/bashlock (macOS)/lock(1) (BSD)/peaclock (Haiku) optional lock terminal
advcpmv (Linux) (integration) optional copy, move progress
$VISUAL/$EDITOR, $PAGER, $SHELL optional fallback vi, less, sh

Installation

TL;DR: Can't install packages? Get the statically linked binary from the latest release.

Release packages

Officially maintained RPM distribution + an Arch package is available in Openbuildservice
Packages for Debian and Ubuntu and a static binary are generated with the latest release.

From a package manager

Packaging status (expand) Packaging status


Packaging status

Unlisted packagers:


● CentOS (yum --enablerepo=epel install nnn)
● iSH (apk add nnn)
Milis Linux (mps kur nnn)
NuTyX (cards install nnn)
Sailfish OS (devel-su zypper install nnn)
Source Mage (cast nnn)

From source

Download the latest release or clone this repo (risky), install deps and compile. On Ubuntu 18.04:

sudo apt-get install pkg-config libncursesw5-dev libreadline-dev
sudo make strip install

PREFIX is supported, in case you want to install to a different location.

See the developer guides for source verification, platform-specific notes and other tips.

Shell completion

Completion scripts for Bash, Fish and Zsh are available. Refer to your shell's manual to install.

Plugins

Visit the plugins page.

Configuration

The new colorscheme (config NNN_FCOLORS) - a feast for your eyes!

There is no config file. Associated files are at

${XDG_CONFIG_HOME:-$HOME/.config}/nnn/

Use plugin nbak to backup configuration.

nnn supports a few optional (set if you need) environment variables.

Example export Description
NNN_OPTS="cEnrx" binary options to nnn
NNN_OPENER="/path/to/custom/opener" custom opener (see plugin nuke)
NNN_BMS="d:$HOME/Documents;D:$HOME/Docs archive/" 1 key-bookmark pairs
NNN_PLUG='o:fzopen;m:nmount;x:!chmod +x $nnn' 1 key-plugin (or cmd) pairs
NNN_ORDER='t:/home/user/Downloads;S:/usr/bin' 2 directory-specific ordering
NNN_ARCHIVE="\\.(7z|bz2|gz|tar|tgz|zip)$" 3 archives [default: bzip2, (g)zip, tar]
NNN_ARCHMNT='fuse-archive' archive mounter [default: archivemount]
NNN_COLORS='1234' (/'#0a1b2c3d'/'#0a1b2c3d;1234') 4 6 context colors [default: '4444' (blue)]
NNN_FCOLORS='c1e2272e006033f7c6d6abc4' 5 file-specific colors
NNN_SSHFS='sshfs -o reconnect,idmap=user' 6 custom SSHFS cmd
NNN_RCLONE='rclone mount --read-only' 6 custom rclone cmd
NNN_TRASH=n (n=1: trash-cli, n=2: gio trash) use desktop Trash [default: rm -rf]
NNN_SEL='/tmp/.sel' custom selection file
NNN_FIFO='/tmp/nnn.fifo' 7 FIFO to write hovered file path to
NNN_LOCKER='saidar -c' terminal locker
NNN_TMPFILE='/tmp/.lastd' always cd on quit
NNN_HELP='pwy paris' run cmd, show o/p on help page
NNN_MCLICK='^R' (/'m') 8 key emulated by middle mouse click
NO_COLOR=1 9 disable ANSI color output
  1. Key-bookmark and key-plugin pairs are listed in the help and config screen (key ?).

  2. Sort keys can be a/d/e/r/s/t/v (see program option -T). Capitalize to reverse (except r). Path must be absolute.

    Timestamps for entries created/modified within 5 minutes are shown in reverse.

  3. With atool or bsdtar and (un)rar installed you can have:

    export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
    

    bsdtar can extract, list and archivemount can mount ISO 9660 cdrom images (extn: iso).

  4. Understands 8 color, xterm 256 color or both.

Hexadecimal numbers representing xterm 256 colors, note that the width has to be 2, e.g. "5" becomes "05"

  • 8 colors numbers: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white.
  • To specify xterm 256 color hex numbers, prefix with # (2 symbols per context).
  • To specify both, export 256 color hex numbers followed by 8 color number as fallback, separated by ;.
  1. Specify file-specific colors in xterm 256 color hex numbers (2 hex symbols per color).

    Order is strict, use 00 to omit/use default terminal color. Defaults:

    Order Hex Color
    Block device c1 DarkSeaGreen1
    Char device e2 Yellow1
    Directory 27 DeepSkyBlue1
    Executable 2e Green1
    Regular 00 Normal
    Hard link 60 Plum4
    Symbolic link 33 Cyan1
    Missing OR file details f7 Grey62
    Orphaned symbolic link c6 DeepPink1
    FIFO d6 Orange1
    Socket ab MediumOrchid1
    Unknown OR 0B regular/exe c4 Red1
    • If the terminal supports xterm 256 colors or more, file-specific colors will be rendered.
    • To force the 8-color scheme use option -C.
    • If xterm 256 colors aren't supported, 8-color scheme will be used.
    • More Themes.
  2. nnn v2.9 and below have NNN_CONTEXT_COLORS, NNN_SSHFS_OPTS and NNN_RCLONE_OPTS.

  3. If the FIFO file doesn't exist it will be created, but it will never be removed.

  4. Only the first character is considered if not a Ctrl-key combo.

  5. Overridden by NNN_COLORS.

Program options

usage: nnn [OPTIONS] [PATH]

The unorthodox terminal file manager.

positional args:
  PATH   start dir/file [default: .]

optional args:
 -a      auto NNN_FIFO
 -A      no dir auto-enter during filter
 -b key  open bookmark key (trumps -s/S)
 -B      use bsdtar for archives
 -c      cli-only NNN_OPENER (trumps -e)
 -C      8-color scheme
 -d      detail mode
 -D      dirs in context color
 -e      text in $VISUAL/$EDITOR/vi
 -E      internal edits in EDITOR
 -f      use readline history file
 -F val  fifo mode [0:preview 1:explore]
 -g      regex filters
 -H      show hidden files
 -i      show current file info
 -J      no auto-advance on selection
 -K      detect key collision
 -l val  set scroll lines
 -n      type-to-nav mode
 -N      use native prompt
 -o      open files only on Enter
 -p file selection file [-:stdout]
 -P key  run plugin key
 -Q      no quit confirmation
 -r      use advcpmv patched cp, mv
 -R      no rollover at edges
 -s name load session by name
 -S      persistent session
 -t secs timeout to lock
 -T key  sort order [a/d/e/r/s/t/v]
 -u      use selection (no prompt)
 -U      show user and group
 -V      show version
 -x      notis, selection sync, xterm title
 -0      use null separator in picker mode
 -h      show help

Notes:

  1. nnn opens the current working directory if PATH is not specified.
  2. If PATH is specified and it exists, nnn will open it.
  3. If the PATH doesn't exist and ends with a /, nnn will attempt to create the directory tree and open it. Otherwise, PATH is considered a path to a regular file and nnn attempts to create the complete directory tree to the file, open the parent directory and prompt to create the new file in it with the base filename.
  4. The keys for option -T are apparent disk usage / disk usage / extension / reverse / size / time / version. Capitalize to reverse (except r).

Keyboard, mouse

The list below is from master. Press ? in nnn to see the keybinds in your installed version.

 NAVIGATION
         Up k  Up                PgUp ^U  Page up
         Dn j  Down              PgDn ^D  Page down
         Lt h  Parent            ~ ` @ -  ~, /, start, prev
     Ret Rt l  Open                    '  First file/match
         g ^A  Top                     J  Jump to entry/offset
         G ^E  End                    ^J  Toggle auto-advance on open
        B (,)  Book(mark)           b ^/  Select bookmark
          1-4  Context           (Sh)Tab  Cycle/new context
      2Esc ^Q  Quit                   ^y  Next young
           ^G  QuitCD                  Q  Pick/err, quit
            q  Quit context
 
 FILTER & PROMPT
            /  Filter                 ^N  Toggle type-to-nav
          Esc  Exit prompt            ^L  Toggle last filter
            .  Toggle hidden     Alt+Esc  Unfilter, quit context
 
 FILES
         o ^O  Open with...            n  Create new/link
         f ^F  File details            d  Detail mode toggle
           ^R  Rename/dup              r  Batch rename
            z  Archive                 e  Edit file
            *  Toggle exe              >  Export list
      Space +  (Un)select            m-m  Select range/clear
            a  Select all              A  Invert sel
         p ^P  Copy here            w ^W  Cp/mv sel as
         v ^V  Move here               E  Edit sel list
         x ^X  Delete or trash         S  Listed sel size
            X  Delete (rm -rf)       Esc  Send to FIFO
 
 MISC
        Alt ;  Select plugin           =  Launch app
         ! ^]  Shell                   ]  Cmd prompt
            c  Connect remote          u  Unmount remote/archive
         t ^T  Sort toggles            s  Manage session
            T  Set time type           0  Lock
           ^L  Redraw                  ?  Help, conf

Notes:

  1. Shift-TAB attempts to create a new context, and reverse cycles when all contexts are active.
  2. B adds a new bookmark in the bookmarks dir, , marks a location in-memory
  3. At the filter prompt, ^L toggles last filter and unfilter. If no last filter, exits filter mode and redraws.
  4. Q quits with EXIT_FAILURE if no selection, else prints the selection to stdout and quits with EXIT_SUCCESS.
  5. S shows the total size of non-filtered selected files listed in a directory. For directories, only the size of the directory is added by default. To add the size of the contents of a directory, switch to du mode.
  6. Help & settings, file details and archive listing are shown in the $PAGER.
  7. To change shortcuts modify key bindings in nnn.h and compile. Option -K detects collisions.
  8. Repeat sort order key ^T to apply sort by time, size and default in the same order.
  9. There are keymap patches available for the Colemak and Colemak-DH keyboard layouts in nnn's User Patch Framework.

Graphical map

nnn QWERTY map

(CC BY-SA Léo Villeveygoux, based on Qwerty.svg)

SVG version

Mouse

Mouse click Function
Left single on context number Visit context
Left single on current path Visit parent
Left single/double on last 2 rows Toggle type-to-nav
Left single Select context or entry
Left double Select context or open entry
Right single Add entry to selection
Middle single User configured with NNN_MCLICK

Broken control keybind

Some control keybinds may not work if they are mapped by stty. To confirm, run stty -a and look for keybind conflicts. Some common ones are: ^Q (start), ^S (stop), ^V (lnext).

To remove the stty mapping:

stty start undef
stty stop undef
stty lnext undef

Symbols

File indicators

Listing 1Listing 2
Indicator File type
/ Directory
* Executable
| Fifo
= Socket
Indicator File type
@ Symlink to file
b Block device
c Character device
? Unknown

Note:

  • All links (hard/sym) are dimmed.

Status bar symbols

Symbol Meaning
x/y current file num / total
+/*(n) selection mode on/range selection on (buffered selected count) [reversed]
H hidden files are listed
M modification time sorted
A access time sorted
C change time sorted
S size sorted
E file extension sorted
V version sorted
R reverse sorted
du disk usage
au apparent disk usage
-> symbolic link target
n-n num hard links - inode number

File size

The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y (powers of 1024), same as the default units in ls.

Help

nnn -h
man nnn

To lookup keyboard shortcuts at runtime, press ?.

user1: How it compares to Midnight Commander ?
user2: It works in daylight too.
         - from a reddit conversation