Created
August 7, 2017 20:54
-
-
Save mistadikay/844ca188e3b6d3db1d629825715c25fe to your computer and use it in GitHub Desktop.
Run this script on Cmd + W to prevent closing the last tab in Safari
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
tell application "Safari" | |
set numWin to count of tabs of window 1 | |
if numWin > 1 then | |
close current tab of front window | |
end if | |
if numWin = 1 then | |
tell application "Safari" to activate | |
tell application "System Events" | |
keystroke "t" using command down | |
end tell | |
tell window 1 of application "Safari" | |
close (tabs where index < (get index of current tab)) | |
end tell | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment