Closed zaaack closed 7 years ago
Blocked by https://github.com/sindresorhus/trash/issues/24 (Which is a long standing macOS bug...)
@sindresorhus What a pity..
@sindresorhus Can we store the original file's directory and just mv ~/.Trash/<lastFile> <lastDirectory>
? I tried and it looks totally feasible.
No, macOS renames duplicates in the trash, so original filenames are not guaranteed. The only workaround, as discussed in the original issue, is to parse the undocumented .DS_Store
file, but that's not something I have time or interest in doing.
@sindresorhus We can rename duplicates manually before putting to trash.
That's a slippery slope. And our mapping will easily get out of sync when the user trashes and restores in Finder, which we can't know about.
@sindresorhus But this wouldn't be a huge problem? We can rename with timestamp and rand id each time before moving to Trash, if the user restores in Finder, then it's handled by the user, he or she will know what he or she is doing since he is already using the command line. And if we cannot find the renamed file in Trash, we can print some message to show what happened.
Yes, I guess that would work, but it's not something I would be interested in maintaining.
@sindresorhus Fair enough.
Like
restore -last
,restore -last=<n>
, n means the last nth file/folder removed to trash.