Nnn is an open source terminal file manager written in C with productivity in mind. It offers numerous features, has very few library dependencies and the binary size is just around 60KB! Besides, the dependency on third-party utilities is minimal and anyway, the most required ones are installed by default on most systems.
nnn is not just a file manager, but can perform disk usage analysis, batch rename files, work as an app launcher and pick files. The plugin framework extends the capabilities of the core file manager. There are 30+ plugins available. These include a (Neo) Vim plugin, as well as plugins to view thumbnails of images, watch videos, preview images, find duplicates, view and upload files, play music, create ringtones, and so on. You can also add your own plugins.
One of the important goals of the project is to support low-power devices. In addition to Linux, macOS (via Homebrew), BSD, Cygwin and the Linux subsystem for Windows, nnn also runs smoothly on the Raspberry Pi and the Termux environment for Android.
Note that in this article, we are using the development snapshot of nnn available at the time of writing. However, nnn is available on many package managers and distros like Arch Linux, Debian, Fedora, Homebrew, openSUSE and Ubuntu (and others in this family). If it’s not readily available for you or if the packaged version is old, you can compile it from source code easily. For example, on Ubuntu 18.04, the following commands will compile and install nnn:
$ sudo apt-get install pkg-config libncursesw5-dev libreadline-dev $ make $ sudo make strip install
You may want to install some optional utilities like bsdtar and trash-cli depending on your regular workflows.
To install plugins, run the following command:
$ curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh
There’s more information on the plugins in the README available in the plugins directory of the project’s home page. In addition, there’s a very informative wiki.
nnn does not have any configuration file. It uses a few environment variables and you have to set the ones that you need. For regular users, the following example settings should suffice:
# Set bookmarks NNN_BMS='d:~/Documents;D:~/Docs archive/' # Set keys for plugins you want to run directly with the keypress combination `:key` NNN_PLUG='o:fzy-open;p:mocplay;m:nmount;t:thumb' # If you prefer to open text files in your $EDITOR NNN_USE_EDITOR=1 # Set a distinct color for each tab (by default all are blue) NNN_CONTEXT_COLORS='1234'
The first thing you notice when you start nnn is its minimalism. However, don’t let it fool you. nnn switches to the detailed mode at a key-press with more information about listed files. If you want, you can also set an alias to open it in default mode, all the time. It also comes with four contexts (or tabs) which you can cycle by using TAB.
Once you start navigating, you’ll notice the speed at which directory entries are loaded and listed. It’s instant and has zero lag! There are several features which help in navigation such as a navigate-as-you-type mode with directory auto-select which feels very natural. There are bookmarks, and you can pin a directory and visit it anytime. There are also easy shortcuts to visit home,‘ /’, start and the last visited directories.
You can search files in the current directory by regex or normal text strings. Matches are dynamically updated instantly as you type. There’s also a plugin to perform fuzzy subtree search.
By default, nnn uses the case-insensitive sort with directories on top. Pure-numeric file names are listed sorted. This ordering is very helpful in directories with lots of pure-numeric entries like /proc, where there are directories for each process ID running on the current system. The additional orders supported are version sort, file name, modification time, access time, size and file extension.
nnn supports both the keyboard and the mouse. However, terminal users may prefer to use the keyboard most of the time. As you may have realised by now, so many features need shortcuts to trigger or switch. To make life easy for users, the shortcuts can be listed anytime while running nnn by pressing ‘?’.
Desktop integration is seamless and files are opened using the default file opener for the desktop environment. It’s possible to use a custom opener. You can also open a file in an app of your choice using the ‘Open with…’ shortcut.
The memory usage of nnn is something that needs to be mentioned. Even while running disk usage analysis on a directory with 2000 files, it’s negligible:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 18976 user 20 0 17224 3792 2760 S 0.0 0.0 0:00.04 nnn
Once you get started, you’ll notice that the numerous features of nnn get revealed to you, depending on what your current needs are. There are just too many features packed into this tiny utility. It’s an amazing productivity-booster that can easily find its place in your regular terminal sessions.