Go Mac OS x A gadget that puts files in the Recycle Bin when you write an RM

Source: Internet
Author: User

The last time because of the company's machine to face the reload, began to panic in the Mac file SCP to my desktop. In the bustle of the original to delete a useless folder, the results with RM-RF when the tab, fill out the document did not see the press ENTER, no doubt, the file deleted the wrong. Because the RM command is not to go to the Recycle Bin, even before the deletion of the confirmation will not have, so that a useful folder deleted. Fortunately I later found that I have backed up this file on the desktop, otherwise good memories are lost because of this operation error.

To prevent the recurrence of such incidents, I asked someone on Twitter about the command to send the file to the Recycle Bin without deleting it when RM was implemented. Some people say it's OK to use the MV command, but this is obviously not enough because the MV and RM command options are not compatible, especially the rm-rf,mv I'm accustomed to. Second, the file MV into the Recycle Bin after it is not put back, it is even more. There are ways to get files into the Recycle Bin and put the back on the web, which is good, but as I said before, the RM option function is not fully implemented. So it took me a few nights to achieve my own realization of a tool that meets my needs: Https://gitcafe.com/bachue/rm-trash

    • This tool is written entirely in Ruby (all the time with pure Ruby), considering that Mac OS X comes with Ruby 1.8.7, so all the code is also written on 1.8.7, and guaranteed to be absolutely independent of any gem at run time (the reason why you don't want to rely on gems is that the package was missing because of a utility that was written in Python previously on Linux, and then I found the error from GitHub's issues because the dependency package was not installed , I obviously do not engage in Python, so can only be on-site Google learning to install PIP, and then use PIP to wrap it, far more complex than the use of C writing programs, not because they are the language of the developers think other people also have its development environment AH).
    • The core functionality put into the Recycle Bin is implemented by AppleScript (so it can only run on Mac OS X), which is referenced in this Python implementation.
    • All output information (except for help information) is colored in order to be as interesting as possible.
    • As much as possible, all behaviors are consistent with the RM command that comes with the system, and all inconsistencies are treated as bugs, except for features that are impossible or unnecessary to implement (such as three erase file blocks that make the file unrecoverable and attempt to recover the file).

In fact, at first I thought this tool is not difficult to do, just put the folder to the Recycle Bin can be, and then do the interactive deletion when the difficulty multiplied, so I have to refactor the code several times to meet this demand. Fortunately, at the beginning of the project, a perfect rspec test case has been established, otherwise it is certainly not enough to take into account so many edge cases. At the same time, with more in-depth development and research, found more and more at the beginning not found in the RM's behavior details, these details so far I have not completely imitated, because the program is not allowed to do the current algorithm, but because the program has been basically available and time is precious, can only wait until later time to achieve.

Go Mac OS x A gadget that puts files in the Recycle Bin when you write an RM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.