Git Product home page Git Product logo

Comments (6)

nitrix avatar nitrix commented on May 18, 2024 2

Technically speaking, it's more of an Operating System thing, and as far as I know, Linux doesn't provide an "undo" feature internally by default; it's always been a patch/trick played by the file explorer (like on Ubuntu).

You have to understand the motivation behind it, it's part of the "linux way". The whole concept of having aTrash Can / Recycle bin from Windows is ridiculous. If you think about it, it's somewhere you can put files into, copy them back if you need them again, or re-delete them again? Does that even make sense... then why not use any regular folder... you have the exact same features!

For most users, we just keep all our files until we really are sure one particular shouldn't exist anymore. I think it'd be sane to ask a confirmation, like other tools and OS do, but that's it. It does the job, it ask you if you want to delete the file.

  • No need to move the file to a temporary folder.
  • No extra step of re-deleting the file after it's already been deleted (emptying the bin)
  • Not another confirmation dialog to ask you if you really really want to delete X items.

from ranger.

hut avatar hut commented on May 18, 2024 1

It is easy to implement a trash-key, for example:
:map x shell mv %s ~/.trash/

I won't implement undoing move/copy operations, because it is unclear what exactly it means to undo such an operation, and this would confuse the operator.

For example, I copy ~/test.png to /mnt/test.png. Then I mount /dev/sdb1 over /mnt. If I undo the copy operation, it would delete test.png on /dev/sdb1, even though it might be a completely different file, resulting in accidental loss of data.

from ranger.

make-github-pseudonymous-again avatar make-github-pseudonymous-again commented on May 18, 2024

I think this is related: How would I configure ranger to use trash (trash-cli) everytime it wants to use rm?

@nitrix Just to put my two cents here, I sometimes delete stuff by mistake because I am too tired. Moving to another folder can also be much faster than doing a rm -rf.

from ranger.

toonn avatar toonn commented on May 18, 2024

@aureooms, you can edit all the keybindings in rc.conf that use delete or rm if that's used anywhere. Or you could try to redefine the :delete command in commands.py and implement it using trash-cli.

from ranger.

make-github-pseudonymous-again avatar make-github-pseudonymous-again commented on May 18, 2024

@toonn I am looking at the code right now and it looks a bit more complicated than I expected.

For instance, there are many references to destructive commands.

$ ag --hidden --ignore .git 'os\.remove|os\.removedirs|os\.rmdir|shutil\.rmtree' ranger
ranger/core/actions.py:1236:                        shutil.rmtree(f.path)
ranger/core/actions.py:1241:                        os.remove(f.path)
ranger/config/commands.py:852:            os.remove(cf.path)
ranger/ext/vcs/git.py:121:            os.rmdir(self.path)
ranger/ext/vcs/bzr.py:106:            os.rmdir(self.path)
ranger/ext/vcs/hg.py:114:            os.rmdir(self.path)
ranger/ext/shutil_generatorized.py:210:    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
ranger/ext/shutil_generatorized.py:245:                os.remove(fullname)
ranger/ext/shutil_generatorized.py:247:                onerror(os.remove, fullname, sys.exc_info())
ranger/ext/shutil_generatorized.py:249:        os.rmdir(path)
ranger/ext/shutil_generatorized.py:251:        onerror(os.rmdir, path, sys.exc_info())

It seems that patching all this code to use trash-cli instead would not be very future-proof.

On the other hand, looking at the keybindings, it seems there is some redraw logic in those functions, not just the rm command. Changing those does not seem future-proof either.

Maybe this comment deserves its own issue.

from ranger.

toonn avatar toonn commented on May 18, 2024

Doubt any of those are relevant. What I was saying is you implement your own custom commands in ~/.config/ranger/commands.py (It's a configuration file.) And then you can rebind some keys in rc.conf to use those commands rather than :delete or :shell rm etc.

from ranger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.