[{'language' => 'en', 'url' => '/en/nnn.html'}]

nnn 101 en

nnn is a sweet terminal file manager. It looks like this:

Image from the official nnn repository

We are going to use plugins, check if you have them file in ~/.config/nnn/plugins/. If not, clone the repository and copy them from the plugins folder.

Browsing

Use the arrow keys or the good old h j k l keys if you do not want to leave your home row.

For folders, left/right and h/l allow to go up and down in the tree. When you are on a file, use right or l to open the file (see the "Open everything" part a little bit further).

Tabs

See the [1 2 3 4] at the top of the image in the beginning of this article? They are tabs.

Use your keyboards numbers to switch activate one and switch to it. Tab and Shift+Tab allows to cycle through activated tabs.

Open everything

The nuke plugin allows to open some files with a range of applications

Here are a few elements (see the full list in the plugin comments);

  • pdf: zathura (GUI), pdftotext, mutool, exiftool
  • audio: mocplay (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool
  • avi|mkv|mp4: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool
  • htm|html|xhtml: w3m, lynx, elinks
  • json: jq, python (json.tool module)
  • image/*: imv/sxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool
  • video/*: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool
  • audio/*: mocplay (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool
export GUI=1
export NNN_OPENER=~/.config/nnn/plugins/nuke

I use the GUI=1 variable because I can't live without zathura and mpv.

Tell nnn to use a CLI opener:

nnn -c

Then, when you hit right or l on a file, it will be opened with your favorite application.

Fuzzy find

I use the fzopen plugin which allows to find a file in the current subtree to open it (remember the "Open everything" part? 😄).

export NNN_PLUG='o:fzopen'

Then, use ; (the "start a plugin" key) then o (the key set in NNN_PLUG). Then, just type the name of the file you are looking for and voilĂ !

File preview

I use the preview-tabbed plugin. The preview-tui is also a possibility.

We need to have tabbed installed.

export NNN_PLUG='t:preview-tabbed'

Tell nnn to use an automatic fifo file for the plugin:

nnn -a

Or set the path to one with the NNN_FIFO environment variable and run nnn.

Then, use ; (the "start a plugin" key) then t (the key set in NNN_PLUG). I use i3, a tiling window manager, so the screen gets split automagically to display the preview on a part of the screen. You can then browse your files and the preview window will be updated.

Images

viu is quite a fun tool to display an image in a terminal. And nnn has the imgviu plugin for that!

export NNN_PLUG='v:imgviu'

Then, when you are on an image, use ; (the "start a plugin" key) then v (the key set in NNN_PLUG). Enjoy this pixel art of your images!

Icons

Since version 3.4, nnn can display icons. You just need... to compile nnn!

Key bindings

Type ? and you will see the keys you can use.

The wiki has a graphical map.

Want to change the bindings? Just change them in the source and compile nnn!

The end

Here is the whole configuration I currently use:

export NNN_OPENER=/home/user/.config/nnn/plugins/nuke
export NNN_PLUG='o:fzopen;v:imgviu;t:preview-tabbed'
export GUI=1
alias nnn="nnn -a -c"

I really enjoy nnn, it is really fast compared to ranger on my old computer.

Not having a configuration file is disturbing in the beginning, and maybe it is a force to make sure the configuration does not grow into a neverending list.

Here are a few links to go further: