jarun / nnn

nĀ³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.41k stars 763 forks source link

ToDo list #1193

Closed jarun closed 3 years ago

jarun commented 3 years ago

Rolled from #1133.

Cooking

Up for grabs

None open at the time.

For anything else please discuss in this thread.

Contribution guideline.

jcfk commented 3 years ago

Any chance you'll end up including some way to remember the hover position within a child directory?

If I'm hovered over dir1/dir2/file1 inside dir2, jump out to dir1, and then back into dir2, I should end up hovered over file1 instead of at the top of dir2.

jarun commented 3 years ago

Sorry, no plans to memorize as it's very use-case specific. Also, it makes nav-to-type mode management extremely complex.

keiviv commented 3 years ago

Nnn is so perfect that I actually had to fanboy-google the author. I very (very) rarely do that - last one I googled was Fabrice Bellard, years ago.

The best todo is to cherish and keep this rare combination of power, simplicity and clear vision. These days it's so rare (sadly) it feels almost magical.

I see 3 areas of possible long-term improvements:

  1. Wider OS inclusion via a curses alternative. This is clearly not a priority, but should be considered long-term. More users, more sponsors, worldwide domination.
  2. Nvim plugin. While most useful, it can be improved. Sometimes it's empty. sometimes it has own plans. Clicking its window traps. No auto-next on select (as if -J). I use it every day, very grateful to luukvbaal for it, but also very excited to see it on the improvements list. Nvim + nnn is majestic.
  3. Archivemount is not a great piece of software. The author even mentions he is not proud of the code. It's in a sense the opposite of nnn - limited, slow and chaotic. Since most usage cases are rather simple (list, add, delete, rewrite), maybe a 7z wrapper would be more practical, performant and clean. It also would allow Windows and non-rooted Termux users to enjoy the full power of nnn (due to fuse they can't atm).

Keep being cool!

jarun commented 3 years ago

Thanks for the compliment!

Regarding your notes:

  1. Windows does support curses through PDCurses. I think post let me try dual-boot phase, most users choose a single path - the GUI or the CLI, the former being more in number. Those who pick the GUI are predominantly on Windows. So as long as no one tries nnn with PDCurses we have to understand there's no need for it on Windows.
  2. It's new, so it would have its quirks. Please raise defects on the project with clear reproduction steps and we will actively work on them. Auto-proceed on selection is not implemented as it would be an issue when you don't want to select anything and just want to pick the current file on Enter. Maybe we can improve the flow that when there a selection we don't pick the last hovered file. But in any case, it would be confusing and need documentation. @luukvbaal please have a look at the other notes.
  3. I didn't understand what you mean by 7z wrapper. You can use 7z independently with nnn without installing archivemount.
jarun commented 3 years ago

Commit https://github.com/jarun/nnn/commit/24b71bcf1f36661216e73d5211cab2226e126705 takes care auto-proceed and pick on Enter.

@luukvbaal please take a note for nnn.nvim. Note that we still support -J to disable auto-proceed.

keiviv commented 3 years ago

I suggested to increase / ease OS support as I only want more people to enjoy nnn - benefiting both them and you. Some have to use Windows not because they love it. But this is of a low priority - just global plans for the future to make things as easy as possibru if you have time for it.

By 7z wrapper I meant maybe some non-archivemount, alternative way to transparently access archives. Suggested it because I often forget I can't use fuse on Termux without root, and instinctively press m. Also - Windows (fuse is painful there). It is debatable if this a core or plugin functionality, and fully up to your vision.

P.S. I just want to make it clear that I highly respect @luukvbaal, and that those minor imperfections I mentioned in no way preventing me and everyone else from using and loving his hard work every day. I'm simply glad it will get more awesome.

jarun commented 3 years ago

