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.
This commit is contained in:
parent
8d00173fd2
commit
28da8f916b
2 changed files with 20 additions and 13 deletions
2
init.zsh
2
init.zsh
|
@ -1,7 +1,7 @@
|
||||||
# Initializes Oh My Zsh.
|
# Initializes Oh My Zsh.
|
||||||
|
|
||||||
# Check for the minimum supported version.
|
# Check for the minimum supported version.
|
||||||
min_zsh_version=4.3.9
|
min_zsh_version='4.3.10'
|
||||||
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
|
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
|
||||||
print "omz: The minimum supported Zsh version is $min_zsh_version."
|
print "omz: The minimum supported Zsh version is $min_zsh_version."
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
local trash_dir="${HOME}/.Trash"
|
print -N "${@:a}" | xargs -0 osascript -e '
|
||||||
local trash_item
|
on run theFilePaths
|
||||||
local item
|
tell application "Finder"
|
||||||
for item in "${@}"; do
|
set thePOSIXFiles to {}
|
||||||
if [[ -e "${item}" ]] || [[ -L "${item}" ]]; then
|
repeat with aFilePath in theFilePaths
|
||||||
trash_item="${trash_dir}/${item:t}"
|
set aPOSIXFile to aFilePath as POSIX file
|
||||||
if [[ -e "${trash_item}" ]] || [[ -L "${trash_item}" ]]; then
|
if exists aPOSIXFile
|
||||||
trash_item="${trash_item} $(date "+%H-%M-%S")"
|
set end of thePOSIXFiles to aPOSIXFile
|
||||||
fi
|
end if
|
||||||
mv -f "${item}" "${trash_item}"
|
end repeat
|
||||||
fi
|
move every item of thePOSIXFiles to trash
|
||||||
done
|
end tell
|
||||||
|
end run
|
||||||
|
' &>/dev/null
|
||||||
|
|
||||||
|
if (( $? != 0)); then
|
||||||
|
print "$0: failed to move one or more items" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue