Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToDo list #1292

Closed
jarun opened this issue Jan 23, 2022 · 38 comments
Closed

ToDo list #1292

jarun opened this issue Jan 23, 2022 · 38 comments
Labels

Comments

@jarun
Copy link
Owner

jarun commented Jan 23, 2022

Rolled from #1219.

Cooking

Up for grabs

None open at the time.

For anything else please discuss in this thread.

Contribution guideline.

@jarun jarun added bug planning and removed bug labels Jan 23, 2022
@rieje
Copy link

rieje commented Feb 4, 2022

Is it possible to save nnn session automatically without Q, e.g. if closed terminal without manually exiting nnn?

Also would like the option of -S (persistent session) to not save the session if all contexts are closed. That would work nicely for my wrapper script where first argument would be checked if it's a directory/file and if so, open it with nnn, otherwise, create a session. Sometimes I realize I don't want the session saved anymore after working with it, so it would be nice to quit all contexts to prevent the session from being saved instead. I don't see any benefits of saving a session when all contexts are closed and this would be an option anyway.

Would be nice to be able to "redraw" a filtered list.

How does nnn decide which context to focus after closing a context? Did a quick test and it seems it doesn't focus on n-1 context (closing 4th context focuses on 1st one despite 2nd/3rd opened) nor does it focus on most most previous context. The latter or n-1 context is preferable.

@jarun
Copy link
Owner Author

jarun commented Feb 5, 2022

Is it possible to save nnn session automatically without Q, e.g. if closed terminal without manually exiting nnn?

Does the following patch help?

diff --git a/src/nnn.c b/src/nnn.c
index 8673207..df059b9 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6715,7 +6715,7 @@ begin:
 nochange:
                /* Exit if parent has exited */
                if (getppid() == 1)
-                       _exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
 
                /* If CWD is deleted or moved or perms changed, find an accessible parent */
                if (chdir(path) == -1)

Also would like the option of -S (persistent session) to not save the session if all contexts are closed.

This is an ambiguous behaviour. Some user may be working with only 1 context and she may want to save the context when she exits. The current behaviour is exactly as advertised and will not be changed.

Would be nice to be able to "redraw" a filtered list.

Why? If you have lost the filtered listing, you can apply the last filter again by pressing ^U at the filter prompt.

How does nnn decide which context to focus after closing a context?

Currently it focuses on the next active context by number. We can change the behaviour to focus on the previous active context by number. We don't track the history of context usage.

@jarun
Copy link
Owner Author

jarun commented Feb 5, 2022

We can change the behaviour to focus on the previous active context by number.

Implemented at commit 23b54ba.

@rieje
Copy link

rieje commented Feb 10, 2022

Does the following patch help?

Just tested, doesn't seem to work (applying patch directly didn't work for me, I had to generate same patch manually (maybe tabs/spaces issue?).

This is an ambiguous behaviour. Some user may be working with only 1 context and she may want to save the context when she exits. The current behaviour is exactly as advertised and will not be changed.

Oh yea, not suggesting the current behavior to change as it's simple/intuitive, just wish for an additional option for the behavior described.

Why? If you have lost the filtered listing, you can apply the last filter again by pressing ^U at the filter prompt.

Didn't realize this (^L), nice.

We can change the behaviour to focus on the previous active context by number.
Implemented at commit 23b54ba.

Works great.

@jarun
Copy link
Owner Author

jarun commented Feb 11, 2022

Just tested, doesn't seem to work (applying patch directly didn't work for me, I had to generate same patch manually (maybe tabs/spaces issue?).

If this doesn't work then I don't know how to do that.

Oh yea, not suggesting the current behavior to change as it's simple/intuitive, just wish for an additional option for the behavior described.

We can't keep adding options for everything. Thanks!

@rieje
Copy link

rieje commented Feb 12, 2022

In batch rename, deleting line of filename rm's the file. Instead, it should respect $NNN_TRASH.

@jarun
Copy link
Owner Author

jarun commented Feb 12, 2022

@KlzXS I think it's a fair request to trash when defined. Can you please take a look?

@LordRishav
Copy link

Is it possible to make nnn sort by 'creation time'? As far as I know, it only supports sorting by modification time, and it will be good if nnn supported sorting by creation time as well. ls -lt --time=birth on coreutils 8.32+ works for the purpose on the supported filesystems.

@jarun
Copy link
Owner Author

jarun commented Feb 27, 2022

I don't think there's a single reliable way to get it yet.

@LordRishav
Copy link

Hmm, I have not tried the ls flag on a filesystem other than ext4 really, so I too can't be sure about whether it works reliably everywhere. On ext4 however, stat -c %w file (like in the hyperlink above) does show the crtime of a file as it was created.

When I tried to find other file browsers that do support such a feature, I found ranger does. However ranger is like HUGE so you may not want to implement the feature if you think it will require too much code.

@jarun
Copy link
Owner Author

jarun commented Feb 27, 2022

No, we don't want to implement filesystem-specific hacks in nnn. Thanks!

@rieje
Copy link

rieje commented Mar 2, 2022

^I binding is not documented? Pressing repeatedly looks like it just cycles between active contexts but for one of these contexts it starts a filter.

I only found out because when I press l to open a file, it opens the file but nnn starts a filter on one of the contexts. If I exit out of that filter and l to open another file, same thing. I can toggle off this undesirable behavior by pressing ^I, so it seems ^I is a toggleable feature and I must have accidentally triggered this keybinding initially.

If I run nnn without options, I am not able to reproduce the above behavior-- ^l will simply cycle through the contexts.

@jarun
Copy link
Owner Author

jarun commented Mar 2, 2022

There's no ^I, looks like you are talking about ^N.

@rieje
Copy link

rieje commented Mar 2, 2022

I am aware of ^N and its correct behavior is different than ^I I'm experiencing. If ^I is supposed to do nothing, then I will file a bug when I have the time. I also found ^5 has the behavior of ! (go to shell) that's not documented, so that might be related.

@jarun
Copy link
Owner Author

jarun commented Mar 2, 2022

^I or ^5 codes duplicating other codes is not an nnn issue. You can check with the ncurses guys and proceed.

@replica9000
Copy link

I noticed when I use tree (or run a script that uses tree) from within nnn, tree outputs in json format as if I was calling tree -J. I'm not seeing any environmental variables or aliases causing tree to output this way.

@N-R-K
Copy link
Collaborator

N-R-K commented Mar 4, 2022

@replica9000 either upgrade to the latest tree version or compile nnn from master. #1291

@replica9000
Copy link

@N-R-K Thanks for the info. I've already compiled nnn from master. I've upgraded tree from 2.0.1 to 2.0.2, and tree works as expected now.

@pvxx
Copy link
Collaborator

pvxx commented Mar 7, 2022

I am aware of ^N and its correct behavior is different than ^I I'm experiencing. If ^I is supposed to do nothing, then I will file a bug when I have the time. I also found ^5 has the behavior of ! (go to shell) that's not documented, so that might be related.

Most terminals send the same character for Tab and ^I, see for example here for more info. I don't know about ^5, but I suspect it will be something similar.

@pvxx
Copy link
Collaborator

pvxx commented Mar 7, 2022

One small patch I always apply, please consider including it:

diff --git a/src/nnn.c b/src/nnn.c
index 878e15d8..2fcee449 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1454,7 +1454,7 @@ static char confirm_force(bool selection)

        int r = get_input(str);

-       if (r == ESC)
+       if (r == ESC || r == 'n' || r == 'N')
                return '\0'; /* cancel */
        if (r == 'y' || r == 'Y')
                return 'f'; /* forceful for rm */

"n" is more convenient than ESC for touch-typists and I press "x" over wrong file quite often ;).

@jarun
Copy link
Owner Author

jarun commented Mar 13, 2022

Pushed at commit d38841d.

@page-down
Copy link

I noticed that due to CWD notifications (OSC 7) is not escaped for URL, the terminal parses some paths (e.g. /tmp/%20test/) to a different path than the original.

I saw the previous discussion
#1148 (comment)

If it is not worthwhile to implement the full url encoder (all except a-zA-Z0-9_.~-),
is it possible to just replace % with %25 as in the following example?
https://codeberg.org/dnkl/foot/wiki#how-to-configure-my-shell-to-emit-the-osc-7-escape-sequence

Thank you.

(Recently kitty terminal added support for OSC 7 and I'm testing the functionality.)

@jarun
Copy link
Owner Author

jarun commented Mar 18, 2022

No plans. Thanks!

@pvxx
Copy link
Collaborator

pvxx commented Mar 23, 2022

Non-blocking actions (requested in #1328) are sometimes useful and can be easily done if you use tmux - I have custom plugin (based on rsynccp) for copying huge files (;p instead of p) that splits current window and runs rsync there - so I can continue using nnn and monitoring copy progress at the same time.

My first idea was using named plugins (like .cp/.mv/.rm) instead of cp/mv/rm, like you already do with advcpmv for -r, but that may be too dangerous (users reporting their own bugs in these plugins as nnn bugs :)). Maybe adding info about using plugin with tmux for non-blocking actions to the wiki will be sufficient and you can refer further requests of this feature there.

@greenfoo
Copy link
Contributor

greenfoo commented Apr 2, 2022

Feature request:

In #899 I asked about being able to automatically close nnn when a file was opened. Back then I was suggested to use the file picker option which is what I have been doing since then. However there is one thing that doesn't seem to work in "file picker mode": copying/moving files.

In other words, if I run "nnn -p -" I can not select with "space" and then copy/move with "y","v" because the selection is always empty (I guess this happens because un "file picker mode" the selection is used to decide what to print when "nnn" exists).

So... would it be possible for "copy"/"move" to work while in "file picker mode"? And, if not, maybe it is worth to reevaluate the patch in #899 that closes "nnn" after openin a file in "normal mode"?

Thanks!

@N-R-K
Copy link
Collaborator

N-R-K commented Apr 2, 2022

In other words, if I run "nnn -p -" I can not select with "space" and then copy/move with "y","v" because the selection is always empty (I guess this happens because un "file picker mode" the selection is used to decide what to print when "nnn" exists).

That's weird, I can copy/move files inside nnn.vim just fine, which uses the picker mode.

Trying it out, I can reproduce this with nnn -p - and nnn -p /dev/null however nnn -p /tmp/test works fine with copy/move.

@greenfoo
Copy link
Contributor

greenfoo commented Apr 2, 2022

Good finding! That makes sense: it looks like in "file picker" mode the selection file is overwritten by whatever is provided in the command line:
selection

This explain why it does not work when using nnn -p - or nnn -p /dev/null.

Maybe a tmp selection file can be used in those cases until nnn exits and prints the selection to the "real" fd provided in the command line.

This is a quick PoC I did that seems to fix the issue (it probaby breaks other things, please review!):

diff --git a/src/nnn.c b/src/nnn.c
index 2ef8a14d..4738cda3 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -452,6 +452,7 @@ static char *home;
 static char *initpath;
 static char *cfgpath;
 static char *selpath;
+static char *selpath_picker;
 static char *listpath;
 static char *listroot;
 static char *plgpath;
@@ -8236,22 +8237,20 @@ static bool setup_config(void)
 	}
 
 	/* Set selection file path */
-	if (!g_state.picker) {
-		char *env_sel = xgetenv(env_cfg[NNN_SEL], NULL);
+	char *env_sel = xgetenv(env_cfg[NNN_SEL], NULL);
 
-		selpath = env_sel ? xstrdup(env_sel)
-				  : (char *)malloc(len + 3); /* Length of "/.config/nnn/.selection" */
+	selpath = env_sel ? xstrdup(env_sel)
+			  : (char *)malloc(len + 3); /* Length of "/.config/nnn/.selection" */
 
-		if (!selpath) {
-			xerror();
-			return FALSE;
-		}
+	if (!selpath) {
+		xerror();
+		return FALSE;
+	}
 
-		if (!env_sel) {
-			r = xstrsncpy(selpath, cfgpath, len + 3);
-			xstrsncpy(selpath + r - 1, "/.selection", 12);
-			DPRINTF_S(selpath);
-		}
+	if (!env_sel) {
+		r = xstrsncpy(selpath, cfgpath, len + 3);
+		xstrsncpy(selpath + r - 1, "/.selection", 12);
+		DPRINTF_S(selpath);
 	}
 
 	return TRUE;
@@ -8412,8 +8411,8 @@ int main(int argc, char *argv[])
 				}
 
 				close(fd);
-				selpath = abspath(optarg, NULL, NULL);
-				unlink(selpath);
+				selpath_picker = abspath(optarg, NULL, NULL);
+				unlink(selpath_picker);
 			}
 			break;
 		case 'P':
