1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prezto/modules/osx/functions/trash

32 lines
698 B

#
# Moves files to the macOS trash.
#
# function trash {
emulate -L zsh
setopt LOCAL_OPTIONS EXTENDED_GLOB
local file
local -a files=()
for file in $@; do
if [[ -e $file ]]; then
# ':a' gets the full path (do not use ':A', which would resolve symlinks)
files+=("the POSIX file \"${file:a}\"")
else
print "trash: No such file or directory '$file'." >&2
return 1
fi
done
if (( $#files == 0 )); then
print 'usage: trash <files...>' >&2
return 64 # Match rm's return code.
fi
# Join file list with commas, and tell Finder to trash that list.
local file_list="${(pj., .)files}"
osascript 2>&1 > /dev/null -e "tell app \"Finder\" to move { "${file_list}" } to trash"
# }