In Script Debugger I often create new “Untitled” tabs just to test some lines of code. After a couple of hours I end up with 1 or 2 “real” tabs (the actual script) and a dozen of “Untitled” tabs.
This can get annoying when I quit SD, because it doesn’t keep the “Untitled” tabs for the next session, instead it asks me to save each one individually with a proper name.
Since these “Untitled” tabs are just temporary documents, I’m not interested in saving each one “properly”. However, if the project isn’t finished yet, I do want to keep them for the next session.
Here’s where the macro comes in:
The macro scans SD’s open documents for “untitled” documents. If it finds one it saves it as text script in a predefined location (i.e. your folder for temporary scripts). File name will be the current time stamp (Apple Reference Time), so it is assured that each “Untitled” gets a different name.
Next time when I open SD, these files will be auto-opened (assuming the SD preferences are set accordingly).
It comes with three triggers:
-
When SD activates:
- All “Untitled” tabs are saved.
-
Hotkey ⌃⌥⌘S:
- All “Untitled” tabs are saved.
- Selects Save All from SD’s File menu.
-
Hotkey ⌘Q:
- All “Untitled” tabs are saved.
- Quits SD.
- Sans the temporary folder and trashes previously saved temporary scripts that are older than 1 week (last used date).[1]
[1] In the downloadable macro purging is disabled by default. Before enabling it make sure that your temporary folder doesn’t contain any other files that might match the naming scheme, or change the naming scheme to your needs.
To use the macro you have to set the path to your preferred temporary scripts location. (Drag the desired folder into the text field of the green action.)
Save “Untitled” SD Tabs.kmmacros (11.5 KB)
Edit (2016-10-16 01:20 Z):
Here is an additional Launcher Macro:
Save “Untitled” SD Tabs (Additional Launcher).kmmacros (3.3 KB)
This launcher macro just provides a “Deactivates” trigger for the main macro.
- The launcher macro must be in the Global Macro Group.
- The main macro (‘Save “Untitled” SD Tabs’) must be in the Script Debugger macro group.
If you use this launcher macro you should remove the “Activates” trigger from the main macro.
Make sure that the link to the main macro (Execute macro: Save “Untitled” SD Tabs) is valid on your computer!
If it doesn’t work reselect the main macro from the Execute macro drop-down menu.
Update (2016-10-17 13:24 Z):
I added a If Script Debugger is running condition to the launcher macro. Otherwise it would relaunch SD immediately after quitting. (Due to the AppleScript test in the main macro.)