@@ -8758,7 +8757,7 @@ int main(int argc, char *argv[])
 
 	if (g_state.picker) {
 		if (selbufpos) {
-			fd = selpath ? open(selpath, O_WRONLY | O_CREAT | O_TRUNC, 0600) : STDOUT_FILENO;
+			fd = selpath_picker ? open(selpath_picker, O_WRONLY | O_CREAT | O_TRUNC, 0600) : STDOUT_FILENO;
 			if ((fd == -1) || (seltofile(fd, NULL) != (size_t)(selbufpos)))
 				xerror();

Let me know if this is acceptable/desired and if you want me to create a pull request. Thanks!

@jarun
Copy link
Owner Author

jarun commented Apr 2, 2022

Sorry, I don't want to complicate this. nnn -p - does exactly what it is supposed to do - pick files and write to stdout. Please use a separate output file to use as selection if you want to use functionality that needs the selection file.

Also, did you notice that pressing Q to quit also writes the selection to stderr? Perhaps this can help in your case.

@greenfoo
Copy link
Contributor

greenfoo commented Apr 2, 2022

Sure, no problem. I can use nnn -p /tmp/somefile.txt for my use case. Thanks!

PS: Just one final note as maybe my previous explanation was worded in a confusing manner: Right now there is a small inconsistency in that nnn -p - and nnn -p /tmp/somefile.txt both serve as file pickers (one writes the selection to STDOUT and the other one to a file) but only in the second case you can also move/copy file while inside nnn. But, as you said, maybe it is not worth the extra code to "fix" this. Thanks!

@rieje
Copy link

rieje commented Apr 3, 2022

Is there a reason why QSORT is not the default and will it ever be?

@jarun
Copy link
Owner Author

jarun commented Apr 3, 2022

No reason other than it came later. There is no definitive proof that it is faster in all scenarios and if you are interested in it probably you also know how to compile nnn from source.

@raj-magesh
Copy link

Has anyone successfully used nnn as a file picker for VS Code? I skimmed the VS Code docs and searched the internet but couldn't find any info.

I realize it's not the right place for this (so sorry for the noise, but I figured it might be easier to get help here).

@rieje
Copy link

rieje commented Apr 8, 2022

Following the example from the README, export NNN_PLUG='m:-!|mediainfo $nnn' and then running the plugin, it does not show the output of mediainfo. Instead, it shows:

/tmp/.nnn1mtjZb (END)

and then pressing a key will show an empty output.

Any ideas?

@jarun
Copy link
Owner Author

jarun commented Apr 9, 2022

@raj-magesh VS Code is a GUI tool. You might have some luck with the documentation here: https://github.com/jarun/nnn/wiki/Advanced-use-cases#browser-integration

however, I haven't come across anyone who has tried it before. Do let us know if you are able to achieve that.

@rieje which version of nnn are you using? Does running mediainfo directly on the file work? It appears nnn is trying to pipe the output however there was none.

@rieje
Copy link

rieje commented Apr 9, 2022

@rieje which version of nnn are you using? Does running mediainfo directly on the file work? It appears nnn is trying to pipe the output however there was none.

Latest version 4.4. Yes, mediainfo works directly on file. I don't know if it has anything to do with it but the output of mediainfo is long and the /tmp/.nnn1mtjZb (END) shows up maybe 5 lines starting from the top. I was thinking maybe I need to scroll up but pressing any key shows (END) at the end of the line and the first column full of ~ in an otherwise blank output.

@jarun
Copy link
Owner Author

jarun commented Apr 9, 2022

Sorry, I'm unable to reproduce this.

@gavieira
Copy link

Hello! Thanks for the amazing tool.

This link from the wiki states that:

"The prompts (except the filter prompt) support readline-like command-line shortcuts. Enter or ^D at the empty prompt (except the filter prompt) exits the prompt.
Key ^L clears and Esc exits all prompts."

Is there some reason to this behavior? I'd personally like to type a substring, have Enter exit the command prompt and then select the file of interest.

Though I tried, I still haven't managed to get the desired behavior by changing the bindings in the source code yet. I would really appreciate if someone could give me a hint on how to achieve this or point me to a fork that does that.

@N-R-K
Copy link
Collaborator

N-R-K commented Apr 11, 2022

@gavieira I think you'll need to look into the filterentries function.

@jarun jarun mentioned this issue Apr 26, 2022
13 tasks
@jarun jarun closed this as completed Apr 26, 2022
Repository owner locked as resolved and limited conversation to collaborators Apr 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants