nnn

nnn (also stylized as n³) is a portable terminal file manager written in C. It is easily extensible via its flat text plugin system where you can add your own language-agnostic scripts alongside already available plugins, including a (neo)vim plugin. nnn features native archiving/decompression to and from commonly installed formats such as xz, disk usage analysis and a fuzzy app launcher, a batch file renamer and a file picker through its plugin architecture. nnn supports instant search-as-you-type with regex (or simple string) filters and a navigate-as-you-type mode for continuous navigation in filter mode with directory auto-select. Also supported are contexts, bookmarks, multiple sorting options, SSHFS, batch operations on selections (a group of selected files) and a lot more.

Despite its capabilities, nnn is designed to be easy to use and is configured by way of environment variables without the use of a configuration file.

Installation

nnn can be installed with the nnn package.

Usage

nnn can be controlled with the vim-like characters hjkl or the arrow keys. Do not memorize keys. Arrows, and suffice. Press ? for help on keyboard shortcuts anytime.

Configuration

nnn is configured via environment variables, typically by appending them to . For detailed information on these settings see the man page as well as the nnn wiki.

Here is an example configuration you can add to your :

~/.bashrc
export NNN_BMS='d:~/Documents;u:/home/user/Cam Uploads;D:~/Downloads/'
export NNN_SSHFS="sshfs -o follow_symlinks"        # make sshfs follow symlinks on the remote
export NNN_COLORS="2136"                           # use a different color for each context
export NNN_TRASH=1                                 # trash (needs trash-cli) instead of delete

One of the more useful settings is the variable which lets you choose shortcuts to quickly jump to your bookmarked directories. They are reached with followed by one of the letters that you have specified. In the example configuration hitting the keys would result in nnn jumping into . But all of these are optional, nnn will consistently behave the same on all of your machines.

Get selected files in terminal

To get a list of the files you have selected in nnn one could create the following alias:

which later could be used to pipe the selected files to other tools.

Indicate depth level within nnn shells

If you use to spawn a shell in the current directory, it could be nice to add:

~/.bashrc
[ -n "$NNNLVL" ] && PS1="N$NNNLVL $PS1"

To have your prompt indicate that you are within a shell that will return you to nnn when you are done.

This together with #cd on quit (Ctrl-G) becomes a powerful combination.

cd on quit (Ctrl-G)

Add the following to your /.zshrc And run the command instead of (more precisely the n bash function).

Also see the nnn wiki.

Add your own plugins

You can run your own plugins by putting them in . For example you could create a executable shell script

And then trigger it by hitting and selecting which will conveniently show the git log of changes to the particular file along with the code for a quick and easy review.

gollark: ***p i c a l c u l u s***
gollark: Garbage collection, sure, that might be useful.
gollark: You won't use the green threads half the time and libraries exist.
gollark: And?
gollark: ©++ not so much.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.