On Linux you can install p7zip-full, override NNN_ARCHIVE to include more extensions and list, extract or open them on Enter independently of archivemount (it's an optional dependency).

keiviv commented 3 years ago

Yes, that's what I use. But a transparent in-nnn access via 7z (or other) would be way cooler, I think. But it's up to you, and of course is not essential or priority.

I'm trying my best, man... You shouldn't have written such a perfect piece of software that it's so hard to add something to a todo list. No one to blame here but you šŸ˜„.

jarun commented 3 years ago

But a transparent in-nnn access via 7z (or other) would be way cooler

You mean you want to open it by default using 7z? That's not possible because many archive formats are not supported by 7z also e.g. rar. We wouldn't hard-code more utilities for archive handling. Already we do that for bsdtar, tar and patool which are more of less generic.

keiviv commented 3 years ago

7z supports rar reading (edited). Its format support is extremely wide. Igor really made a swiss knife of archiving - I doubt anyone can name a practically used format it does not support - that's why I suggested it as an all-in-one optional archive handler. Thought - if it's just one single entry point & logic for everything - why not.

It shares the same ideology as nnn - small & powerful.

Not insisting though, just something for you to consider for later.

jarun commented 3 years ago
  1. I don't really have the time to explore another utility. atool uses 7z internally anyway.
  2. 7z cannot auto-detect archives by extension (tried rar and tgz) at least when creating:
1 ~/GitHub/nnn$ 7z a archive.tgz CHANGELOG Makefile

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (806E9),ASM,AES-NI)

Scanning the drive:
2 files, 53413 bytes (53 KiB)

Creating archive: archive.tgz

Items to compress: 2

System ERROR:
E_INVALIDARG
1 ~/GitHub/nnn$ 7z a archive.rar CHANGELOG Makefile

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (806E9),ASM,AES-NI)

System ERROR:
E_NOTIMPL
keiviv commented 3 years ago

Yep, rar is read-only, I've edited right after posting. But firstly rar is closed source commercial (and rather rare usage-wise last ~10 years due to 7z rise), plus reading is better than nothing. It's basically one single edge case.

Not pushing it, just trying to evaluate pro and contra. Well, just keep it in the back of your head then, maybe one day you'd want it.

luukvbaal commented 3 years ago

@keiviv

Sometimes it's empty. sometimes it has own plans. Clicking its window traps.

Can you explain what you mean by this if the issues are still present and/or open issues on nnn.nvim? First issue might have been fixed by https://github.com/luukvbaal/nnn.nvim/issues/6?

keiviv commented 3 years ago

@luukvbaal - sometimes (rarely) the window is empty, need to close & re-open. I did not submit the issue as I cannot find any logical correlations yet (due to the rarity), and was afraid to waste your time. Same for the 2nd. I'll submit if I find more useful info for you.

