mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
add plugin safe-rm to replace rm with mv
This commit is contained in:
parent
f8f01262ab
commit
46e5f74f3d
1 changed files with 16 additions and 0 deletions
16
plugins/safe-rm/safe-rm.plugin.zsh
Normal file
16
plugins/safe-rm/safe-rm.plugin.zsh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function rm () {
|
||||
local files
|
||||
local trash=~/.Trash/
|
||||
for files in "$@"; do
|
||||
# ignore any arguments
|
||||
if [[ "$files" = -* ]]; then :
|
||||
else
|
||||
local dst=${files##*/}
|
||||
# append the time if necessary
|
||||
while [ -e $trash$dst ]; do
|
||||
dst=$dst_$(date +%H-%M-%S)
|
||||
done
|
||||
/bin/mv $files $trash$dst
|
||||
fi
|
||||
done
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue