This is a simple utility to send files to macOS's Trash from the command line.
This works on macOS Sonoma 14.5 (June 2024).
curl -fSLO https://github.com/proprietary/macos-trash/releases/download/v1.0.0/trash
sudo install ./trash /usr/local/bincd /tmp
echo "hello world" > hello-world.txt
trash hello-world.txtThis works on directories or regular files. I suggest using
trash anywhere you would have used rm(1).
Currently, this command line tool cannot restore files. You will have to open Trash in Finder and restore it from the GUI.
xcode-select --install
git clone https://github.com/proprietary/macos-trash
cd macos-trash
make
make test
sudo make installtrash --versionApache-2.0