What to search to find what macro is using certain string in Shell Script action

I had a script getBreak.ts in my file system somewhere. It was called here:

I wanted to rename the script to get-break.ts which means I need to update it in KM too like so:

Great. But now I have another script like countLines.ts that I want to do same on but I don't remember the KM macro this countLines.ts is being called in. Is there something I can grep to know which macro calls the script?


You should be able to just enter countLines.ts in the search box at the top right of the editor window, and you'll get a list of all macros it appears in.


1 Like

That's nice and works.

Still would love to know the location I can grep. Say if I want to automate updating it without using KM UI.

The macros live in your user's Library > Application Support > Keyboard Maestro folder, in a file named Keyboard Maestro Macros.plist. However, plist files are binary, so before you can grep it, you'd need to convert it to XML, run your search, then convert it back.

And while that would work probably 99.999% of the time, losing all your macros on that .001% could really ruin your day. (And it's also XML, so you need to be careful not to ruin the structure during your editing.)

But if you really want to try…

plutil -convert xml1 "Keyboard Maestro Macros.plist"

That will convert it to text, and you can now use any text manipulation tools you want. When done:

plutil -convert binary1 "Keyboard Maestro Macros.plist"

To convert it back to binary. You should make sure that the Keyboard Maestro editor and macro are both quit first.

I think doing anything directly to that file is a terrible idea. The risks of making a mistake and losing my macros makes it a no-go for me; I'll only edit my macros from within the editor. If you're going to try this, I strongly suggest you have a good verified backup before you start.

I also don't know 100% that it will work in Keyboard Maestro after converting, editing, and reconverting. In theory it should, but I am not going to test it :).


1 Like