Created
September 19, 2013 20:19
-
-
Save mrgcohen/6629269 to your computer and use it in GitHub Desktop.
rm = move to trash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias rm='~/move_to_trash.bash' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment