jarun/nnn

ToDo list

Closed this issue ยท 46 comments

jarun commented

Rolled from #137.

Ready for next release (master-only)

Proposed and completed features

  • draw help screen in a scrollable window/pad
  • support command completion with libreadline
  • support soft delete to reclycle bin
  • vertical split pane (discussion required)
  • compile with PDCurses
  • make libreadline an optional dep
  • use nnn as a file picker with picker.sh
  • user-contributed scripts repository
  • substring search for filters (option -s)
  • version sort (option -n)
  • disk usage calculation abort with ^C
  • create sym/hard link(s) to files in selection
  • archiving of selection
  • show dir symlinks along with dirs on top
  • key N (1 <= N <= 4) to switch to context N
  • bring back NNN_OPENER to specify file opener
  • env var NNN_NOTE and keybind ^N for quick notes
  • handle multiple arguments in VISUAL/EDITOR
  • show the current directory being scanned in du mode
  • select all files
  • use libreadline for command prompt
  • reduce delay on Esc press
  • config option to avoid unexpected behaviour on 0-byte file open (see #187)
  • support custom opener (e.g. mimeopen)
  • run a command (or launch an application)
  • a new demo video (see #167) (thanks @Kallinteris-Andreas)
  • choose script to run from a script directory (see #127)
  • shortcut to run current file as script
  • support a combined set of arguments to $EDITOR, $PAGER and $SHELL
  • remote connection and file transfers (using lftp)
  • per-context directory color
  • support for Cygwin env
  • offer to fore file removal
  • support selection across directories and contexts
  • parse EDITOR or VISUAL for options when NNN_USE_EDITOR is set
  • option to disable file open on navigation (Right Arrow and l keys)
  • vim plugin to use nnn as a file picker within vim
  • retire nlay (no more used by nnn)
  • integrate static analysis on Travis
  • list currently copied files
  • option to disable directory auto-select
  • use $TMPDIR if available
  • support terminal locking on OS X (bashlock) and BSD (lock)
  • support patool
  • run any number of scripts
  • prefer VISUAL over EDITOR
  • add a keybind to run a custom script (see #79)
  • integer get_coolsize() (thanks @arsv)
  • batch rename, move, delete files with vidir integration
  • copy file paths when X is unavailable
  • support copying multiple file names to copier
  • add open with... shortcut
  • add option to open bookmark directly
  • optimize memory usage and algorithms for file name handling
  • list and extract archives
  • show current selection number along with total entries in dir
  • support NNN_NOWAIT to unblock nnn (DE specific)
  • file and directory creation
  • change to light mode if number of cols < 35
  • in-place file rename
  • watch out for current dir changes (if not in filter or du mode)
  • pin and jump to a directory
  • show vol capacity and vol free in help
  • option to use exiftool instead of mediainfo
  • option to show dirs in custom color (default: enabled in blue)
  • show dir content size and number of files in du mode
  • support bookmarks string
  • add option to support opening text files in EDITOR
  • use xdg-open on Linux and open(1) on OS X as desktop opener
  • support multiple apps in nlay
  • use vlock as default terminal screensaver
  • navigate-as-you-type mode
  • subtree search (using gnome-search-tool or catfish)
  • support custom nlay
  • search-as-you-type at filter prompt
  • RPM packages for RHEL/CentOS (thanks @fennm)
  • support cd ..... (with . as PWD, stops at /) (feature removed)
  • jump to initial directory (where nnn was started)
  • nlay - a shell script for actions like open desktop search utility, run screensaver
  • show file details, mediainfo output, help in less
  • show media information (needs mediainfo)
  • use Q to quit to current dir (needs external shell integration)
  • use ^Q to quit (even from filter mode)
  • UTF-8 support
  • add option to start in disk usage analyzer mode
  • open current dir in desktop file manager
  • disk usage analyzer more
  • show unprivileged free blocks in du mode
  • shortcut - to jump to last directory
  • resolve ~ (HOME) at chdir prompt (feature removed)
  • option to show complete stats of just the current entry (name, file type, human readable permission string, byte size... all lstat() details)
  • update noice man page
  • sort entries by size
  • support file path copier script (NNN_COPIER)
  • support detail view (default)
    • file type
    • modification time
    • human-readable file size
    • current item in reverse video
    • full name of currently selected file in bottom "bar"
  • roll navigation with Up and Down at the first and last entries
  • remove restriction on visiting parent dir when opened with a relative dir path
  • case insensitive alphabetic content listing
  • generate optimized binary
  • show total number of files in du mode (apparently it has to be counted in nftw callback, with adjustments like file type check, hardlink check, which means unreasonable overhead)
  • threaded/multicore nftw(3) (overkill, we are already very fast)
  • use scandir instead of readdir (we are using custom alphanum sort, see 6912912)
  • modify packagecore.yml and probably Makefile to generate OpenSUSE Leap package

Anything else which would add value (please discuss in this thread)

Here is a compact version of nnn config:

Go up/down/in/out/top/bottom            k/j/l/h/g/G
Scroll up/down                          Ctrl-u/Ctrl-d
Go to home/previous/start dir           ~/-/&
Filter entries                          /
Toggle nav-as-you-type mode             Ctrl-t
Pin dir/Go to pinned dir                b/Ctrl-b
Go to context #/next                    {1-4}/Tab
Quit context/nnn/nnn and cd             q/Ctrl-q/Ctrl-g
.......................................................
Toggle show hidden entries              .
Toggle du in allocated/apparent size    Ctrl-j/S
Toggle sort by size/modification time   s/t
Show entry details                      D
Show brief/full media info              m/M
.......................................................
Create file/dir/links to selection      n
Rename entry/all entries                Ctrl-r/r
Toggle multi-selection mode             Ctrl-y
Select entry/all entries                Space/Y
List current selection                  y
Copy/move selection                     P/V
Delete entry/selection                  Ctrl-x/X
Extract/create/list archive             Ctrl-f/f/F
Open file in EDITOR/PAGER               e/p
Open file with...                       Ctrl-o
Execute file                            C
Run custom script                       R
Spawn SHELL in dir                      !
Clear/exit prompt                       Ctrl-l/Ctrl-[
Show help and volume free/total space   ?

I think archiving should apply to selection, and navigating with <h,j,k,l> instead of arrows should be possible after filtering a directory listing and hitting Enter. Right now, I use Ctrl-u after filtering with / before I can use <h,j,k,l>. There also seems to be a strange timing issue when a directory listing is filtered, but it happens only at the first time whereas subsequent filters in the same directory seem to be alright: I go in videos dir and type /2017, press <down> arrow once, and wait on the entry for about a second, then the list automatically returns to the unfiltered state while the selected entry is preserved.

jarun commented

Simply awesome! I had been looking for a concise listing to save memory. ๐Ÿ‘ Many thanks!

I think archiving should apply to selection

The problem is the archiver is third party utility and not each one follows the same syntax. And then passing a variable list to exec() is trouble. So the use case now we have is to select the files, copy/move them to a dir and archive that dir.

Right now, I use Ctrl-u after filtering with / before I can use <h,j,k,l>

Instead of Ctrl-U you can press Esc to escape the filter prompt.

it happens only at the first time

I will check this. I can reproduce it.

jarun commented

I think some entries are missing e.g., ^K. Also, now I am myself finding it difficult to figure out a key from the list. Everything seems too close for comfort. :(

jarun commented

The 3rd issue should be fixed at commit 81318f9.

The 3rd issue should be fixed at commit 81318f9.

Yes!

So the use case now we have is to select the files, copy/move them to a dir and archive that dir.

This does the job just as good, thanks.

I think some entries are missing e.g., ^K. Also, now I am myself finding it difficult to figure out a key from the list. Everything seems too close for comfort. :(

Yeah, I omitted four shortcuts, picked only one when there are alternatives, and used my usual dense notation; easier for me to commit to memory this way, but bad for documentation :] I just put it here so that maybe some other people benefit.

Instead of Ctrl-U you can press Esc to escape the filter prompt.

When I press Esc at the filter prompt, the filtered list is lost, i.e. the list goes back to the unfiltered state. I think after typing /pattern at the filter prompt, pressing Enter should go back to navigation so that <h,j,k,l> can be used. If I'm not mistaken, v1.6 was working like that.

jarun commented

pressing Enter should go back

I might be missing something... pressing Enter always opened the file or dir... even in filter mode.

Just checked, and indeed Enter opens the entry in v1.6; I remembered its behaviour was exiting the filter prompt because the entries I tried in the past were all files and there wasn't programs associated with their mimetypes on that system. Now that aside, <h,j,k,l> navigation in a filtered list should be possible I think. Right now I can only use arrows, or Ctrl-u to leave the filter prompt before <h,j,k,l> navigation works, because Esc cancels filter.

jarun commented

When you press h/j/k/l that becomes a part of the filter string. So pressing any of up/down arrow is the way to do this.

Alright then. Although Ctrl-u is a bit of a hack, there is an alternative to arrows that is closer to the home row. Thanks.

jarun commented

Yes, the keyboards/keypads differ among form factors so it's really a difficult call to favour one against the other. I generally try to keep things easier for the Termux users on Hacker's keyboard (I am one of them). For regular keyboard users, life is much simpler.

jarun commented

BTW, I have made the help a little more concise now without sacrificing visibility... space is the separator now and I could reduce a column of text.

Hacker's keyboard

I understand. If only people could stay away from "smart" mobile devices. But a lot of water under the bridge since 1874 for qwerty/hjkl...

BTW, I have made the help a little more concise now without sacrificing visibility... space is the separator now and I could reduce a column of text.

New config has the visible advantage of looking the same. It's just that a more concise functional grouping seem to always help me for some reason.

Thanks again for this smooth fm!

jarun commented

@lawnowner archive selection is available at commit d9977c5.

Any chance of seeing a Windows variant? There are some locations where I'm required to use Windows, and of course I use Vim for convenience. I'd like to switch to nnn, but for it to only be available part of the time is a hurdle.

jarun commented

You can use nnn on Cygwin and Linux subsystem for Windows.

There is an item to compile nnn with PDcurses for native support. Unfortunately I don't own a Windows box.

You can use nnn on Cygwin and Linux subsystem for Windows.

Cygwin is pretty cancerous, and working with LSW is more of a pain than just not using Vim.

I'll attempt the native option.

Thanks!

jarun commented

That would be great! Please let me know if you need any help.

I love nnn, but comming from ranger I miss better sorting by name when there are numbers in the name. I often name my files like so:

  • abc 1
  • abc 2
  • abc 10

nnn sorts it like so:

  • abc 1
  • abc 10
  • abc 2

Ranger would sort this the way I expect (1, 2, 10).
The same wrong sorting is happening when file name starts with numbers but does not only contain numbers (i.e. 1 abc). I could change my file naming habits and start naming files with leading zeroes, but I would rather not :)
Is there a reason why numeric sort only works when filename contains only numbers?

jarun commented

The same wrong sorting

It's implemented that way. Only pure-numeric names are sorted in numeric order.

Is there a reason why numeric sort only works when filename contains only numbers?

Take a look at issue #190.

I see the following problems:

  1. The version sort is probably slower. Let's say we want to compare abc 10 and abc 2. strcoll() would compare 5 characters each but strverscmp() would also check the last character in the first string. nnn strives for speed. When you are having a directory of 10000 similar files this overhead may matter.

  2. The other problem is strverscmp() is non-portable. We can, however, bypass that. The source code is available:

The Android and uClibc versions are similar so I believe it applies to embedded devices.

  1. strverscmp() places capitals on top. We really don't want that. No one remembers if a file name starts with a or A.

Any chance of adding the comma key to be a Leader key? The current options are impossible to use for those of us who do not have an US keyboard layout.

jarun commented

@DavideSilva sure thing! Could you kindly raise a PR? Please feel free to ask if you need any help.

I was but now that I tried the master version, I think my need for adding the comma key as leader as disappeared. My motivation was to be able to switch contexts but that will be possible using the 1-4 keys.

I've only just found this so I'm not at all familiar with all the features nnn has but from the help menu I can only see the Leader key being used to create/switch contexts.

@jarun Do you think it is still worth it to had the comma key as a Leader?

jarun commented

We have two keys mapped to leader - ^/ and `. Do you have the second one (backquote) in your keyboard?

I don't know what keyboard layout @DavideSilva is using, but for example on a german keyboard the current leader-number combinations are impossible too. There are / and ` keys, but to get them you have to press Shift wich prevents you from entering a number at the same time. (e.g. Shift + 4 = $)
A leader key that is accessible without pressing a modifierer key would be a better choice. Examples for such a key in the german keyboard layout would be: + - . , < ยด ^ #

jarun commented

, it is! ;)

jarun commented

@Garzet version sort is in on master at commit 336eca3! Please let me know how it goes.

jarun commented

@DavideSilva & @breisa comma replaces backquote as leader key at commit f21ec61.

Have multiple contexts open and try comma comma, comma dot. ;)

@jarun Thank you, works like a charm. ๐Ÿ‘

jarun commented

@breisa awesome!

@Garzet version sort is in on master at commit 336eca3! Please let me know how it goes.

Works perfectly! Thanks!

Wasn't able to get native to compile. I suspect my Windows environment is... Well, it's Windows. I'll leave it at that.

I'll eventually try this again.

jarun commented

Thanks for the try!

@jarun something to consider is the atool utility for archives, which already does the work of trying to monomorphize the interface to interacting with archives. http://www.nongnu.org/atool/

Also, I'm interested in perhaps adding support for ssh browsing, but my C is a bit rusty, so it might be a while.

jarun commented

nnn works with atool / patool already - https://github.com/jarun/nnn#utility-dependencies.

lftp is my preferred way to go for remote transfers - https://github.com/jarun/nnn/wiki/simplify-remote-transfers-with-lftp

Does support file picker mode mean providing a file chooser dialog similar in GTK and QT?

jarun commented

@amosbird in picker mode, nnn opens and you can select one or multiple files.

Is it possible to act as a file dialog and possibly replace the Gtk/Qt ones system-widely?

jarun commented

Nope.

Hi, I'm about to switch from ranger, but the way quit-and-cd is implemented bothers me: I often forget to press C-g and press q instead. Wouldn't it be more convenient to always update $NNN_TMPFILE on quit? (Of course if the environment variable is set.) I mean, if I want to change the directory, I have to call nnn through a special Bash function (that sources $NNN_TMPFILE afterwards) anyway, so additionally telling nnn about this fact seems redundant to me.

jarun commented

Of course if the environment variable is set.

$NNN_TMPFILE specifies the tmp file where nnn should write the last visited dir if the user chooses to cd on quit. The intention of the user is confirmed by ^G. Exporting the variable in no way it means the user always wants to drop into the last visited directory on quit.

Did you think the other way? What if a user (like me) has the variable set but (s)he doesn't want to end up into the last directory unless (s)he specifically indicates? How do you handle that?

I believe this is well-documented. Also if it helps, the G in ^G stands for Go.

And q is meant to quit the current context, not the program unless that's the last context left.

Getting familiar to a keybind is a matter of habit and not about remembering a keybind. :wq is not that simple to remember.

What if a user (like me) has the variable set but (s)he doesn't want to end up into the last directory unless (s)he specifically indicates?

You won't. You only end up in this directory if you call nnn through a function like n() in scripts/quitcd/. If you call this function, you're already indicating that you want to use cd on quit, so from my point of view it is redundant to have to indicate it again while quitting.

If you call nnn directly and press the keybinding for 'quit and cd', it writes the last visited directory to $NNN_TMPFILE, but won't cd there. I see no harm in having this behaviour by default on every quit.

I believe this is well-documented.

Sure it is. I had no problem understanding how it works, I would just prefer it to work slightly differently. But if you don't agree, I can simply patch it for myself - the program is so minimal that changing it to fit one's personal taste is easy :)

jarun commented

You only end up in this directory if you call nnn through a function like n()

Exactly. I have that in my rc and I don't want to cd on quit every time. I like the brevity of having to type just n to start.

I would just prefer it to work slightly differently

I would really appreciate that! Kindly share the patch if possible. There's another user who wanted that.

the program is so minimal

And it would remain so. I plan to make the libreadline dep configurable too.

jarun commented

libreadline can now be dropped as per commit a8388ab. The stock prompt would be used (no history or completion) but saves several KBs of memory at runtime.

Is it possible to view the contents of the currently selected directory in an extra column without having to enter this directory (like the default in ranger, for example)? That would be a neat and very useful feature.

jarun commented

@retipuj sorry, nnn visual design would remain single-column.

jarun commented

Just to explain a bit more on the decision...

I think it's very evident from the README that the priority of nnn is to remain a lean and low resource/power consuming utility to navigate the filesystem and help with regular activities of people who have to spend a lot of time in the terminal but don't want to miss out on the GUI applications.

nnn uses unfragmented memory in chunks to store information of files in the current dir. If it needs more it has to re-allocate because the amount of memory required cannot be determined beforehand.

Here's my /usr:

[1 2 3 4] /usr

 2019-02-22 05:56        /  bin/
 2018-10-21 08:47        /  games/
 2019-01-25 06:28        /  include/
 2019-02-10 17:10        /  lib/
 2018-11-03 18:16        /  lib32/
 2016-08-08 20:40        /  local/
 2019-02-22 05:56        /  sbin/
 2019-02-09 07:23        /  share/
 2019-02-02 14:39        /  src/

With the proposed interface, if a user wants to navigate to /usr/share he would have to load /usr/bin which on my system has 2078 files. This would need several consecutive re-allocations. How many files in usr/share? 288, which is roughly 9% of the memory that would get allocated.

That's not the end of it. He would also have to load 6 more directories (the files within each) making unnecessary disk accesses and wasting CPU time and power. He wouldn't even look into those!

Behind every design decision I make, there is a primary question - which purpose does it serve for the primary goal of the utility?

If I wanted to write a multi-pane file manager, I wouldn't have been using only ONE window in nnn so far - the default one. I would have added one for previewing files or images, one for side by side comparison of directories and so on... but there are plenty of file managers that do that.

Perhaps, when you consider enhancing the capabilities of nnn, think of nnn as an ISR, your extended use-case being the bottom half. You would probably appreciate what nnn delivers.