298 points · by max_sendfeld · 8y ago · 193 comments
Posting as a Show HN something you didn't create is effectively taking credit for someone else's work, so please don't do that!
Please read the rules: https://news.ycombinator.com/showhn.html.
I am grateful OP posted it. Thanks for fixing the title.
HOWEVER, there is a specific use-case - renaming a bunch of files in a directory - where I do use a "file manager" and that file manager is 'vimv'.[1]
vimv is a very simple tool - you run vimv in a directory and suddenly the vi editor opens up with the contents of that directory. You then use the vi editor to edit the filenames any way you like. Upon :wq, the files in that directory are renamed.
Very useful - and in many cases, much faster than crafting a sed/awk one liner to do the renaming (especially if some of the renaming is arbitrary or random).
And as someone else mentioned nnn integrates well with vidir which does exactly what you describe. In most distros it's installable through moreutils [2]. vidir uses $EDITOR , so it works with pretty much anything.
Coming to your use-cases:
> use the Finder to browse ... which gives me preview, etc.
Preview is not available, and there are other emerging file managers which agree that preview is redundant for a fast workflow. People may not want to have a jumpy experience to preview a 8K res image all the time. And that image can be compromising as well. It's easy to say make it optional, but it adds tons of deps on other tools which `nnn` doesn't want to bear. It integrates with sxiv, so you can open a dir of images in sxiv and browse at will.
> renaming a bunch of files in a directory
`nnn` supports in-place renames and it integrates with `vidir`, which allows you to batch rename in vi, exactly the same thing which your favourite utility does. I mentioned this earlier but it got lost among other responses. Probably you haven't read the features section or given `nnn` a try which is why you missed `vidir`. I recommend at least a quick at the features list. If you want to try it, `nnn` is available on Homebrew.
I had no idea you can do that, thank you for sharing!
I am not talking about some rarely used keys/functions, but the problem lies at the very core of the experience: the simple hjkl, vim-style navigation.
You see, as in vim, k/j ('up'/'down') obviously move up/down in the list of dirs/files. h ('left') moves up the directory hierarchy ('Parent dir' as nnn's help aptly describes the function.) Of course, now l ('right') moves down the directory hierarchy: IF you are sitting with the highlight on a DIRECTORY entry, obviously if moves down into that directory.
But here is the kicker: what if you have as your current highlight something OTHER than a directory, that is a FILE ?
It OPENS the file. (The open operation is done through xdg-open, so whatever that is configured to recognize) If xdg-open is not configured defensively, in the case when the file is executable it runs the program. Or if the file has some associated program, it is launched with the file as an argument. (this was happening even on my machine, and I have a relatively conservative xdg-open config) At the minimum it launches an editor, opening the file in read/WRITE. In nnn's help, listed among the keys activating this 'Open file/enter dir' is the <Return> key, in addition to the usual move right keys (so 'l' and right arrow). A clear expression that in the authors intention those keys have equivalent functionality.
So imagine you're browsing around the file system as fast as your fingers and eyes allow (after, that's the beauty of the fast text/ncurses interfaces, yes?). You just want to examine stuff, look at files, poke into configurations, maybe for a archive you just downloaded. Archive that might or might not have executable stuff and/or potentially harmful things. You've located the dir path you want to go into, you dive in and before you realize you need to hit the brakes on that 'l' key, you end up moveing RIGHT on SOMETHING (it happened so fast you're not even sure what it was), and that SOMETHING was executed/loaded, now some application is opened, and on top of that you were continuing to type so that application receives your keys and does who-knows-what (well, depending on what was launched).
WTF ??? The first time it happened, I could not believe such a UI design decision: mixing NAVIGATION and OPEN operations on the SAME KEY. OPEN is a sensitive, potentially disruptive operation: there SHOULD be some minimal friction provided in the interface before one is allowed to proceed.
It moved this nnn from potentially one my favorite tools, into a totally love/hate relationship. Yes, "love" because indeed it does some things well. But the mistake of this RIGHT/OPEN snafu is enough to more than cancel any other qualities.
But focusing back on keyboard operation... It is true that many text based file managers do this 'open file on right navigation move'. In my opinion that doesn't make it right: I personally consider a bad thing that can lead to startling, unnecessary and potentially sensitive application launches; a separation between movement (hjkl, arrows) and opening (obvious choice here, <Return>) is a sensible design.
Another point of view: the unwanted file-open-by-mistake situations are a form of involuntary file previews. As nnn's own 'design considerations' state [0], previews are to be avoided: "previewing ... is a wastage", potential "slow/faulty ... access makes the experience very painful" and "Users should see only what they explicitly want to see".
Lastly, there is an important aspect that mitigates the problem for 'most file managers': customization.
Here's a quick glance at the players in this text-fm arena:
- ranger and vifm, the larger managers: a cursory look in their help/configs hints that they can be heavily customized - out of the box ranger displays a preview of the selected file; that acts a big visual hint that you don't need to 'navigate' further; however I agree that default previews are bad - ranger and vifm remember the position along the path, so you don't get shunted moving back down - noice has about the same behavior as nnn (nnn was forked from it), but at least it has a standard suckless style config.h header allowing customization by recompiling - speaking of suckless style, a last resort solution is to do just that with nnn, making your own fork: its header largely keeps the structure of the original
And here are examples that work more along the lines I prefer:
- rover has the best behavior IMO: it can be similarly configured using environment variables, but by default it uses hjkl simply for navigation and NOTHING ELSE; it has separate, dedicated keys for open, preview or other things - midnight commander has the same separation: arrows (actually just up/down) strictly for navigation (in local dir ONLY, no less); explicit directory navigation and opening with <Return>; there is no implicit 'file open'
[0] https://github.com/jarun/nnn/wiki/nnn-design-considerations
Oh, don't worry! I can drop an env var to disable the right-> open file thing.
However, all dirs are listed on top separately and in a clearly different color. How often are you ending up pressing the right on a file? I am surprised because `nnn` has many users and no one ever mentioned this as an issue before!
> dirs ... in a clearly different color
Hey, unless you launch nnn -c 10 I guess ? ;-) Or nnn -l -c 10 and there is even less to distinguish them other than that slash.
> How often are you
Maybe it's the file hierarchy on my machine, but I end up a lot, somehow. One easy example is a deeper path ending with, say, an .odt or .xcf as first entry in the last, leaf directory, e.g. a/b/c/d/e/bigfile.xcf; oops! one extra l and the gimp or libre office start up (for fun, try that on a RPi ;-) As someone else mentioned in the discussion, the intuition is that going up and down the SAME path will take you to the SAME positions in each directory: the example given was "/a/b/c/d -> /a/b/c -> /a/b -> /a/b/c -> /a/b/c/d;". That is not the case in noice/nnn and it can trip you off. To make it more clear, consider this tree:
tmp/a/1b/huge.odt
tmp/a/2b/c/some_other_stuff
You are inside 'c'; you quickly go up 3 levels ('hhh') to glance at the content of 'tmp'; then you go back down 3 levels by quickly tapping 'lll', intuitively expecting to end up in the same place, inside 'c'; instead you'll go in 'a', but then in '1b' on the 'huge.odt' file , then the 3rd l launches libre office...> many users and no one ever mentioned
selection bias or how do you call this effect ? People that are bothered by this simply moved away and didn't mention a thing ?
Anyway, thanks again.
> nnn vs. ncdu memory usage in disk usage analyzer mode (400K files on disk):
I assume that's because nnn isn't keeping the entire directory structure in memory, which means that browsing to a subdirectory involves rescanning the entire directory. That's a fair trade-off, but an unfair comparison.
1. https://vifm.info/ - I'm surprised this hasn't been mentioned yet in this thread.
Please let us know what you like in vifm which isn't available in `nnn` and we will consider the features. However, I must say the last thing we want to see in `nnn` is feature bloat. You can extend it as you wish through scripts which `nnn` supports in any number.
No, `nnn` scans the complete dir tree otherwise du won't work. It rescans because data on disks keep changing e.g. on our server where 17 people run VMs. It can be easily changed to static but the rescan is very fast and users specifically asked for it. The memory usage is less because `nnn` uses much less memory for all operations in general.
nnn is not keeping information about 400K files in memory in that benchmark. As a result, the rescan is necessary when changing directory. The rescan may be fast in many cases and in some cases it may even be what you'd want, but I can also name many cases where you certainly won't want it (large NFS mounts being one example).
Sorry for the pedantry. I spent a fair amount of time optimizing ncdu's memory usage, so I tend to have an opinion on this topic. :)
Coming to memory usage, if you store the sizes of every file you need 400K * 8 bytes = ~3 MB.
Now `ncdu` uses ~60 MB and `nnn` uses ~3.5 MB. How do you justify that huge gap?
> but you're not being very honest with your claims
No, I am completely honest within the limits of my technical understanding. Your tool uses 57 MB extra which would be considerable on a Raspberry Pi model B. To an end user, it's not important how a tool shows the du of `/`, what's important is - is the tool reasonable or not? I don't know how `ncdu` manages the memory within, I took a snapshot of the memory usage at `/`.
In fact, now I have questions about your very first line beginning with `This looks incredibly cool` and then the comparisons of it with different utilities in negative light. (I must be a fool realizing it now, I should have seen it coming.)
- split screen (files left, file contents on the right) - customise file viewers - quick file search - customise key-bindings
Autojump makes it easy to quickly jump into any directory I've visited and then I can open my editor or Finder (file explorer) from there. Would be great if I can be inside nnn and jump to directories using autojump.
fd is very useful when I want to just directly open a file. I might be in a project's root directory and I'd want to edit a file a few levels nested. Currently I either use fd to locate the path of the file, and then copy paste it into the shell. If `fd` is combined with nnn, I can type in a few letters of the file I expect, and jump to its parent directory, with the file highlighted.
Is this workflow possible in nnn, or can it be written using its scripting?
fd: `nnn` integrates seamlessly with fzy (another blazing fast C utility).
And when you need to do a more complicated operation you're looking at a shell oneliner vs. multiple (possibly repetitive) manual steps in the UI.
If simple copying of files made up a great deal of my daily work, I'd certainly use a file manager (if I couldn't write a script to do it).
Any comparison between the two systems should stem from there: you’ve only offered half of it.
Eg getting a remote virtual disk set up in OSX’s finder is much easier than on terminal, without googling/general research, for a one-off drive. Getting 50 such disks up and going is far easier on terminal. (CLI has a better O(), but worse constant factor.)
Once the GUI reaches hundreds of actions it's no longer easy to find the functionality you're looking for.
On CLI eg I don’t remember the mkfs command for a file system, I type mkfs and hit tab twice.
It could be better though, of course.
Some time I did a survey for a neat a nice terminal fm. Trying a lot of different kinds I ended up with vifm.
Copying multiple files regularly I recommend using Python Fabric.
Always miss it. But never had the time to write it myself.
Disclaimer: I wrote it.
One super awesome Dired feature is C-x C-q to edit a folder like a file (all Emacs commands work here, like macros which are easier & faster to get right than most shell commands). To save your changes after editing, press C-c C-c.
For me the best part of dired is "do-what-i-mean" mode, dired-dwim. You basically get the output of `ls -la` and edit it as a text file. When you save, dired figures out changed names/permission bits/etc and does what you mean to those files.
Anyway, if you run emacs as a server, you can connect to it with emacsclient in less than a second.
Even starting emacs from scratch can take less than a second, if your config is small enough or optimized enough.
Spacefm does not have any of the above issues, which is why I am currently using it.
Will look into spacefm though.
> Previewing large files on selection is a wastage of processing power and time. A slow/faulty disk or over the network access makes the experience very painful.
You only need the first lines of the file, not the whole file, so this argument is not valid.
> It's also a risk to privacy and confidentiality. Users should see only what they explicitly want to see.
Not valid if preview is off by default. A hotkey could toggle preview mode.
Yes, you can open each file in a pager. Exit the pager, go to the next file and repeat. That is slow and painful. Being able to browse a code repository with file preview is the main reason I will probably not use this and stick with ranger. It's a deal breaker for me.
I really like that it's fast (I've tried using ranger on the USB Armory – it was very slow), and if preview was added as an option I would seriously reconsider.
[1]: https://github.com/jarun/nnn/wiki/nnn-design-considerations
Volkov Commander is written in assembler, binary has 32KB with zero deps, memory requirements far bellow 1MB. It has better UI and more features.
> better UI
I doubt that from the screenshots. But it's a personal preference.
- I needed something that _performs_ on the Pi which I was setting up as a _media player_ for my 3-yr old. - `ranger` wasn't an option because of slow python deps and I found ranger's changing/shifting panes very confusing. Please don't get me wrong here, I have several popular utilities in python. But when it comes to low-power, low-freq devices, the performance of interpreted or scripting languages is questionable.
`nnn` also has the `du` and `navigate-as-you-type` modes which aren't readily available in `ranger` (AFAIK; I don't use it). Then you get to copy (un)quoted file path(s) even without X, `vidir` integration, terminal locker support and finally, all the painstaking optimization.
The binary size is ~60KB (much lesser than the C source file that generates it). The requirements are minimal too - a c (say, musl) and a curses library.
Copying file path(s) between two instances of `nnn` works seamlessly (with or without clipboard).
I think the philosophy behind `ranger` and `nnn` are different and they were written to cater to different use-cases and a different audience at the very beginning. I had to write `nnn` on my desktop and at some point I noticed it works like a charm with my drop-down terminator session (I never lose any context anymore) so it became a desktop software.
Also `nnn` is not a feature by feature replacement for ranger. The last thing we want is a feature bloat. And we are very open to useful feature requests. Let us know if you are missing something.
Was it an intentional design choice to make "l" put you back on the first entry in the directory? Why?
/a/b/c/d -> /a/b/c -> /a/b -> /a/b/c -> /a/b/c/d
However, if you instead go into `/a/b/x` after the first two steps, the "forward history" would be lost.I must admit this is the first time I am hearing it's a problem. Probably because of the abundance of other navigation options available in `nnn`.
In addition, last night I added a vim plugin to use `nnn` as a file picker within vim.
It is the file manager many will compare against. I would suggest you request volunteers to put a comparison page for it. That alone will give you ideas on features you may want to add.
EDIT: One nice thing that mc has is that it lets you open a remote shell via ssh. I use that a lot (I find sc syntax a big pain) so I'd miss that a lot in nnn. Sorry if that feature is included and I failed to spot it.
Don't be, it's not in yet. It's on the ToDo list. I would really appreciate a PR.
However, I do not see several `nnn` features in mc as well:
- left, right arrows don't work
- relies heavily on mouse (menu driven), `nnn` doesn't need the mouse
- couldn't open a text file without extension
- filter workflow needs more key/mouse presses
- no du mode,
- no navigate-as-you-type
- no terminal locker
- no vim plugin
- no shortcuts like `-`/`&`/`~`
- no pin and visit dir,
- no media info
- no cd on exit
I might have missed certain things due to my lack of familiarity with mc.
-- Arrow keys work in the menus- press F9 to bring them down, then you can navigate around them with the arrow keys. In the main view, tab moves you from one pane ("window") to the other.
-- I don't think you can use the mouse in mc. It's text based. The menus are all operated by key presses.
-- I can open a text file without extension, on the setup above. I navigate to the file, then press F3 and it opens (in the mc file viewer which I don't generally use).
-- If I understand navigate-as-you-type correctly, yes, mc doesn't have that.
-- Yes, I don't think there's a vim plugin.
-- (No shortcuts) Well, the shortucts are all in the function keys. Also, after F9 each menu item has its own shortcut (its first letter, which is highlighted).
-- (No pin & visit dir) There's the possibility to bookmark paths. Is that what you mean?
-- (No media info) I think you're right about that.
-- cd on exit is configurable; e.g. instructions:
https://ptspts.blogspot.com/2010/01/how-to-make-midnight-commander-exit-to.html
-- Sorry- I don't know what "filter workflow" and "du mode" are and I'm not sure what you mean by terminal locker.mc's been around for a while. It's a good piece of software. I think I might have been a bit unfair asking for a comparison, after all nnn is not an Orthodox File Manager, so it occupies a completely different space than mc.
Apologies again. I didn't mean to make you defend your work, and I didn't mean to attack it.
One of the important goals behind `nnn`: extremely smooth workflows that don't get in your way.
Alternatively, could you please link to details about the comparison?
wenderen is indicating that the question you raise is addressed on the nnn Github page itself: https://github.com/jarun/nnn#performance
https://www.urbandictionary.com/define.php?term=tfa
Aside: a quick shortcut url for the free dictionary;
[F6]
tfd.com/word
> 2018-11-15 09:44 167.8M* Krita-4.1.5-x86_64.AppImage*I think it might be open(1): https://man.openbsd.org/file.1
same as in iOS. But i need the confirmation before making the change. Please raise an issue in the project page for the same.
Konqueror and w3m are both web-aware local file managers.
I see you vouching around for alternatives in every comment thread here. No issues. But please explain what you are seeing in other utilities that's missing in `nnn`? I would be repeating myself, but we are very open to reasonable feature requests.
Sorry, but my comments were invincible for long time than suddenly appeared. Thought it was something wrong then all comments was visible. Hard to know if you don’t know HN comment system.