Skip to content

Instantly share code, notes, and snippets.

@mrgcohen
Created September 19, 2013 20:19
Show Gist options
  • Save mrgcohen/6629269 to your computer and use it in GitHub Desktop.
Save mrgcohen/6629269 to your computer and use it in GitHub Desktop.
rm = move to trash
if [ $# -eq 0 ]; then
echo "usage: trashit <files...>" >&2
exit 2;
fi
for file in "$@"; do
# get just file name
destfile="`basename \"$file\"`"
suffix='';
i=0;
# If that file already exists, change the name
while [ -e "$HOME/.Trash/${destfile}${suffix}" ]; do
suffix=" - copy $i";
i=`expr $i + 1`
done
mv -vi "$file" "$HOME/.Trash/${destfile}${suffix}"
done
alias rm='~/move_to_trash.bash'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment