Published on

Move to Trash CLI on macOS



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


Install theHomebrewpackagetrashusing 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 commandrmwill move your files/folder to Trash instead of delete them permanently.

© 2019-present by Le Minh Tri (@ansidev).