Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created May 18, 2011 17:23
Show Gist options
  • Save tomykaira/979056 to your computer and use it in GitHub Desktop.
Save tomykaira/979056 to your computer and use it in GitHub Desktop.
Move multiple files to a directory with rm, instead of deletion. Some similar codes are not supporting mutiple file input, but this supports.
function my-trash(){
while [ $# -ne 0 ]; do
if [ -a $1 ]; then
FULLPATH=$(cd $(dirname $1) && pwd)/$(basename $1)
if [[ $FULLPATH == /mnt/* || $1 == *~ || $(basename $1) == \#*\# ]]; then
\rm $FULLPATH
else
\mv $FULLPATH ~/.Trash
fi
case $? in
0 ) shift ;;
* ) echo "Failed to move" $1; return 1;;
esac
fi
done
return 0
}
alias rm=my-trash
@tomykaira
Copy link
Author

Updated not to cache temporary files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment