Skip to content

Instantly share code, notes, and snippets.

@moreindirection
Created February 1, 2011 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moreindirection/806831 to your computer and use it in GitHub Desktop.
Save moreindirection/806831 to your computer and use it in GitHub Desktop.
safe rm
function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=${path##*/}
# append the time if necessary
while [ -e ~/.Trash/"$dst" ]; do
dst="$dst "$(date +%H-%M-%S)
done
mv "$path" ~/.Trash/"$dst"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment