I found this 4-year old topic
because I'm missing exactly this capability.
I thend to forget how to convert timezones in my DB to my local timezone so I created a macro which cuts out my current selection and puts the SQL code for converting the timezone around it.
Would be greate I could store this macro and maybe bind it to some shortcut.
This has not been implemented yet, partly because very few have shown an interest in it. I have added you vote for it so we will discuss it again.
If you happen to know jEdit, take a look at its macro system. Something like that would be fantastic. Macros are simply stored as files in a specific directory and its subdirectories. The content of that directory can be found in a macro menu. Every subdirectory is a sub-menu. Additionally keybindings are possible.
For anybody on a Mac, this might help. As you saw above, my goal was to have selected text to be surrounded by some fixed text which makes NySQL/MariaDB convert a column to my local timezone.
wolud become this
CONVERT_TZ(last_scan, '+00:00', @@global.time_zone) as last_scan
Here is how I do it now.
Copy attached script "TimeZoneConvert.scpt" into ~/Library/Scripts/DbVisualizer and note that this path will most probably not exist yet.
In Script Editor's preferences, (/Applications/Utilities/Script Editor) enable the script Menu.
When in DbVisualizer's Editor, select the word(s) you want to be surrounded by mentioned text. Then click the Script Menu -> DbVisualizer -> TimeZoneConvert and see how the text is replaced.
Open in Script Editor the TimeZoneConvert script and adjust it to you needs and store it under a different name. You can store as many other "Macros" as you want.
Great, thanks for sharing this script!
Bump. I still would love to have the ability to save and reuse my recorded macros
Some macros I have to repeatedly record quite often:
- Add double quotes around the word I'm currently at the end of
- Commify this number
- Strip single quotes from the word I'm currently at the end of
It would be a huge time saver to have a "Load previously saved macro" function and grab the macro definition from a pull down list.
I will add your vote for this.