Posted on

Move to Trash CLI on macOS



On Linux, you can move files/folder to Trash from CLI using command called rm. On macOS, there is also a command called rm, but this command will delete your files/folder permanently instead of move them to Trash. By default, you must do it via GUI.


Install the Homebrew package trash using command:

brew install --HEAD macmade/tap/trash

You can alias the default rm command to trash, using the following line into your shell profile file:

if [ -f /usr/local/bin/trash ]; then alias rm="/usr/local/bin/trash"; fi

Then restart the terminal application.

Now, the command rm will move your files/folder to Trash instead of delete them permanently.