Close and Delete

Summary: Closes the frontmost document and moves it to the trash without a warning.
Requires: BBEdit 8
Suggested Key Binding: Command-Shift-W
Last Modified: 2019-05-24

Description

BBEdit has a great feature called Close & Delete, which is available when you hold down Shift and view the File menu. In BBEdit 7.0 and later, the utility of this time-saving feature is greatly diminished because BBEdit asks if you’re sure that you want to delete the file. This script restores the old behavior of the command. If you delete the file by accident, you can always recover it from the trash can.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

tell application "BBEdit"
    
if class of window 1 is text window then
        
set f to file of document 1 of text window 1
        
close document 1 of text window 1 saving no
    
else
        
set f to file of window 1
        
close window 1 saving no
    
end if
end tell

tell application "Finder"
    
move f to trash
end tell