Skip to content

Instantly share code, notes, and snippets.

@reitermarkus
Last active June 16, 2017 13:45
Show Gist options
  • Select an option

  • Save reitermarkus/a313fad0d1a05b2e760c1fc740abc379 to your computer and use it in GitHub Desktop.

Select an option

Save reitermarkus/a313fad0d1a05b2e760c1fc740abc379 to your computer and use it in GitHub Desktop.
#!/usr/bin/xcrun swift
import Cocoa
import Foundation
DispatchQueue.main.async {
let arguments = CommandLine.arguments.dropFirst()
let urls = arguments.map { URL(fileURLWithPath: $0) }
NSWorkspace.shared.recycle(urls) { (dict, error) in
guard error != nil else {
exit(0)
}
let untrashedURLS = urls.filter { !dict.keys.contains($0) }
untrashedURLS.forEach {
fputs($0.path + "\n", stderr)
}
exit(1)
}
}
RunLoop.main.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment