Created
March 28, 2017 12:21
-
-
Save gmolop/3f43c6176ca05c4c2efc26b5094e21a2 to your computer and use it in GitHub Desktop.
Sublime Text 3: Confirm dialog to delete file(s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://stackoverflow.com/a/35630637/1601332 | |
# Credit: @iron77 | |
# File path: ~/Library/Application Support/Sublime Text 3/Packages/User/confirm_delete.py | |
from Default.side_bar import * | |
class DeleteFileCommand(sublime_plugin.WindowCommand): | |
def run(self, files): | |
if len(files) == 1: | |
message = "Delete File %s?" % files[0] | |
else: | |
message = "Delete %d Files?" % len(files) | |
if sublime.ok_cancel_dialog(message, "Delete") != True: | |
return | |
# Import send2trash on demand, to avoid initialising ctypes for as long as possible | |
import Default.send2trash as send2trash | |
for f in files: | |
v = self.window.find_open_file(f) | |
if v != None and not v.close(): | |
return | |
send2trash.send2trash(f) | |
def is_visible(self, files): | |
return len(files) > 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment