8 ms·
Show HN: Rmt an alternative to rm with trash written in Rust
- sph 4y agoQuote: > Launch CLI to restore or flush elements: `rmt trash_display` or `rmt td` > Flush all element from the trash: `rmt trash_flush` Those need to be dash-style options. Because if someone runs a `rmt *` in a directory and there's a trash_flush file inside, it will NOT do what one expects and will be destructive. This is why options are traditionally prefixed with dashes. (Yeah sure, you have the same problem if you have a file that starts with dash, I already hear someone point out.) Since you suggest to alias rm to rmt, your application needs to behave like rm and have a similar UI.
- Amine_Ztn 4y agoYou are totally right, thank you for the pertinent comment and I will correct that. This is one of the first cli's I had not thought of at all.
- rcthompson 4y agoI think the trash interaction command needs to be a different main command, actually. No matter what you call the option, someone can make a file with that name.
- vore 4y agoUsually tools support a `--` option for that, e.g. with `rm`: rm -- --file-that-looks-like-a-flag
- ben0x539 4y agorm ./--file-that-looks-like-a-flag ;) (I'm always half-tempted to suggest that a "strict mode" shell should require all paths in arguments to start with either / or ./ so that anything else is unambiguously not a file.) (I spent a bunch of time with a file named -i in my home directory, you know, just in case.)
- kevincox 4y agoI agree. rmt-flush and rmt-list would be great options.
- kseistrup 4y agoAlso, the `trash_` is redundant, so `rmt --display` et cetera is all enough (and please make short options like `-d` too).
- nextaccountic 4y agoOddly enough, https://github.com/Byron/trash-rs https://github.com/Byron/trash-rs also has this same UI issue (and is also written in Rust)
- forgotpwd16 4y agoOh, that's nice. A library providing cross-platform access to system's trash. Surprising none of the Rust-written rm alternatives used this.
- Amine_Ztn 4y agoI followed your advice and fixed the problems, I updated the readme and the deployment of the new version (0.1.2) should arrive in 1 hour. I thank you for raising these points.
- lavela 4y agoDon't actually alias it with 'rm' or you'll have a bad surprise waiting when you are on a different system and your muscle memory kicks in. I even had to disable rm for non-privileged users on my systems just to get used to use trash-cli.
- deleted 4y ago[deleted]
- ridiculous_fish 4y agoThis has a pretty serious bug with symlinks: > ln -s important_file.txt ./just_a_link > rmt ./just_a_link This leaves "just_a_link" and instead deletes important_file.txt.
- nusaru 4y agoNice! Now I'll just be a single missing keystroke away from accidentally deleting my files permanently.
- virtualritz 4y agoThere is `rip`[1] (also written in Rust) which does more or less the same? Or am I missing something? [1] https://github.com/nivekuil/rip https://github.com/nivekuil/rip
- Amine_Ztn 4y agoThank you for your comment, I try to get as close as possible to the signature of the real rm command in order to facilitate aliasing, plus I have many ideas to improve my project that are not necessarily available on rip
- virtualritz 4y agoI would write to the author of `rip` and ask if you can take the project (including the memorable/cool name) over. `rip` seems unmaintained (three open PRs from one to five years old). It has a name that doesn't clash with an existing *nix command and people seem to also ask for the same thing since its inception (see issue #3 from 2016).
- r3tr0 4y agoHere is an interactive browser demo. Have fun. https://xn--yv9h.fm/emu/?m=oACYqwLUHto9zqU25DWm97 https://xn--yv9h.fm/emu/?m=oACYqwLUHto9zqU25DWm97
- TazeTSchnitzel 4y agoWhat OSes are supported? Does it use the standard trash locations for each OS?
- AdilZtn 4y agoIt support Linux and MacOS and it use a different trash location (.trash_rmt)
- im3w1l 4y agoConsider using The FreeDesktop.org Trash specification. It's just two screenfuls long, and would let the tool integrate with Gnome/Kde trash. https://specifications.freedesktop.org/trash-spec/trashspec-latest.html https://specifications.freedesktop.org/trash-spec/trashspec-...
- nobody9999 4y agoWhile most folks don't use it anymore, there is already an 'rmt' command[0]: Rmt is a program used by the remote dump(8), restore(8) or tar(1) programs in manipulating a magnetic tape drive through an interprocess communication connection. Rmt is normally started up with an rexec(3) or rcmd(3) call. The rmt program accepts requests specific to the manipulation of magnetic tapes, performs the commands, then responds with a status indication. All responses are in ASCII and in one of the following two forms. Depending on the platform, this could cause a name collision with unexpected results. Not telling you what to do, just that you should be aware. [0] https://linux.die.net/man/8/rmt https://linux.die.net/man/8/rmt
- IgorPartola 4y agoI don’t currently have a project on deck that I’d like to Show HN but whenever I have one I will absolutely post it as “Show HN: XYZ an alternative to ABC, NOT written in Rust” just to see what would happen.
- forgotpwd16 4y agoDebatable in Show HN having the implementation language kinda makes sense if you want to find people knowledgeable/interested in said language to contribute.
- IgorPartola 4y agoWhen was the last time you saw a “written in” be followed by PHP, Perl, Ruby, Python, C, or even JavaScript? I only see Rust as the language mentioned which makes me think the poster is looking to ride the Rust is popular train rather than looking for collaborators.
- jasonlingx 4y agoWhy not just use or alias ‘mv’ to trash?
- Amine_Ztn 4y agoThis was my initial idea but unfortunately there can be name conflicts, if two files or folders have the same name, this idea does not work anymore. Also, I wanted to be able to keep the initial path to restore the element directly where it was deleted.
- imiric 4y agoHow would you use Rust with that approach?
- Amine_Ztn 4y agoWhen a person delete an item, I get all the information that are interesting for me (https://github.com/AmineZouitine/rmt.rs/blob/main/src/trash_item.rs https://github.com/AmineZouitine/rmt.rs/blob/main/src/trash_...), and then I move it in a .trash folder in which I rename it with a hash (the hash is made with several parameters to avoid any collision), I then store the information in a database sqlite :)
- svnpenn 4y agoDoesn't work for Windows
- Amine_Ztn 4y agoI'm fixing the bugs after the feedback and then I'm fixing the Windows problem, I'm using a crate that is not cross-platform for the input management
- pabs3 4y agoReminds me somewhat of trash-cli: https://github.com/andreafrancia/trash-cli https://github.com/andreafrancia/trash-cli
- AdilZtn 4y agoThe benefit of rmt over trash-cli is that rmt has almost the same set of arguments as the rm command, and it is easier to alias between rm and rmt than thrash-cli. Also, rmt is written in rust and, therefore, more easily installable because you have to move the binary to usr/local/bin than trash-cli; it is necessary to install a python interpreter.
- pabs3 4y agoIn most situations installing trash-cli and its dependencies is a single command (apt/dnf/etc), while with rmt you need to pick the right tarball for your system, download it, unpack it and then install the binary, or manually build it from source.
- Amine_Ztn 4y agoIt's my first project in rust, I didn't really know how to go about getting the most practical installation possible. But thanks for the feedback, I'll work to make the process easier.
- pabs3 4y agoNot sure about rust stuff, but trash-cli is simply just packaged for all the commonly used distros. https://repology.org/project/trash-cli/versions https://repology.org/project/trash-cli/versions
- singularity2001 4y agofunction rm(){ mv "@$" ~/.Trash }
- Amine_Ztn 4y agoThis was my initial idea but unfortunately there can be name conflicts, if two files or folders have the same name, this idea does not work anymore. Also, I wanted to be able to keep the initial path to restore the element directly where it was deleted.
- mikercampbell 4y agoOh I love stuff like this. I'm always looking for that little tool that scratches itches I hadn't yet articulated, and this is one of them. Just last night I rimraf'd something and did a double take. I deleted the right one, thankfully, but you're always one command from trouble.
- Amine_Ztn 4y agoHi, thanks for your comment! I fix a lot of things with the numerous feedbacks, and I have a lot of ideas to make the project really interesting and different from what we can find :D
- kseistrup 4y agoAlso in Rust: https://git.sr.ht/~mzhang/garbage https://git.sr.ht/~mzhang/garbage — a soft-deletion CLI tool with FreeDesktop Trash compatibility.
- psychphysic 4y agoNice! Is there any desire to extend beyond original `rm` functionality?
- Amine_Ztn 4y agoThanks ! I have many ideas to make the project much more interesting, including adding automatic flush (that the user will have configured), the ability to compress the file before entering the trash etc ... Do you have any ideas in mind?
- psychphysic 4y agoSo glad you asked! The main one is that files sent to trash are encrypted. So that a private key is required to restore them. Ideally even the meta data is encrypted. I've watched too many kids spy movies from the 2010s with files restored from trash! Edit: just wanted to add I just mean via GPG! Rather than asking encryption be added to the application.
- Amine_Ztn 4y agoThis is a great idea! I hadn't thought about it. I'm currently fixing the major bugs and refactoring the code a bit, and when I finish that, I'll get to your idea, I find it really interesting.
- forgotpwd16 4y agoSeeing it creates some sort of database, this uses its own trash distinct from system's trash, right?
- AdilZtn 4y agoYes
- bandie91 4y agoshameless self plug: https://github.com/bAndie91/libyazzy-preload/#recyclixso https://github.com/bAndie91/libyazzy-preload/#recyclixso recyclix.so is an LD_PRELOAD-able shared library intercepting file deletions and moving files to recycle bin (trash can) folder.