This macro has been incredibly useful. One issue I've run into is that I have a few small macros that run whenever I switch apps (maintaining Stream Deck icons), so the list will often look like this:
Then I created this macro to call the subroutine and filter unwanted macros. Note that you'll want to modify the contents of local_Macros to Exclude
DOWNLOAD Macro File: Last N Macros Run (Filtered).kmmacros (32 KB) Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
@noisneil, there's one known limitation. If the macro name includes a close parenthesis the If action that includes matches will not successfully match.
For example, I have a macro named: 01)Toggle Smart Sort. If I put that exact string in local_Macros to Exclude then the filtering fails. (Note: I suspect that this is a Regular Expression issue, but even when I attempted to use the Filter Action—Encode for Regular Expression, the filtering failed. Maybe @ccstone, @drdrang or some other RegEx Ninja could explain.)
The good news is that the macro can be filtered if a substring of the macro name is entered in local_Macros to Exclude (in this example: Toggle Smart Sort).
Do you need a regex? I haven't fully followed the logic of the macros, but can you not use "contains" (which is also case-insensitive) instead of "matches"?
Unless it's because you want to include regex pattens in your exclusions list, in which case @peternlewis's post here might help.
Thanks @_jims. Very nicely put together and that filtering works perfectly! None of my macro names start with parentheses but quite a few have them near the end of their titles. All I've had to do is cut the name short and it still finds them.
The ideal scenario would probably be to do the filtering on the shell script side (not that I'd have a clue how of course), just because there are so many instances of those little macros, that I have to request a silly number of results. Here's what I get from requesting 500 results, which takes 12sec to process:
Nice thought regarding contains but I couldn't get that to work.
I was hoping to use RegEx specifications due to the flexibility. Unfortunately I wasn't thinking straight when I posted the macro earlier.
The problem is easily resolved by escaping the special character. In addition, I added a prefix (⇢ ) and suffix ($) to each macro in local_Macros to Exclude to prevent unintended matches.
Okay @noisneil, now that I look at the approach I used above, I'm embarrassed. I need to get more sleep.
This is much more efficient:
DOWNLOAD Macro File: Last N Macros Run (Filtered—Method 2).kmmacros (27 KB) Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
Sooo much quicker! The only downside is that, now that it's looking for a new line directly after the macro name, I can't shorten the name to exclude the trigger. As some of these macros are triggered when any application activates, the trigger could be anything.
Brilliant. I changed the regex to .*⇢ %Variable%local_Exclude%.*\n and it works nicely. Thanks @_jims!
I tried to automatically escape special characters, but it doesn't seem to do anything. Any idea what's wrong with it? Be handy to know for other applications.
This macro leverages @ccstone's excellent macro (recast as a subroutine) to generate a list of the most recently executed macros (filtered) presented in a Prompt With List (most recent on top).
When a macro is selected, it will be executed.
If the Shift (⇧) is down when it is selected, the macro will be found using Edit>Find>Find in All Macros….
DOWNLOAD Macro File: Execute or Find Recent Macro.kmmacros (32 KB) Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
Try downloading the main macro again (above). I think I may have mistakenly uploaded an incorrect version. Also, in this updated version I replaced tac with tail -r in the shell script. tac may not be available on your system.
After testing again, if you have any issues, please let me know.
Perhaps easier for @_jims to add a "Log" action to any subroutines to be tracked, then leverage your original script. I'll confess I haven't looked -- is there a particular format to log so the line gets picked up?