As I was re-configuring my web server today, I figured it would probably be best to install some kind of file browser (duh), because I kept forgetting where some of my files were placed. And so I found myself perplexed and unsure of what to use. On my personal computer I use lf from the AUR, but of course Debian doesn't have the AUR so I had to look for some kind of alternative. After I spent a little time looking for some kind of file browser for my web server, even though who really needs one nowadays, I come to have stumbled across nnn and it has just got better.
I would say that a majority of people know about ranger, however, given the fact that it was written in python (slowest programming language out there), it is way too slow! So I found a much lighter and faster option which is essentially the equivalent of ranger for browsing files on the terminal. It is extremely fast on the terminal, which is just what I needed for my web server. And besides that, my favorite part about it is that it doesn't use any additional config files, it only uses the environmental variables and that's it. By the way, these environmental variables can be set in your .profile
or wherever else you store your environmental variables. A lot of us are probably used to the traditional setup with either dotfiles or suckless-like config.h
which you are intended to recompile, thankfully nnn doesn't have this. Nevertheless, nnn is basically ranger without bloat and it has everything you need for file manipulation on the terminal. If you are currently using ranger for no specific use or functionality, then I'd suggest you make the switch over to nnn as soon as possible.
I'm aware that nnn doesn't provide all the functionality as that of ranger, but it definitely works great for me and on my web server. A while back when I used to run apache, I had ranger installed in case I would need it for something, however, the fact that it was so slow made me never want to use it. If you were to compare the startup times between ranger and nnn, you would really see the difference. Mind you though, there is no shame in using ranger, it's just that running it on a cheap VPS doesn't really work all too well.
I would also like to touch upon the usage of nnn, since it isn't so traditional like the other more common file browsers out there. So here are some key presses that you might want to remember:
- To navigate, you can use the arrow keys on your keyboard (for noobs) or even better you can use vim-keys.
j
will move you down andk
will move you up.h
will move you into the upper directory or the previous directory. Finally,l
will move you into a directory. Also,l
will open files but not text documents. By default it will open these files in xdg-open, so make sure that those are properly set (environmental variables). - In addition to opening files, you can only use
e
to edit text files, and again that opens whatever your default text editor is set to. - If you would just like to view a file, then you can press
p
to open it in a pager for viewing. - When moving files in nnn, you want to use
space
to select the file(s), then navigate to the directory that you want to move the file(s) into and pressV
. That will move the file(s) and delete it out of its old directory. To better remember this, there is a v in move. - To copy a file is not much different, press
space
to select the file(s), then navigate to your desired directory and pressP
. That will copy the file(s) and it will still leave it in its old directory. To better remember this, there is a p in copy. - For deleting files, again select the file(s) using
space
and then useX
to permanently delete it. - Another thing about copy and pasting, you can use
Y
to select the file(s), and then to view what's selected you can usey
. Thereafter you can paste, like before you can navigate to your desired directory and useP
to paste. This is very similar to using yy and pp in LaTeX. - You can use
/
for the search function to go through directories quite swiftly. A little handier feature is using their automatic directory selecting tool by pressingctrl-i
. To disable it, just hit the same key combo and that's that. - To rename files, use
ctrl-r
and you will be prompted to change the file/directory name. - Another nice feature, is renaming all files within a directory and this can be accomplished just by using
r
by itself. This command runsvidir
(you might need to install this). - If you are ever unsure of something or would like to learn more about the usage of the program, you can press
?
any time and that will pull up a list of commands that you can run. Likewise, you can typeman nnn
in the terminal and that'll also provide you with more information. - Lastly, if you were wondering what the numbers near the top left-corner represent, those are contexts or commonly referred to as tabs. You can switch to the second tab for example, by pressing the leader key and 2 (
`2
). The leader is just `. So press that and the number of the tab and that is how you can switch.
For those who are interested, here is the source code. And also if you are using Arch, this should come by default in their repos. If you really wanted to, I believe that you can go into the nnn.h
config file and change whatever you want to before you compile it. But there really is no need for that.