The clicking issue you can ignore if you are busy - as most vim people don't usually even use mouse. But on Termux it's sometimes easier to touch. Most floating windows plugins (e.g. Telescope etc) process touches correctly, but nnn traps the cursor (as it's a terminal) - and you cannot exit unless :q. When deep into work I sometimes forget that.

None of those are critical, and I love you. Nvim + nnn + your plugin is a dream combo. I was simply glad to see it on this list - as opposed to forgotten. My remarks were clumsy, and came out way more snarky than it was in my head. Even added a P.S. in the next post when I re-read it and blushed.

Just do your things. You guys know what you are doing.

luukvbaal commented 3 years ago

Alright, thanks for the kind words. I'm not sure about mouse behavior either, although pressing i (to go back to insert mode) should be sufficient to get out of the trapped state. There is no need to :q.

According :h terminal-input mouse events are supposed to be forwarded to terminal buffers:

Mouse input has the following behavior:

- If the program has enabled mouse events, the corresponding events will be
  forwarded to the program.
- If mouse events are disabled (the default), terminal focus will be lost and
  the event will be processed as in a normal buffer.
- If another window is clicked, terminal focus will be lost and nvim will jump
  to the clicked window
- If the mouse wheel is used while the mouse is positioned in another window,
  the terminal wont lose focus and the hovered window will be scrolled.

I'm positive this worked properly at one point in nnn.nvim for NnnPicker but not for NnnExplorer. I assumed at the time that this had to do with the floating window but according to the docs it's supposed to forward mouse events for all terminal buffers.

The thing is that I can't find any commit where mouse events are being forwarded now, has this ever worked properly for anyone in nnn.vim @mcchrish? For me it doesn't work in any terminal buffer anymore even without any plugin, i.e. :e term://nnn doesn't work despite mouse=a being set..

I agree it isn't the most important but if is supposed to work according the the docs I would like to have it work.

keiviv commented 3 years ago

Wrote :q just as I was quickly testing it before posting - and closed without selecting. Posted the wrong brain register šŸ˜„. Yes, i to restore the keys functionality. But you've got the gist - an extra quirk to remember. Sometimes when deep into work you press keys in auto-pilot and forget it.

But this is not important, only if you are in a Sherlock Holmes mood.

luukvbaal commented 3 years ago

It turns out running tmux inside the terminal buffers makes mouse support working on my setup lol. So changing nnn cmd override to tmux new-session nnn lets you interact with nnn with the mouse and prevents the "trap" as well.

luukvbaal commented 3 years ago

Wonder why this is necessary, I usually use st but the same behavior is present on xterm and kitty.

keiviv commented 3 years ago

Err. I am running tmux though. Added: Do you have termux + tmux to test? Added: If not - install from Github or F-Droid, the Store version exists, but is discontinued.

luukvbaal commented 3 years ago

Running neovim inside tmux makes no difference for me, you need to actually set the cmd override for nnn.(n)vim to tmux new-session nnn.

I suppose this results in some sort of nested tmux session if you're already running tmux outside of nnn.(n)vim but it's what works (for me) šŸ¤·šŸ»ā€ā™‚ļø

Edit: haven't tested termux.

keiviv commented 3 years ago

Ah. Anyway I already feel guilty for bothering you. Just maybe put it into a low priority and do your things, this is not really important.

N-R-K commented 3 years ago

It turns out running tmux inside the terminal buffers makes mouse support working on my setup lol.

Same here on vim. sfeed_curses works fine however, don't have any other interactive terminal apps to test on. So I am assuming this is an nnn issue.

luukvbaal commented 3 years ago

I'm not sure, I see the same behavior with htop. :e term://htop no mousef forwarding, :e term://tmux -> htop mouse forwarding.

N-R-K commented 3 years ago

I'm not sure, I see the same behavior with htop.

Ahh, forgot about htop. Yes same here. I guess tmux and sfeed_curses are "signaling mouse events" while nnn and htop aren't?

luukvbaal commented 3 years ago

I'm not sure why one terminal application works and the other doesn't. Imo this should be agnostic the the terminal applications and instead just work if mouse events work outside of the vim terminal if events are properly forward as claimed by the docs. No idea though.

N-R-K commented 3 years ago

Looked into the sfeed_curses source. This patch works:

diff --git a/src/nnn.c b/src/nnn.c
index 8499489..ac1b802 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2079,6 +2079,8 @@ static bool initcurses(void *oldmask)
    //intrflush(stdscr, FALSE);
    keypad(stdscr, TRUE);
 #ifndef NOMOUSE
+   printf("\x1b[?1000h\n"); /* xterm X10 mouse mode */
+   printf("\x1b[?1006h\n"); /* extended SGR mouse mode */
 #if NCURSES_MOUSE_VERSION <= 1
    mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED | BUTTON2_PRESSED | BUTTON3_PRESSED,
          (mmask_t *)oldmask);

I have no clue how it works, or what it's doing though :smile:

P.S tmux seems to be doing something similar. https://github.com/tmux/tmux/blob/ee9885a40ced1fd34fe2eed879a40975a0691ac8/tty.c#L770-L773

luukvbaal commented 3 years ago

Nice catch!

jarun commented 3 years ago

@N-R-K please raise a PR for this.

N-R-K commented 3 years ago

@jarun The escape codes might be X(term) related. Might have to guard it with #ifndef NOX11 https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates

jarun commented 3 years ago

OK.

keiviv commented 3 years ago

That was some great catch!

Just please nobody say that escape code out lout - it's a part of the forbidden language, and if you say it - Rick & Morty will probably abduct jarun.

jarun commented 3 years ago

I am Rick's grandad... teaching my 7yr old python3 in terminal+vim... till I felt bad and gave him some respite.

keiviv commented 3 years ago

@N-R-K - A bit more on the format, particularly SGR. Has a list of the terminal support, quite big - from xterm to st and from mintty to putty,

keiviv commented 3 years ago

While not super-critical - it feels right that nnn works flawlessly with any input. And that nnn devs know what SGR is, unlike htop's (hehe), maybe it'll come handy in other projects.

nnn is such a mighty tiny beast, like a superpokemon... I literally tried every single file manager - extensively. Nothing comes close, with fff being the closest in terms of the flow. But it looked like it borrowed the context feature that originated in nnn (if my mega research was right), plus it (being a shell script) struggled in a stress test, while nnn ate even 200k elephant-packed SD card on a pre-Pi abomination of a microbox.

It just looks so unassuming at first - untill all the features unfold on you - wish more people knew about how cool it is. It's even my main fm on a damn phone - one day I've just noticed I'm not opening the Solid Explorer (one of the best Android fms) - as I do things faster on termux + tmux.

And I'm naturally very grumpy - I've just insulted the Firefox CEO for trying to kill the cult browser. And generally - there are so much imperfections, blurry vision and chaos these days - that in a sense nnn even restored my faith in devs, and refreshed the forgotten sense of dev beauty.

If you think I'm polite and give compliments left and right, you are wrong - it's you guys who are so cool I can't think of anything but praise.

Keep being the rockstars!

dgcom commented 3 years ago

Not sure nnn can do much about it, maybe include this in wiki: Trying to view encrypted 7z archive - less is hanging on password prompt. Workaround is to change lesspipe script to include -p parameter to 7za - this sends empty password and causes 7za to print error and terminate instead of waiting for password input. I tested this with standard lesspipe which is included in Ubuntu. The version by Wolfgang Friebel needs similar fix, but it looks like it has much more elaborate archive handling and I am not convinced it is much better šŸ˜„ If I have time, I'll look into it a bit more and take it to https://github.com/wofr06/lesspipe for a discussion. (By the way, you may want to have Advanced use cases wiki to point to the original Git repo for lesspipe - it is currently points to an old fork of it).

jarun commented 3 years ago

Can you send such a file with some dummy text files archived within?

jarun commented 3 years ago

By the way, you may want to have Advanced use cases wiki to point to the original Git repo for lesspipe - it is currently points to an old fork of it

@0xACE can you have a look?

dgcom commented 3 years ago

Can you send such a file with some dummy text files archived within?

You can easily create it yourself, here are the steps to reproduce:

$ echo dummy >testfile.txt
$ 7za a -pSecret -mhe protectedarchive.7z testfile.txt
$ 7za l protectedarchive.7z
$ less protectedarchive.7z

The 2nd command uses -mhe switch to encrypt archive header - concealing file names. The 3rd command will now prompt for password And the 4th command will appear "hang".

0xACE commented 3 years ago

@0xACE can you have a look?

Entire lesspipe.sh is a mess. The user may use my branch or upstream as they see fit, i rebased my github branch. Made a local patch for 7zip prompts but there are so many archive managers in lesspipe.sh that i dont feel like it's worth the effort.

