Comments (6)
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.
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.
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.
@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.
@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.
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)
- Provide entrypoint for successful pipx installation
- Show progress instead of stuck when copying big folders under WSL
- icat works in kitty on Windows WSL but ranger image preview with kitty not working
- Preview image prob still . .
- Ranger crashes when trying to preview a jupyter notebook file HOT 2
- yank path not working on wsl HOT 2
- feature request: add "Loupe" to default rifle.conf
- want to use vim editor to open dts file in rifle.conf,but invalid. HOT 1
- ranger crashed. Please report this traceback HOT 2
- preview **SVG** images using kitty HOT 2
- FileNotFoundError: [Errno 2] HOT 1
- [FR] Center the image when previewing
- Missing man page HOT 1
- Image/PDF preview overflow on Wezterm and Kitty terminals HOT 2
- Coping filename using `yn` does not work
- rc.conf is not read
- Feature request: add "Xournal++" to default `rifle.conf` for `.xopp` files
- Ranger takes very long to load HOT 1
- discrepancy folder size and subfolders
- Crash after trying to trash folder HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ranger.