mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-07 15:20:22 +00:00
20 lines
534 B
Fish
20 lines
534 B
Fish
# Move a specified file to the Trash
|
|
|
|
function trash -d "Move a specified file to the Trash"
|
|
if [ (count $argv) -gt 0 ]
|
|
set -l trash_dir "$HOME/.Trash"
|
|
for item in $argv
|
|
if test -e $item
|
|
set -l item_name (basename $item)
|
|
if test -e "$trash_dir/$item_name"
|
|
set -l current_time (date "+%H.%M.%S")
|
|
mv -f "$item" "$trash_dir/$item_name $current_time"
|
|
else
|
|
mv -f "$item" "$trash_dir/"
|
|
end
|
|
end
|
|
end
|
|
else
|
|
echo "No file(s) given to delete"
|
|
end
|
|
end |