Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Nnn – unorthodox terminal file manager (github.com/jarun)
123 points by apjana on Nov 17, 2020 | hide | past | favorite | 103 comments


@apjana since I have you here. (Feel free to gracefully decline to answer any of the following.) May I ask why are you not trying to leverage the assortment of useful tools you wrote with sizeable following to be some kind of side income? I didn't miss the paypal link on every repo, but I don't think that would make much without being a recurring payment and a little bit of blog posting.

This was partly inspired by the 'to spend more time with his kid than at a computer' quote.

a bit off topic: do you have a rough idea about the number of actual users, other than github stars?

I am not trying to doxx you or anything :D, just thinking about the dynamics of open source and my own inspirations. ----- Disclaimer: I don't any experience with what I am talking about.


> May I ask why are you not trying to leverage the assortment of useful tools you wrote with sizeable following to be some kind of side income?

I started contributing to open source because I learn a lot from it since my graduation days. I think of it as a payback to the community. Having said that - I do appreciate users donating now and then. :)

> This was partly inspired by the 'to spend more time with his kid than at a computer' quote.

My regular job is a demanding one. So I have to work smart to save time for my kid and family. Some of the utilities were written to help with that.

> Do you have a rough idea about the number of actual users, other than github stars?

Not really. But I know for sure even some orgs use some of my utilities.


Thanks for replying. I really need to start using smth like buku to manage all my tabs/bookmarks.

Hope you and your familly all the best.


Yes, it's very useful for people like me who live on bookmarks.

Thank you!


This is very exciting and planning to give it a try to see if it can finally replace my usage of midnight commander. I appreciate the clean aesthetics.

Please don't hide your feature list under a toggle though! Put it all the way at the top - I nearly missed it.


Thank you for the appreciation! The full feature list is not hidden, it's below because it got way too long (who would have thought?). The toggled one is a quick peek into some of the cool things users can do with nnn.


> No FPU usage (all integer maths, even for file size)

I wonder what is the significance of avoiding floating point math in a program that will spend most of its time waiting for user input.


You are looking for the benchmarks: https://github.com/jarun/nnn/pull/84


Why does this provide such a speed up on modern CPUs?



Don't know what the situation is like today, but not so long ago not all architectures supported floating point numbers. Math operations were emulated in software libraries, which was slow and buggy.


I get the sarcasm but probably a lot of that would depend on the calculation involved.


I never understood terminal file managers... If I want to find a file, I use find or fzf. If I want to list files in a directory, I can use tree or ls. If I want to move files around, cp and mv work great.

If I want something more rich or discoverable, I'll just move to a GUI, which handles this much better.


Try to think of it as an endless ls-cd loop with tons of automated functionality few keypresses away. Also, please try the type-to-nav mode in nnn.

Also, find/fzf etc. are useful as long as you are not on a slow disk and a mid-range Android device/the Pi. If you are saying you are OK with scanning the whole filesystem every time you are looking for something that can be anywhere under /, I simply don't prefer that.


If you are saying you are OK with scanning the whole filesystem every time you are looking for something that can be anywhere under /

You can specify a target directory from which to start the search.


Bookmarks you mean. Yes, in nnn you can jump to the bookmark from anywhere and then press `Alt-O` (my preferred key) to start the search.

But you know what, let me share a smarter workflow:

  find . -iname "*.mp3" -print0 | nnn -p -
Now you list all yours mp3 files in nnn, examine/play them and finally get to cherry-pick some and print them to stdout when you quit nnn.

BTW, you can also run the find within nnn and list in nnn.


I see what you did there


If you're looking for something that can be anywhere under /, then the target directory needs to be /.


Yes, that's what I intended to convey.


> endless cd-ls loop

Better to have "chpwd() { ls }" in your .zshrc as this executes ls after cd'ing to save up on your infinite amount of ls typing.


That'll print the list of files even in a populated directory like /usr/bin and leave me at the prompt with the last few files listed above. As soon as you want the list of files not to go away so you can control/manage/examine them, you are talking of a file manager.


Who would regularly cd into /usr/bin/?

If you only work inside messy folders with hundreds of files all the time, maybe it's time to tidy up.


There can be other frequented examples, say, ~/Pictures.


Might as well "head" the output by 10 lines or something then.


Yes, where there is a will, there is a way! :)


Find has a pretty poor API in my opinion. Replacing it with fd is a simply improvement similar to ripgrep over grep.

Separately, I have a bunch of keybindings to load sets of files into fzf for easy access. Things like modified files, files changed in current branch, branches modified in the past six weeks. All of these have make working for a large code base much easier for me with little downside except have to piece them together on a new machine.


I found switching to fd challenging. fd makes some of the options easy. But find and fd are not syntactically the same. I guess I didn't spend enough time with it.


No, you are probably right. My main usage of find is `find ./ -name "blah"` which with fd is simply `fd blah`. If you are doing more complex finds then it may very well not be a good replacement for all find usage.


nnn supports all of them BTW - find, grep, fd, ripgrep...


I just checked both fd and ripgrep and they both seem like wonderful tools. I've been using a very long and slow bash script for what ripgrep to make grep -R avoid my node_modules directory.

Being realtively new to Linux both these commands will be super helpful to me. Are there any other command line tools you will recommend?


> Separately, I have a bunch of keybindings to load sets of files into fzf for easy access.

Do you have your dotfiles available to share? That sounds really useful


I don't have dotfiles online, but many were inspired by this gist: https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f...

For other things like files changed in current branch I've just kludged together aliases: branch_files='git log --decorate --pretty=oneline --abbrev-commit --name-only --no-merges --first-parent main..HEAD | fpp'

(fpp extracts file paths from output)

If you use zsh it can also helpful to setup suffix aliases so just the filename is bound to an application. For instance `alias -s {rb,erb,rake,css,js}=vim`


Thanks for sharing!


I like using terminal file managers for quickly traversing many nested directories, where I'm not sure where I want to go. I can use it to browse around and hjkl is familiar as a vim user.

With ranger[0], I can even use it as an alternative to cd, which is often the most convenient (I usually want a terminal in the last directory I browsed to, not the place where I opened the file manager[1]).

I hope to find a way to use nnn similarly, but it (like ranger) doesn't seem to support this out of the box.

[0]: https://github.com/ranger/ranger

[1]: https://unix.stackexchange.com/questions/342064/ranger-cd-in...


> With ranger, I can even use it as an alternative to cd

cd on quit works in nnn as well... and many other file managers.


Thanks for pointing this out - here's the link, for anyone interested:

https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-...


> but it (like ranger) doesn't seem to support this out of the box

No utility can support cd-on-quit out of the box because a spawned process can't send the $PWD to the parent directly when it quits. It needs tweaks in your shell's rc file. nnn also needs the same instrumentation.


I use them because they fit better in my workflow. I use a tiling WM and vim bindings everywhere I can because keyboards hurt my hands less than mice. I use them just for discovery, if I know what I want mv / cp / find are better. tree doesn't work so well if you have a sub-directory with hundreds of object files, etc.


Yes, cd, ls, mv, cp etc. don't help much in unknown territory.


In my life I’ve occasionally used emacs dired-mode[0] to do medium-sized file operations; more than just 1 or 2 files, but not worth building a script w heuristics.

[0] https://www.emacswiki.org/emacs/DiredMode


The problem with emacs-based solutions is the speed.


Hasn’t been a problem for me for years. It seems to me that often this argument is based (directly or indirectly) from conditions 20 or more years ago. I think Emacs itself hasn’t changed much (it’s gotten better, but not fundamentally different), but the supporting environments (read: hardware) easily make for a usable experience. There are better poster children for bloat these days.


Can't counter that given I've last used emacs years back.


I suppose I've not tried it in any sort of extreme scenario, but it's not clear to me what dired would be slow at. Functions like copy-file are implemented in C.


My response was from from emacs perspective. Here's a memory usage comparison: https://github.com/jhallen/joes-sandbox/tree/master/editor-p...

Looks like emacs uses at least double the memory.


I guess, but I think somebody using dired would be using Emacs anyway, and dired is unlikely to be the straw that breaks the camel's back.


Completely agree.


They can be handy if you're in the middle of something else, and you need one without distraction.

I don't personally use them, but I live in emacs for many hours a day so I do use its integrated directory-manager (dired) to perform simple operations.


> They can be handy if you're in the middle of something else, and you need one without distraction.

Add a drop-down temrminal file manager to the mix, so you never lose your context. ;)


My main use nowadays is to select files. i.e. I have a folder with many files, and I need to cp or mv some of them elsewhere. If it's more than a handful tab completing them is a chore, so I run "mc".

A gui doesn't help, because usually I'm on a remote server somewhere (using SSH).


I think that workflow is available in almost any terminal file manager now.


Take a look at Ranger. Ranger gives you the ability to do things like bulk edit files within a vim editor. Try doing this on the cli with the same efficiency and speed. This is where a term file manager really begins to shine...


nnn has an in-built batch-renamer as well as a more powerful POSIX-compliant plugin to do that.

List of features: https://github.com/jarun/nnn#features


Sometimes a GUI is faster for me, especially when I'm not 100% sure where things are or there are many files to select.

A terminal file manager has a GUI that works everywhere, including over SSH sessions (OK, technically could use X forwarding, but it's slow).


> Sometimes a GUI is faster for me, especially when I'm not 100% sure where things are or there are many files to select.

nnn takes care of these already. I don't think you would see a difference once you get used to.


Exactly. I don't understand what these grant me in terms of flexibility and workflow that bash + shell scripts do ?

Can someone who uses these tools explain ?


If you have to cd/ls around a lot, it's simply faster once you get used to it.


If your scripts do all of the following, you are already using a file manager:

https://github.com/jarun/nnn#features


That doesn't really help - something like "POSIX-compliant, follows Linux kernel coding style" doesn't really indicate what it's useful for.

My question isn't snark. It's more like "what is the usecase and what advantages does it have over standard terminal workflows?"

FWIW: My main file manipulations I need to do are within vim when working on a project. I typically use nerdtree for this, but having a project that's consistent in my environment would be good.

I do other manipulations using standard tools like ls/rm/etc. what advantages does this have over those ?


I answered to a similar question in the same thread (in response to the comment you replied to). Please take a look if that clarifies.


As a vim user, I got a good analogies, why don't you use vim over ex mode. The same applies here.


I can't speak to any of the others but Midnight Commander is the best and best maintained of the two-panel (orthodox) file managers.


Fewer keystrokes.


Thanks for voicing what I've been feeling. I've just never got any kind of file browser in the terminal. As you said, there are better tools for browsing that require less investment in a partiuclar way of thinking.


Why do I want to invest in the particular way of thinking required to use GUI file browsers when I have a plethora of options in the terminal? (ranger, lf, mc, and nnn being the better know ones, but there are others too)


I tried nnn after I was dissatisfied with ranger's startup time.

nnn is much faster, but I was already used to ranger's keystrokes and I did not want to learn a new set of keystrokes.

Then learned about lf, a ranger clone written in go, which is much faster. That is what I use now.

It is possible that nnn is the fastest file manager out there.

You may also want to try Midnight commander, a timeless classic.


> I did not want to learn a new set of keystrokes.

You don't really need to learn too many new keystrokes for the set of functionality you get in ranger. Many of them are same too.


Thanks for the suggestion. That is my one gripe with Ranger. It can be sluggish at times...


Not sure but vifm never shows up in these type of posts but I find it a good alternative.

https://github.com/vifm/vifm


Yes, that's a good file manager too! Especially for people familiar with vim.


A note for anyone who is thinking of switching from ranger, to customize key bindings you need to recompile the application [0]. The developer is not interested in maintaining custom keybinding support. For more insight into the reasoning behind the current keybindings see this issue thread [1].

Also mentioned in this thread, lf a ranger clone written in go [2].

[0]: https://github.com/jarun/nnn/wiki/Advanced-use-cases#custom-...

[1]: https://github.com/jarun/nnn/issues/422

[2]: https://github.com/gokcehan/lf


The funny thing about nnn is that the maintainer is absurdly responsive to the point that whenever I didn't like something, rather than configuring it, I would complain and after some consensus from fellow complainers it would get changed in a commit which I immediately enjoyed since I use nnn-git from the AUR.

I feel like I configure nnn via github issues xD


That's correct, we don't tend to add dispensable features without multiple users asking for it. Of course, features you demand would mean the world to you, but from where I stand, a feature bloat is the last thing in my mind. And the funny thing is, some users find it reasonable.


I don't think I ever asked for features actually; it was usually keyboard shortcut tweaks and other minor changes like that. Although obviously not really configurable keys, I felt like it was an interesting experience.


OK, then let me tell you a story - if you see the `^` and `v` in the latest release, someone requested for those and I personally found them useful and added those on first request. A week later, someone else asked for a program option to disable those.

If you think maintaining a piece of software like nnn is easy, it's not. You can't make everyone happy.


Reminds me of this clasic: https://xkcd.com/1172/


Exactly!


Yes, that's the stand from the beginning and there are good reasons behind that. If you read the issue thread, we did spend a good amount of time discussing those keybinds and most users find them reasonable. Speaking of compiling, the only mandatory library dependency is ncurses and the users don't consider it a significant problem. For example, Arch Linux users install most software from source using formulas and so do Homebrew users. So the tools to build are already present on the system.

nnn also has an option to make the process simpler. Additional details - https://github.com/jarun/nnn/wiki/Advanced-use-cases#custom-...


This looks great! Looking forward to testing this. When I get my Raspberry Pi 400 :)


You'll enjoy it for sure!


Now I want to see the unorthodox git manager.


Have you ever played with Magit? It’s an emacs front end for git that is utterly amazing. Works great with evil-mode if you prefer vim bindings.


Not really unorthodox, but I have been really liking SublimeMerge on linux. I know MacOS is Win have a few nice GUI clients but non support linux.

https://www.sublimemerge.com/


GitKraken [1] has Linux .deb, .tar.gz, .rpm, and snap downloads. Free for basic use.

[1] https://www.gitkraken.com/download


For some reason I found it too clunky and slow on a machine that runs other electron apps just fine. I was also looking for something simple as I was not well versed in git at the time, and it was a bit bloated for me.


Cool! Thanks for sharing!



tig might be something like that: https://jonas.github.io/tig/


tig is awesome!


There are so many of them! GitHub, for example. ;)


Try ranger, even less orthodox, to get a MacOS like navigation into your directories from left to right (aka Miller columns), but with VI key bindings and lots of extra features:

https://en.wikipedia.org/wiki/Ranger_(file_manager)

https://wiki.archlinux.org/index.php/Ranger



I just tried using nnn and found it to work reasonable well. However, I could not figure out how to change the default editor to open vim in the same terminal.

Then I realized that I can accomplish this task already by running

vim .

It seems almost identical to nnn with the restriction that everything is opened vim.


Check out the config var `NNN_OPENER` and program option `-e`.


Thank you for the helpful reply. I was missing this option -e I added

alias nnn='nnn -e'

export VISUAL="gvim -v"

to my .bashrc and it really is much cleaner/nicer than using

vim .

so I think I will swtich to nnn


You are welcome!



NNN is a very poor choice of words as is a slang for something else, especially this month. Maybe change it to N3.


Please read the first sentence in the project readme.


I am having difficulty locating which is the first sentence you were referring to in the README.md, and what it has to do with the (what) slang.

nnn - Supercharge your productivity! Latest release Availability Travis Status CircleCI Status Privacy Awareness License icons and colors asciicast [Features] [Quickstart] [Plugins] [Documentation] nnn (n³) is a full-featured terminal file manager.


n³ The unorthodox terminal file manager. ;)


Ah, so you're definitely aware of the slang. Well, in that case what can I say except "good luck with the adoption".


Not until I posted my hard work in one of these public forums for people to use and benefit.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: