Nnn: if cancel the delete operation will get a prompt in the shell

Created on 9 Jul 2020  路  9Comments  路  Source: jarun/nnn

Environment details (Put x in the checkbox along with the information)

[x] Operating System: debian 10
[x] Desktop Environment: xfce4
[x] Terminal Emulator: xfce4-terminal
[x] Shell: zsh
[ ] Custom desktop opener (if applicable):
[ ] Program options used:
[ ] Configuration options set:
[x] Issue exists on nnn master

Exact steps to reproduce the issue

type x delete one file, display "rm -rf current file?"
if type y, it will delete file. 
if type n, display "rm: remove regular empty file '/home/fcying/test/nnn/a'?", and this prompt is in the shell, not in the nnn.

image

bug

Most helpful comment

I have made the necessary changes. Note that we show the cancelled feedback only when removing multiple files. For a single file the user would still be on the same entry without any visual change so he would know that the file is not removed.

All 9 comments

This is not a bug. The question rm -rf current file? emphasizes on the use of option force. If you press n it tries to interactively delete the files instead of force remove.

This is useful when deleting too many files at a time. If you press y, no questions will be asked, else each file will be removed interactively by rm.

and this prompt is in the shell, not in the nnn.

Because nnn internally calls rm which has to be run within the shell. Find the list of nnn dependencies here: https://github.com/jarun/nnn/wiki/Usage#dependencies

This option is chosen instead of having 2 different keys to force-delete and to interactively delete.

Another choice would be having a program option to force-delete/interactively delete always but it's really a case by case thing:

  • force delete always may lead to accidental loss of data anytime
  • interactively delete always may be extremely annoying when trying to delete a directory with 100 files (say)

To delete safely all the time without this prompt, I would suggest installing trash-cli and setting the config:

NNN_TRASH=1

question rm -rf current file? is fine. The interactively after press n is too annoying.
Is there any way to disable interactively after press n? just cancel this delete.

select some need delete file
press x, press s.
change my mind, press n,    a lot of n <CR>...

trash-cli looks good, I will try to test it, thanks~

@fcying you can press Esc instead of n to cancel the delete operation immediately (in the first prompt).

@fcying you can press Esc instead of n to cancel the delete operation immediately (in the first prompt).

This does not take effect.

select some file
press x, press s. press esc
have interactively  also, a lot of n <CR>...

@leovilok currently it's not there. I think it would be a good idea to support cancel for this specific case.

I have made the necessary changes. Note that we show the cancelled feedback only when removing multiple files. For a single file the user would still be on the same entry without any visual change so he would know that the file is not removed.

Oh I thought I tested it, it must have been before the 's'/'c' choice... Well now it here, thanks @jarun :+1:

Now it works great, thanks

rm -rf 2 file(s)? [Esc cancels]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amanjitsk picture amanjitsk  路  8Comments

billop picture billop  路  5Comments

ralphee picture ralphee  路  6Comments

z0rc picture z0rc  路  7Comments

alexx-oo picture alexx-oo  路  3Comments