diff --git a/lesspipe.sh b/lesspipe.sh
index 5a6eed0..0725c77 100755
--- a/lesspipe.sh
+++ b/lesspipe.sh
@@ -357,9 +357,9 @@ get_cmd () {
         cmd=(istemp "bsdtar Oxf" "$2" "$file2")
       fi
     elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
-      cmd=(istemp "7za e -so" "$2" "$file2")
+      cmd=(istemp "7za e -p'' -so" "$2" "$file2")
     elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7zr; then
-      cmd=(istemp "7zr e -so" "$2" "$file2")
+      cmd=(istemp "7zr e -p'' -so" "$2" "$file2")
     elif [[ "$1" = *[Cc]abinet* ]] && cmd_exist cabextract; then
       cmd=(iscab "$2" "$file2")
     elif [[ "$1" = *\ ar\ archive* ]]; then
@@ -674,18 +674,18 @@ isfinal() {
     fi 
   elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
     typeset res
-    res=$(istemp "7za l" "$2")
+    res=$(istemp "7za l -p''" "$2")
     if [[ "$res" = *\ 1\ file* ]]; then
       msg "a 7za archive containing one file was silently unpacked"
       if [[ "$2" != - ]]; then
-        7za e -so "$2" 2>/dev/null
+        7za e -p'' -so "$2" 2>/dev/null
       else
         # extract name of temporary file containing the 7za archive
         t=${res#*Listing\ archive:\ }
         t2="
 "
         t=${t%%$t2*}
-        7za e -so $t 2>/dev/null
+        7za e -p '' -so $t 2>/dev/null
       fi
     else
       msg "use 7za_file${sep}contained_file to view a file in the archive"
@@ -693,18 +693,18 @@ isfinal() {
     fi
   elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7zr; then
     typeset res
-    res=$(istemp "7zr l" "$2")
+    res=$(istemp "7zr l -p''" "$2")
     if [[ "$res" = *\ 1\ file* ]]; then
       msg "a 7za archive containing one file was silently unpacked"
       if [[ "$2" != - ]]; then
-        7zr e -so "$2" 2>/dev/null
+        7zr e -p'' -so "$2" 2>/dev/null
       else
         # extract name of temporary file containing the 7za archive
         t=${res#*Listing\ archive:\ }
         t2="
 "
         t=${t%%$t2*}
-        7zr e -so $t 2>/dev/null
+        7zr e -p'' -so $t 2>/dev/null
       fi
     else
       msg "use 7za_file${sep}contained_file to view a file in the archive"
-- 
2.33.1

this is the 7zip patch incase i reverse it in the future.

I consider lesspipe.sh to be a hack, any user adopting it is solely responsible for w/e comes next. When i first adopted lesspipe.sh it probably had severe issues, and judging it by a quick glance, it probably is still riddled by those issues.

My branch or upstream, doesn't really matter much

dgcom commented 3 years ago

@0xACE Thanks for the patch šŸ˜„ You should push it upstream. And I agree - with that many 3rd-party tools wrapped you may hit similar problem any time...

Randalix commented 3 years ago

I got one improvement for the autojump plugin in combination with zoxide and fzf. Currently zoxide is called with no query like: zoxide query -i -- This works, but it's very slow especially if you have bookmarks on network drives. I changed it to:

elif type zoxide >/dev/null 2>&1; then
    printf "jump to : "
    read -r dir
    if type fzf >/dev/null 2>&1; then
        odir="$(zoxide query -i -- $dir)"
    else
        odir="$(zoxide query -- "$dir")"
    fi
    printf "%s" "0c$odir" > "$NNN_PIPE"
else

This way you make the bookmarks lookup using the speed of zoxide and choose the filtered result in fzf. Listing all zoxide entries with a network drive took ~5 sec.. Now its instant.

danielb2 commented 3 years ago

Feature suggestion for this TODO list:

Ctrl-C from any context should exit the app. I got stuck in some submenu, and could not exit the app. Turns out I had to hit escape a number of times to get to a place where I could exit with q

Being able to quit the app from anywhere is expected behavior

jarun commented 3 years ago

Use option -Q and press ^Q.

N-R-K commented 3 years ago

@Randalix I don't use that plugin but from the looks of it that changes the ui/ux is a non-trivial manner. And from what I understand the slowdown only happens on network drive so not everyone might benefit from that change either.

I'm not familiar with zoxide or what that command, zoxide query -i -- is supposed to do, but does the slowdown happen only on the plugin on in general? If it's the latter case then it feels like it should be a bug report on zoxide instead. I'm assuming it's fetching stuff over the network that's causing the slowdown, maybe some sort of cache should be implemented instead to avoid that.

62832 commented 3 years ago

In my quest to find a way to switch out the default file picker on Chromium, I found out that people have managed to get that to work for ranger as per this Gist. I thought this was quite promising to get Chromium to use a terminal-based OFM as opposed to GTK's sorry excuse for a picker, and from what I can tell it still seems to work today.

How, if possible, could this be adapted to use nnn rather than ranger, though?

0xACE commented 3 years ago

yes, didn't read it thorougly but something along the lines of nnn -p /tmp/foo could help

luukvbaal commented 3 years ago

I made a version of the gitstatus patch that uses nerd icons: image @CantoroMC @N-R-K @Avimitin I think some of you might use the patch. Do you (or anyone else) have an opinion on whether it should be linked to the O_NERD build flag or be a separate patch i.e. O_GITNERD?

Suggestions on the icons used are welcome too, currently using this(see man for the cases): image

jarun commented 3 years ago

Please use the same O_NERD.

N-R-K commented 3 years ago

@luukvbaal sorry, I don't use the git patch. So don't have any opinion on it.

@skrrt from what I see, the kdialog imposter is writing the "picked" file to standard out. So nnn -p - should work.

CantoroMC commented 3 years ago

@luukvbaal I personally activate both nerd and git flags. I feel the git letters are good enough but the icons you have chosen are also self-explenatory (except maybe for R)

For how to activate the use of those icons, shouldn't they be active if both NERD and GIT flags are 1?