jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
18.96k stars 756 forks source link

ToDo list #213

Closed jarun closed 5 years ago

jarun commented 5 years ago

Rolled from #202.

Completed features

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

norcalli commented 5 years ago

The recycle bin desire is higher on my list now. In the spirit of the other commands, perhaps allowing to replace the command used to rm with an environment variable would a good solution? This would allow someone to specify their own script to handle rm.

jarun commented 5 years ago

I think it wouldn't be a big patch. I will work on it.

jarun commented 5 years ago

@norcalli @redquixote trash files on delete is implemented at commit 78115189034ac52eefa4e51931108b9904ea23fb.

Please test and confirm things work as you expect them to.

norcalli commented 5 years ago

@jarun I tested it. It works fine for when you have NNN_TRASH set, but funnily enough it broke the normal mode with the following error when you drop into shell rm: invalid option -- 'N'. Were you aware of the command rmtrash before implementing this? For instance, that handles the case where you have to put something into the trash on a different drive instantly, whereas with this implementation will move it to another drive, which takes time to mv. It might be worth looking into.

jarun commented 5 years ago

I'll avoid a wrapper over rm and live with the fact that files are moved to a central location at the cost of cross filesystem moves.

it broke the normal mode

I think I faced this and fixed it (but can't remember exactly, I fixed several issues last night). Please check on master.

Thanks for testing it.

Gavinok commented 5 years ago

it might be good to integrate with trash-cli

jarun commented 5 years ago

If your concern is movement across filesystem, I have decided to live with it. I am not adding a new dependency for this.

averms commented 5 years ago

Another problem with the way nnn trashes files is that it doesn't make restoring those files easy.

Most desktop environments (GNOME, KDE, LXDE, XFCE) use the Freedesktop Trash specification, which allows users to trash and restore with ease. On KDE, for example, one can use the ktrash command to trash and restore files. trash-cli is another Freedesktop compliant trash implementation.

Making nnn Freedesktop compliant would also let people manage the same trash from other applications, such as a gui file manager. You can make it an optional dependency, one would just need to set a $NNN_TRASH_COMMAND variable.

norcalli commented 5 years ago

Yeah, it's less about the cross directory thing and more about trash compliance and edge cases.

jarun commented 5 years ago

Why not have it in the scripts directory and use it?

Are you guys aware of any C utility that's available in the repos and does the same thing?

jarun commented 5 years ago

Another problem with the way nnn trashes files is that it doesn't make restoring those files easy.

If you see the output of trash-restore, it's more inline with using as a script

$ trash-restore
0 2007-08-30 12:36:00 /home/andrea/foo
1 2007-08-30 12:39:41 /home/andrea/bar
2 2007-08-30 12:39:41 /home/andrea/bar2
3 2007-08-30 12:39:41 /home/andrea/foo2
4 2007-08-30 12:39:41 /home/andrea/foo
What file to restore [0..4]: 4

just need to set a $NNN_TRASH_COMMAND variable.

It's not that simple. None of the utilities are param compatible with rm. Much more change is required to handle the cases separately.

Also, OS X may or may not follow the freedesktop schema.

But I can think of a way. Can you guys check if you create ~/.local/trash as a link to your DE Trash dir that works or not?

averms commented 5 years ago

Also, OS X may or may not follow the freedesktop schema.

Yeah on macOS it's ~/.Trash

jarun commented 5 years ago

Guys, trashing using trash-put is implemented at commit 5dd5710b310a79652e092631d29313b83f33e8bb.

Have fun!

jarun commented 5 years ago

Just set NNN_TRASH=1 and you are good to go!

Note that the previous implementation to move to ~/.local/trash is removed.

creallfluharty commented 5 years ago

There's a good chance I've just missed where it was written, but is there a way to launch nnn such that the terminal's working directory will be the same as the directory that nnn last viewed before closing? (sorry if this isn't the right place to write this, I can't seem to find where else to)

norcalli commented 5 years ago

@jarun I was wondering if the behaviour of the selection could allow for discontinuous regions of selection? Something like "Select all, unselect specific file" because it seems as if it isn't directly possible right now. The single file selection isn't a toggle, but an enable.

Also, I forgot to thank you for the trash implementation! Definitely don't neglect your family for us/work in general.

jarun commented 5 years ago

@norcalli what you can do today is - set selection mode, cherry pick and end selection mode.

unselect is not available because we don't keep the whole selection in memory and write it to the .nnncp file as soon as something is selected. To unselect we have to match a specific file in the copier and remove it from there. That would increase the complexity of a simpler solution.

Also, going forward, please consider contributing patches to the project. I am sure nnn has scopes for improvement and I need people to work on them, not just pointing out scopes for improvement.

jarun commented 5 years ago

@creallfluharty nnn has options to begin at a directory and write the last visited directory to a file. You can easily write script(s) that make use of these 2 features and do what you want to do.

norcalli commented 5 years ago

@jarun I actually stared implementing the trash solution after I mentioned it, but you created a patch with your own trash version and committed it to master before I could finish, so it was more prudent to ask you to consider changing it at the time. I do contribute to dozens of open source projects.

jarun commented 5 years ago

@norcalli in that case, along with the feature request do add a note that you intend to implement it as well. So that we don't work on the same thing.

elig0n commented 5 years ago
jarun commented 5 years ago
elig0n commented 5 years ago
jarun commented 5 years ago

You have to type: `` to reach root (not 3 left keys). This is in master. You shouldn't have to pressright` so many times if auto-select is enabled (which is default).

I have /usr/share/hardening-includes and this is what I pressed:

Esc ` u s s h i n c

to reach it (from anywhere, as I jumped to / first).

That's just 9 key presses. I've been using nnn in this mode for sometime now and I it's natural I didn't find any lag. I would request you to try nnn for a week or so and see the difference in the experience.

page up/down: that's inherited from noice. I think it's done because you'll notice that if you have many files (e.g. /usr/bin) and you scroll down a bit far the file in the middle is selected rather than the one at the top or bottom. If you want to change it please raise a PR and we'll review how the new behavior is.

elig0n commented 5 years ago

Are you sure that auto-select is enabled by default ? I had to run nnn -i to get auto-select in navigate-as-i-type mode but no auto-select in regular mode with regular search.

jarun commented 5 years ago

Auto select is not enabled in normal mode (as filtering by typing characters won't work). It is enabled in navigate-as-you-type mode by default.

jarun commented 5 years ago

@bruce-hill would it be possible to work on a function to eliminate our dependency on vidir?

bruce-hill commented 5 years ago

@bruce-hill would it be possible to work on a function to eliminate our dependency on vidir?

Depends on what the desired use case is. For just renaming files one at a time, it would be very easy to just loop through the selected files, prompt the user to edit the filename, then move it if necessary. For doing a regex rename, that would also not be too hard to do with a shell script and sed, something like: prompt the user for a regex, then run sed -e '<your regex>' copybuf.txt | paste -d'\n' copybuf.txt | xargs -d'\n' -n2 mv. For letting the user rename a bunch of files using their editor of choice, probably easy too: just create a copy of the copybuf file, let the user edit it, then run something like paste -d '\n' copybuf.txt copybuf_copy.txt | xargs -d'\n' -n2 mv (use xargs and paste to run a mv command on corresponding lines of the original and modified copybuf). Replicating the full functionality of vidir (including letting the user delete files) would be a bit more complex, but the functionality of vidir already kinda overlaps with nnn, so it's probably not worth doing everything vidir does.

jarun commented 5 years ago

For letting the user rename a bunch of files using their editor of choice

Just this . For the entries in a directory. We need to match the checksum before and after edit so the content of the dir isn't changed while the user was editing the file. No need to support movement of files. We should also use the index numbers like vidir to ensure the order is right.

jarun commented 5 years ago

Probably we can retain movement and deletion of files. As these are handy. Note that some of the entries can be directories as well.

I have noticed vidir doesn't handle Unicode very well which should not be a problem for us.

bruce-hill commented 5 years ago

No need to support movement of files.

Sorry, I was using "move" and "rename" interchangeably, since renaming is done with the mv command.

We should also use the index numbers like vidir to ensure the order is right.

That increases the complexity considerably, since you would have to do a bunch of error checking and handle deleting files. The changes I was suggesting are basically drop-in shell one-liners that handle the renaming part of vidir. For deleting, you can just delete files in nnn normally by selecting them and pressing X, so I don't think the added complexity of replicating all of vidir's functionality is worth it. I also don't think it's worth worrying about the file numbering, unless there's some reason I'm not thinking of for why users would edit the ordering of the files (other than deleting files). As far as I can tell, vidir just uses the numbers to detect which files get deleted.

If you wanted to be extra safe, you could wrap the shell script with something like if [ $(wc -l copybuf.txt | awk '{print $1}') = $(wc -l copybuf_copy.txt | awk '{print $1}')]; then ...; else echo "File count mismatch"; fi to abort if the user deleted or added lines.

jarun commented 5 years ago

vidir uses the numbers to track which files are changed: https://linux.die.net/man/1/vidir

Yes, I think move/rename is sufficient. No need to have delete (we support delete selection so we are good there).

Can you please raise a PR for this?

jarun commented 5 years ago

Note that we should not use rename() as it doesn't work across filesystems: http://man7.org/linux/man-pages/man2/rename.2.html

bruce-hill commented 5 years ago

Can you please raise a PR for this?

Sure, I can put together a PR in a little while.

jarun commented 5 years ago

Thank you!

smartmic commented 5 years ago

I recently discovered agedu and find it quite useful as du replacement, or better, extension. The added value is that it can quickly filter directories and disk usage of long time unused files. Sure, it has some drawbacks but it could be a neat du alternative embedded in nnn. Performance and footprint (besides index files) seems okay to me. What do you think?

jarun commented 5 years ago

@smartmic please have it as a plugin and contribute it back for others if you find it really useful.

For the past few months our efforts are into reducing the number of deps and configs of nnn. There are some obvious benefits - plugins are loosely coupled (we don't have to worry about deps), users can pick and use on a need basis, users can add their own.

smartmic commented 5 years ago

Yes, this makes sense. I will have a look into the plugin concept and publish it when I think it works well enough for everybody. Thanks for the tip!

Antonio210696 commented 5 years ago

new selection mode doesn't allow for unselecting an item, it is just selected twice, forcing to undo all selection and redo. I think this is unwanted

Also, in a previous version, on my local repo, i colored the output of non-dir files, trying to reproduce the colors of the ls --color=auto. I think this would be a great improvement for readability, maybe making it optional

jarun commented 5 years ago

@Antonio210696 this has been discussed several times in other threads. Please check.

0xACE commented 5 years ago

Hey, I haven't had the chance to try the patch you suggested for #301 but I reckon it will work as intended.

Some thoughts i have of nnn after using it for about a week:

  1. Lack of CONTROL('W") to delete a word in filterentries() or and xreadline(). In my local copy of nnn I have applied a poor mans application for this feature, and could share it if you are interested. (I use CTRL-W in linux more that i use the backspace key, i have killed many webrowser tabs by this habit)
  2. Lack of mouse scroll wheel support. I find it really convenient to be able to use the mouse some times. I have applied it on my local copy of nnn and in my case it is bound to scroll down/up half a screen, and it works fine. Along with this I also moved going back 1 directory to right mouse button rather than middle mouse button.
  3. I didn't like the substring matching, I changed it so that spaces act as a && operator so shazam mkv would match shazam.2019.mkv but not shazam.2019.srt (mkv shazam would work fine too). And I might eventually add leading the filter with a / would switch over to the REGEX method... I also added HJKL to not fill the text in filter mode, and just act as the regular hjkl keys in the normal mode (had to remove SEL_LOCK as i wanted HJKL to work in normal mode for consistency). (Also did it for ~!@# (where # is a alias for - because in filter mode i occasionally search for -) so that you can access those keys without having to exit filter mode) (PE to access p and e without having to exit filter mode first, essentially these changes allows you to do some basic stuff without first having to exit the filter mode)
  4. I accidentally hit the r key in my home directory when i tried to change the name of a file i had hightlighted. And r launches a batch rename on my home directory, out of reflex i immediately hit ZQ to exit out of vim and poof my home directory was broken. I haven't had the chance to debug what actually happened but i applied a patch to stop batch rename working in my home directory. (In my home directory there may have been files with weird names and some symlinks, roughly 2GB of data was lost, again I haven't had the time to research what actually happened, the missing data may have been unrelated to this incident, so its likely safe to ignore it at this point). Since this happened i have added F2 to rename as I usually hit that out of a habit to rename files...
  5. Another one that i wouldn't recommend but I like using it in my local copy is: in filter mode hitting / while highlighting a directory navigates into the directory and returns to the filter mode even if you aren't in navigate-as-you-type mode and lets the user exit it just be pressing escape (i also added q to exit filter mode, Q lets you add a regular q to filter, but that's convoluted for the general population i guess)(in xreadline() (*ch == 'q' && pos == 0) will also cancel the prompt) (I guess it's obvious that I don't have escape mapped to caps lock).

I guess i could create separate issues for my thoughts, but since I can't find a irc channel to just see if these things are even "commonly acceptable". I'll just put them here...

Finally at various places i have read that nnn selections should work between contexts and instances. selecting a file and hitting y works as intended between contexts however if I launch a second (parallel) instance of nnn: hitting y will state empty selection. Am I doing something wrong?

-- Signed a happy nnn user :D

jarun commented 5 years ago

@0xACE

Lack of CONTROL('W") to delete a word in filterentries() or and xreadline().

Please raise the PR and I'll take a look at it

Lack of mouse scroll wheel support.

We have explored this earlier. Some version of ncurses support scrolling, some don't. We decided to leave it out of plan.

I didn't like the substring matching

regex is the default and your the shazm mkv case can be handled with wildcards.

I also added HJKL to not fill the text in filter mode, and just act as the regular hjkl keys in the normal mode

I don't understand what you mean. HJKL characters work in a filter.

Also did it for ~!@# PE to access p and e

I don't understand. All these keys work as filter chars.

I accidentally hit the r key in my home directory

Please let me know how to reproduce it when you get the time. I tried the steps but didn't see any data loss.

Since this happened i have added F2 to rename

I think it's fine as a local copy. We had this key earlier but removed as it didn't apply for mobile keypads.

in filter mode hitting / while highlighting a directory navigates into the directory

I can't reproduce this. Are you on master?

i also added q to exit filter mode, Q lets you add a regular q to filter

These are different keys and should work as filter chars. There are definite ways to clear a filter: https://github.com/jarun/nnn/wiki/hacking-nnn#prompt-shortcuts

selecting a file and hitting y works as intended between contexts however if I launch a second (parallel) instance of nnn: hitting y will state empty selection. Am I doing something wrong?

Yes, selecting a bunch of files is a per-process activity. You can't distribute the job between 2 instances. When we say selection we mean a group of files selected together_ and not the selection process.

jarun commented 5 years ago

Lack of CONTROL('W") to delete a word in filterentries() or and xreadline().

Let's leave the filter prompt simple as it is without adding too much complexity. Most of the shortcuts do not work there: https://github.com/jarun/nnn/wiki/hacking-nnn#prompt-shortcuts

For xreadline(), if you are missing ^W at the command prompt, compile nnn with the readline library. The native one has several constraints (no history for example) and is for users who are OK to ignore those.

0xACE commented 5 years ago

Maybe I should've clarified, a lot of the things I mentioned are changes I have applied to my own version of nnn, I was hoping the first three would be adopted as I figured they'd be fair for more users, but the others are too much of a personal thing, I guess ill maintain my local copy myself. It is okay to skip down to the bold text as you basically covered the points I'm replying to.

Lack of CONTROL('W") to delete a word in filterentries() or and xreadline().

Please raise the PR and I'll take a look at it

Your next response states that you don't want it. I should mention though that the CTRL-W code version implemented is very similiar to how CTRL-L acts...

Lack of mouse scroll wheel support.

We have explored this earlier. Some version of ncurses support scrolling, some don't. We decided to leave it out of plan.

Fair enough.

I didn't like the substring matching

regex is the default and your the shazm mkv case can be handled with wildcards.

Yeah, the problem i find with regex is that it requires me to type .*mkv for the equivalent. I guess it just fits my personal workflow better. Not a big deal just mentioning my private patches to nnn. I'll just maintain it in my local copy.

I also added HJKL to not fill the text in filter mode, and just act as the regular hjkl keys in the normal mode

I don't understand what you mean. HJKL characters work in a filter.

Again this is a personal change, it allows me to use the keys HJKL to browse the objects in the menu without exiting out of the filter mode, the idea is that i dont like using the arrow keys, and hitting the escape key is a real drag for me... so i just hit /commonnameJJL and it will pick the 3rd entry.

Also did it for ~!@# PE to access p and e

I don't understand. All these keys work as filter chars.

Again, another personal change. Allows me to access the shortcut keys to `~!@-~ without exiting the filter mode. Though this is a very personal patch, so i dont expect anything form this.

I accidentally hit the r key in my home directory

Please let me know how to reproduce it when you get the time. I tried the steps but didn't see any data loss.

Yeah, sorry the weekend came around and kidnapped me... It will be hard for me to reproduce as the files which possibly were involved are the exact files that should be missing... Maybe i could find the time to reproduce this. Interestingly recently i found another problem with file names, a .mp4 which was opened differently by nnn I'm guessing the mp4 had a weird name, but I'll have to go back and see what actually happened... (iirc correctly the file started with a space and later had a ', like so: " it's broken.mp4" (Without the quotes)

Since this happened i have added F2 to rename

I think it's fine as a local copy. We had this key earlier but removed as it didn't apply for mobile keypads.

I see.

in filter mode hitting / while highlighting a directory navigates into the directory

I can't reproduce this. Are you on master?

I feel bad; this is a personal implementation. The idea is while you are in filtering mode you could hit / to browse into and remain in filter mode. E.g. hitting these key strokes: ~/down/movie/shaz/shaz mkv<ENTER> would go to the home directory and then enter filter mode, while in filtermode "down" would match "downloads" which is a folder in my pc, hitting / while a folder is selected in filter mode lets you browse into the directory and clear the filter and let you enter another search them, much like navigate-as-you-type but without having to trigger it with CONTROL('T'). This is very much a personal taste thing, the reasoning behind it is / will only be hit when i intend to go deeper into a directory, so I had the the filter utilize it for stepping into directories as a path will not have a /... I don't expect this to get adopted as its not a commonly understood user action...

i also added q to exit filter mode, Q lets you add a regular q to filter

These are different keys and should work as filter chars. There are definite ways to clear a filter: https://github.com/jarun/nnn/wiki/hacking-nnn#prompt-shortcuts

Yeah, i just added it to my local copy. Doubt anyone else would find use for it as it carries along with it a bunch of weird edge cases.

selecting a file and hitting y works as intended between contexts however if I launch a second (parallel) instance of nnn: hitting y will state empty selection. Am I doing something wrong?

Yes, selecting a bunch of files is a per-process activity. You can't distribute the job between 2 instances. When we say selection we mean a group of files selected together_ and not the selection process.

So i interpret this that selections do not pass between different standalone instances of nnn. Though from reading https://github.com/jarun/nnn/wiki/design-considerations

file paths copy-paste should work seamlessly between contexts and instances of nnn

I figured i could select which files i want to copy in one instance of nnn and in another instance just hit P to have them copied to the other instance.

The text above can be ignored as you have mostly addressed it.

Another thing I recall being annoying this weekend which happend frequently:

  1. cmyphone to mount and go into my phone and atleast browse to a subdirectory (sshfs doesnt remove the mount dir, only subdirectories). and while nnn is anywhere inside the sshfs mount and connection is lost to my phone, the ENTIRE nnn session shuts down as the directory i was in dissappeared.

I found this very annoying as sshfs tends to frequently disconnect in my experience, resulting in nnn completely closing and loosing all my progress. In my personal copy of nnn I have applied a patch where nnn jumps to the parent directories until it finds a existing path instead of quitting. I find this change much more convenient than having the program completely quit. I guess sshfs can be setup to not remove subdirs, but I'm not a fan of the program essentially crashing while it is easily solved.

Oh another annoying thing i found just now before i wrote this response is:

  1. Select a directory that contains files say: /home/ace/src/nnn
  2. fyexample.zip<ENTER> to create a zip of the selected directory
  3. F to see the contents of the zip, shows that it saved the absolute full path to the folder and its file.
  4. Hitting ^F on the zip has now created a sub directories with the full path, so in my case it created $PWD/home/ace/src/nnn while i just expected $PWD/nnn

When you select single files it seems to only save the relative path, and behave like expected.

jarun commented 5 years ago

Lack of mouse scroll wheel support.

I did some further digging and it seems you can use libgpm to handle mouse clicks and scrolling independently of ncurses. Please take a look into libgpm and see if you can have a working implementation. You can also look into mc code for reference. It uses GPM.

I figured i could select which files i want to copy in one instance of nnn and in another instance just hit P to have them copied to the other instance.

That's correct. But you cannot ^Y and select some files in one instance. Press ^Y in another instance to end selection.

I found this very annoying as sshfs tends to frequently disconnect in my experience

I can understand. Please raise the PR.

F to see the contents of the zip, shows that it saved the absolute full path to the folder and its file.

That's for a selection. The reason is you can select files across directories in nnn and so you can select two files having the same name from 2 different directories. Hence we use the absolute path for selection.

jarun commented 5 years ago

A note on sshfs disconnection - I see disconnection happening frequently if the display goes off quickly. So I set the mobile to turn off display in 20 minutes and I don't see this problem.

However, please raise the PR. It's the best solution we have in hand.

jarun commented 5 years ago

That's correct. But you cannot ^Y and select some files in one instance. Press ^Y in another instance to end selection.

I see this is broken in master. Need to fix.

jarun commented 5 years ago

Oh, wait:

I launch a second (parallel) instance of nnn: hitting y will state empty selection.

The selection is not shown but cp, mv, rm works with the selection. The selection is not shown because there is no selection in the second instance. For cp, mv, rm, the selection file is read.

jarun commented 5 years ago

The selection listing issue is fixed in commit 41fcbd9b2f62668038b1ab31ce63d55062e31a2f.

0xACE commented 5 years ago

Oh, wait:

I launch a second (parallel) instance of nnn: hitting y will state empty selection.

The selection is not shown but cp, mv, rm works with the selection. The selection is not shown because there is no selection in the second instance. For cp, mv, rm, the selection file is read.

I see, the y list is what kept me confused, I never actually tried cp, mv or rm. I just looked at y and figured the selection isn't inter-process based. Though I'm not really sure how it works if each client makes its own selection...

I found this very annoying as sshfs tends to frequently disconnect in my experience

I can understand. Please raise the PR.

I sent a patch for you to review. Since I don't know of a channel to contact you I spent time reading the code multiple times trying to make the right decision. I made multiple ways to apply this fix, but I figured you wouldn't be happy if i changed visit_parent() so that's why i presented the patch as is. So i applied the changed elsewhere while using visit_parent()

A note on sshfs disconnection - I see disconnection happening frequently if the display goes off quickly. So I set the mobile to turn off display in 20 minutes and I don't see this problem.

However, please raise the PR. It's the best solution we have in hand.

Yeah, in my case just calling termux-wakelock or w/e the command is, is enough, but still it will disconnect, sshfs tends to disconnect on other servers i use too, just used the phone as a example as it exacerbates the problem.

Lack of mouse scroll wheel support.

I did some further digging and it seems you can use libgpm to handle mouse clicks and scrolling independently of ncurses. Please take a look into libgpm and see if you can have a working implementation. You can also look into mc code for reference. It uses GPM.

I can't make any promises but at least having this information will help any potential developer.

If there is a irc channel you or any nnn dev frequents I wouldn't mind joining to keep in touch. So far I'm really happy with nnn and intend to use it as my main filemanager.