Use trash instead of rm

Stop using rm -rf node_modules, use Trash instead.

Use trash instead of rm

Based on this excellent 🔥 tip by Wes Bos and the ensuing Twitter thread I've added the following to my .zshrc:

trash() {
  echo "🗑️ Moving files to Trash can..."
  mv "$@" "$HOME/.trash"
}

Now instead of using the destructive rm -rf node_modules I use trash node_modules to delete files. This is:

  • faster - milliseconds instead of minutes
  • safer - you can always restore files if you make a mistake

Another option would be to install the Node.js based cli by @sindresorhus.