1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-23 10:18:00 +00:00
prezto/plugins/osx/functions/trash
Sorin Ionescu 28da8f916b Use Finder to trash files to enable Put Back.
Though AppleScript is slow, Put Back data is stored in
~/.Trash/.DS_Store, and there is no way to write to it
from the shell at this time.

The minimum Zsh version has been incremented to 4.3.10 to use
the 'a' modifier to convert a relative path into a full path.
2012-01-23 20:41:04 -05:00

21 lines
504 B
Plaintext

print -N "${@:a}" | xargs -0 osascript -e '
on run theFilePaths
tell application "Finder"
set thePOSIXFiles to {}
repeat with aFilePath in theFilePaths
set aPOSIXFile to aFilePath as POSIX file
if exists aPOSIXFile
set end of thePOSIXFiles to aPOSIXFile
end if
end repeat
move every item of thePOSIXFiles to trash
end tell
end run
' &>/dev/null
if (( $? != 0)); then
print "$0: failed to move one or more items" >&2
return 1
fi