It seems that it was recently removed from Homebrew because the license is opaque and there is no response from the author. https://github.com/Homebrew/homebrew-core/pull/65438
It seems that registration of another rmtrash is being considered, but it cannot be used now (December 14, 2020), so we will consider an alternative.
On a Mac, I want something that can be thrown from the command line into the system trash.
The trash in 1 is almost the same as the rmtrash. It's easy to install with Homebrew. But I couldn't get the deleted files back from the trash that I opened in the Finder. (I forgot if rmtrash could be returned from the trash.)
2 needs to download the script, but you can restore the deleted file from the trash can opened in Finder.
3 is highly functional, but recent versions seem to have lost the ability to throw it in the system trash.
For the time being, the script called trash in 2 seems to be good, so I will use it for a while.
https://github.com/h-matsuo/macOS-trash You can download or copy the script from here and put it with execute permission where the path passes.
I aliased it to rm. I also added the -r
option so that the directory can be deleted.
if type trash > /dev/null 2>&1; then
alias rm='trash -r'
fi
In Linux on a server such as a supercomputer, I create a directory (~/.Trash) that becomes a trash can by myself, and move files to it once with mv without using rm.
You can create a directory anywhere you like, so on servers that often use / work
, create it under/work
.
Alias setting.
if [ -d ${HOME}/.Trash ]
then
alias rm='mv --backup=numbered --target-directory=${HOME}/.Trash'
fi
If the --backup = numbered
option is specified, if the same file name exists in the move destination, the file name will be numbered and moved instead of overwriting.
You can move files to a directory specified in advance with the --target-directory
option.
Create a script that empty the contents of the trash can directory that you created, and give execute permission to the location where the path passes.
#!/bin/sh
rm -rf ~/.Trash/*
exit
Recommended Posts