APC Australia

Manage your files



We’re hell bent on having you organise your files this month. So listen up. Nnn, or n cubed, bills itself as the fastest file manager ever written. It’s based on Noice, so the name is a recursive acronym for Nnn’s Not Noice.

Nnn takes things to the next level. It’s written in C, and aims to have as small a memory footprint as possible. As a result, it’s pretty minimal and won’t be to everyone’s tastes. Heck, it doesn’t even have a configurat­ion file, so if you want to change things you can do so through environmen­t variables, plugins and command line switches.

But let’s not get ahead of ourselves. You can install nnn in Ubuntu with:

$ sudo apt install nnn but you’ll get a slightly older version (3.0 if you’re using 20.04, as opposed to the current 3.2). If you want the latest and greatest you’ll find RPMs and DEBs in the releases section of the project’s GitHub at https://github.com/ jarun/nnn and you may as well just install that over the top of the one in the Ubuntu repos. The dependenci­es won’t change – all it needs is the C library and Ncurses. Check the wiki to see some of the other tools it can integrate with.

Firing it up you’ll see that it is indeed fast, and it is indeed somewhat spartan. There’s only a single panel, which you can scroll with the cursors or Vim (or Emacs) navigation. Use the left arrow or backspace to go to the parent directory. If you’re using nnn in a fully fledged desktop environmen­t then opening files (either with the right arrow or enter) will respect your file associatio­ns there, via the xdg-open helper.

Here are a few handy shortcut keys to get you started, you’ll find the rest by pressing ?:

~ switch to your home directory @ switch to directory you launched nnn from - switch to last visited directory . show/hide dotfiles ! spawn a shell in the current directory

Nnn supports up to four contexts, which are like tabs with memory (you can set them up to remember settings and locations). Those are the numbers in the corner, the current context (1 if you’ve just opened nnn) has its number highlighte­d with a blue background, and other contexts in use are underlined. Switch contexts using keys 1 through 4, you’ll see if you navigate somewhere in context 1, then switch to context 2 and navigate to a different place, then you can hop back and forth using the 1 and 2 keys. You can quit a context by pressing q, which will take you to the previous active context. Quitting all the contexts is the same as exiting the program, but you can also do that with a capital Q.

If you wanted to copy files from one directory to another select them with space (or Ctrl-J if you want to be difficult), navigate to the destinatio­n (contexts are handy here) and hit p. To move them instead, use v.

To delete them (careful!) press x. You can rename individual files with Ctrl-R. If you select a bunch of them, then press r, then s (for selection), this will open a text file listing their names from whence you can rename them all at once. If no files are selected, then you can rename everything in the current directory this way.

Bring the panes

Convention­al and Orthodox file managers are all about multiple panes, or panels or columns or whatever you want to call them.

Midnight Commander has two, Ranger has (by default) three and 4Pane has seven (just checking you’re paying attention). Nnn has only one. And that’s part of its minimal design. However, if you want to run two (or more) instances side by a terminal multiplexe­r, then it will happily accommodat­e that. The simplest way is with dvtm, which we can install and invoke with:

$ sudo apt install dvtm

$ dvtm nnn nnn

What’s really magic about this is that the two instances share buffers and selections and wotnot. You can’t recreate traditiona­l file manager functional­ity (where you navigate directorie­s with the left pane and files with the right), but you can do other cool stuff. You can switch between the two dvtm “windows” using the mouse, or using the modifier key (Mod, which defaults to Ctrl-G) and then the 1 and 2 keys.

The current window has its topbar highlighte­d in blue. Start a new window with Mod-c and it will tile nicely into the existing arrangemen­t, giving you a handy terminal. You can shrink the current window with Mod-h and enlarge it with Mod-l. Just like a glorious tiling window manager. Windows can be closed with Mod-x.

A number of plugins (see box, opposite) can use a multiplexe­r too. For example the preview-tui plugin (see https://github.com/ jarun/nnn/blob/master/ plugins/preview-tui) can use tmux or kitty to display in line previews. With a bit of scripting magic (check the wiki) you can use this to obtain live previews of files (if the hot key method described below is too taxing). Alternativ­ely tabbed from Suckless tools can be used to get live previews of videos, images and PDFs via the preview-tabbed plugin.

Multimedia files will open in whatever your desktop tells them to, if you’re using a proper desktop. If not, you can set default MIME types with the xdg-mime command. You’ll want to install some lightweigh­t viewers, such as sxiv (for images), zathura (for PDFs) and mpv (for videos). To edit a text file (with whatever’s set in the $EDITOR variable, or else Vim) navigate to it and press e.

As in Ranger, there’s no built-in search functional­ity. But there is very quick filtering that’s available from the / key. So if you know where you’re going, hit / and type the first few letters of the directory, navigate with the cursors, then rinse, lather and repeat. You can toggle filtering by regular expression­s by hitting / again. But that’s a can of worms we probably shouldn’t open up here.

 ??  ?? A logo involving both chess and mathematic­al notation? Shut up and take… oh, it’s free.
A logo involving both chess and mathematic­al notation? Shut up and take… oh, it’s free.
 ??  ?? The console in action.
The console in action.
 ??  ?? A preview of this very document, courtesy of some weird, inceptionl­ike terminal multiplexi­ng.
A preview of this very document, courtesy of some weird, inceptionl­ike terminal multiplexi­ng.

Newspapers in English

Newspapers from Australia