Hopefully nothing of significance.
thank you Dan
Is there a difference in convenience, access, automation? Why use this over the built-in Export function?
Separate files for each macro.
Dan, not sure if you're still reading here, but I'm finally investing some time (after some painful sync-related lost work) in figuring out how to get your macros and git going for my collection. I have the basics working well now, I think, and have tested changing a macro and watching it roll into the repository.
My question—as a total git neophyte—is this: How do I use the repository to go back in time? Let's say I have Macro X, and it's in the repository. I then make a bunch of changes over time, with each winding up in the repository. But then I realize I've made a logic error, and need to go back to the version before I started making all the changes.
I can see all the changes in git (via SourceTree), but what's the actual mechanic of getting the original version back from the repository into KM (via your import macro, of course, but how do I get the old version, not the latest one that was saved when I last ran your export)?
thanks;
-rob.
That's a good question. I'll be thinking out loud here, so bear with me.
The first thing I'd do is make a copy of the folder that has all the macros, including the git repository (the git repository is a hidden folder called ".git"). That way you can put everything back if you/we mess up.
Do you happen to have a Time Machine backup that has the version you want? If so, that would be the easiest way to get it back. Just restore the folder for the macro. Then import it into KM. If it's what you want, you can do another SourceTree commit and you're good to go.
It gets more complicated if that doesn't work. Git doesn't make it easy to revert just one file/folder. It's totally doable, but it's more complicated than it should be.
So before I write up those steps, let me know if you have a backup, and that works for you.
Well, it was a theoretical question as it hasn't happened yet, but I have run into this exact scenario in the past. At that point, the way I handled it was whenever I started making substantive changes, I'd duplicate and disable the macro. At the end, I'd wind up with like 10 versions just sitting there, waiting to make sure I did what I meant to do :). I was hoping git might help make that process simpler if I just wrote a change to the VCS each time. But it sounds like not.
I would have a Time Machine backup, so that sounds like the route I'd take ... I was just hoping it'd be nice and easy with all the change data sitting there in git. I did some web searching, and it seems like this post has the process I'd follow using git?
-rob.
Wow, I didn't know you could do that! Of course, I haven't tried it, but it looks good.
You'd laugh at the steps I've used before to do this. So learning this is really helpful - thanks!
I'll experiment a bit later today with a test macro and see if it works. But if so, this could be exactly the solution I needed.
-rob.
Good idea to practice. By the way, git doesn't care about file timestamps. It compares the file's size and contents. Just thought you should know.
Yea, I know—I just meant I had other stuff to do first :).
-rob.
I know my comment was a non-sequitur. It's just something that was on my mind, so I blurted it out. It had nothing to do with anything you said. I'm like that sometimes.
@DanThomas Do you have any recommendations or tips for using VCS for sharing macros publicly?
This looks like an excellent tool for internal/personal use, but because of the importer it probably isn't as good for publicly sharing a macro group.
Well, it depends on what you mean by "sharing" them. Several times I started a GitHub repository for sharing my stuff, but I didn't keep it updated. You can look at it for ideas, if you want.
I didn't have a clear idea when I originally asked that question, but now I've spent a bit of time fiddling with an Alfred workflow that taught me a better question to ask.
Has anyone spent any time using scripts (eg. python) to build/modify the .kmmacros file? For example, it would be nice for the README
bundled in a macro to be identical to the README
in a repository. A scripted build step could do that, and it could be automated using GitHub actions. So I guess the question is has anyone started building infrastructure like that?
As an example, here is an Alfred workflow that does some modifications to it's info.plist
file: alfred-jetbrains-projects/build.py at master · artemy/alfred-jetbrains-projects · GitHub
How exactly would you "bundle a readme into a macro"?
I was poking around inside the .kmmacros
file and it looks like I could probably search the plist/XML
file for comment blocks with a certain title. Then I could probably replace the data
with whatever I want programmatically.
<dict>
<key>ActionUID</key>
<integer>16401364</integer>
<key>MacroActionType</key>
<string>Comment</string>
<key>StyledText</key>
<data>
cnRmZAAAAAADAAAAAgAAAAcAAABU
WFQucnRmAQAAAC5AAgAAKwAAAAEA
AAA4AgAAe1xydGYxXGFuc2lcYW5z
aWNwZzEyNTJcY29jb2FydGYyNzA5
Clxjb2NvYXRleHRzY2FsaW5nMFxj
b2NvYXBsYXRmb3JtMHtcZm9udHRi
bFxmMFxmc3dpc3NcZmNoYXJzZXQw
IEhlbHZldGljYTt9CntcY29sb3J0
Ymw7XHJlZDI1NVxncmVlbjI1NVxi
bHVlMjU1O1xyZWQwXGdyZWVuMFxi
bHVlMDt9CntcKlxleHBhbmRlZGNv
bG9ydGJsOztcY3NzcmdiXGMwXGMw
XGMwXGM4NDcwNlxjbmFtZSBjb250
cm9sVGV4dENvbG9yO30KXHBhcmRc
dHg1NjBcdHgxMTIwXHR4MTY4MFx0
eDIyNDBcdHgyODAwXHR4MzM2MFx0
eDM5MjBcdHg0NDgwXHR4NTA0MFx0
eDU2MDBcdHg2MTYwXHR4NjcyMFxw
YXJkaXJuYXR1cmFsXHBhcnRpZ2h0
ZW5mYWN0b3IwCgpcZjBcZnMyNiBc
Y2YyIER1ZSB0byBhIE1hY09TIGJ1
ZywgS00gaGFzIGFkZGVkIGEgZGVs
YXkgdG8gZnVuY3Rpb25zIHRoYXQg
bWFuaXB1bGF0ZSB0aGUgd2luZG93
IGZyYW1lIHN0YXJ0aW5nIGluIDEx
LjAuMi4gUnVuIHRoaXMgbWFjcm8g
bWFudWFsbHkgaWYgeW91IHdvdWxk
IGxpa2UgdG8gY2hlY2sgd2hhdCBk
ZWxheSBpcyBzZXQgb24geW91ciBz
eXN0ZW0ufQEAAAAjAAAAAQAAAAcA
AABUWFQucnRmEAAAAG5SKWe2AQAA
AAAAAAAAAAA=
</data>
<key>Title</key>
<string>README</string>
</dict>
I just did something similar here, but I haven't tried this with a KM macro yet: alfred-jetbrains-projects/build.py at 3e960b71bb4b7c69dd8ff0780584c9d23985686d · gaufde/alfred-jetbrains-projects · GitHub
Tyle "StyledText" key in a comment contains RTF data in base64. Not sure you want to mess with that.
Tyle "StyledText" key in a comment contains RTF data in base64. Not sure you want to mess with that.
I was thinking that I would replace all of the text with completely new content. I haven't worked with RTF data like that, but there must be some way to take a .md
file, convert it to RTF, and then encode it for insertion. Or would that still be a bad idea?
I suppose it could be done, but I'm gonna drop out here. Why don't you start a new topic and see what other people have to offer.