Improve Git Diff Readability for JSON-Based BTT Exports

I’m using Git to manage my BTT changes, and I appreciate that the exported format is JSON, making it easier to read.

However, I’ve noticed that numerous changes in the preset can make it challenging to discern specific modifications when running git diff.

Could you suggest any solutions to improve this?

do you have an example? In general the JSON should already be sorted for export.

git diff has an option textconv, which in theory allows to ignore certain parts - but it really depends on what you'd need to ignore

This is not the best example but I often find that there are big diffs for simple and irrelevant modifications.

Here's an example for a simple "note" change in one of my triggers:

diff --git a/bettertouchtool/Default.bttpreset b/bettertouchtool/Default.bttpreset
index b37c03d..ba0de41 100644
--- a/bettertouchtool/Default.bttpreset
+++ b/bettertouchtool/Default.bttpreset
@@ -183,7 +183,7 @@
     "BSTSnapAreaDefaultShowPictogram" : false,
     "BSTSnapAreaDefaultPictoDistanceFromBottom" : 0.10000000149011612
   },
-  "BTTPresetUUID" : "6567625A-1689-4F93-9937-97CE96128879",
+  "BTTPresetUUID" : "C7C1795F-D7AA-4B53-9EFE-E5BBC7A39659",
   "BTTPresetContent" : [
     {
       "BTTAppBundleIdentifier" : "com.apple.iCal",
@@ -4141,7 +4141,7 @@
       "BTTTriggers" : [
         {
           "BTTActionCategory" : 0,
-          "BTTLastUpdatedAt" : 1730819038.3789191,
+          "BTTLastUpdatedAt" : 1730825264.7634211,
           "BTTTriggerType" : 0,
           "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
           "BTTUUID" : "C1CE4E4E-985E-44A7-9132-CDF235FBAE16",
@@ -4155,7 +4155,7 @@
           "BTTEnabled2" : 1,
           "BTTShortcutKeyCode" : 123,
           "BTTShortcutModifierKeys" : 8388608,
-          "BTTOrder" : 0,
+          "BTTOrder" : 1,
           "BTTAutoAdaptToKeyboardLayout" : 0,
           "BTTAdditionalActions" : [
             {
@@ -4185,11 +4185,11 @@
               "BTTAutoAdaptToKeyboardLayout" : 0
             }
           ],
-          "BTTGestureNotes" : "Previus product image"
+          "BTTGestureNotes" : "Previus Product Image"
         },
         {
           "BTTActionCategory" : 0,
-          "BTTLastUpdatedAt" : 1730819038.3788428,
+          "BTTLastUpdatedAt" : 1730825272.6183629,
           "BTTTriggerType" : 0,
           "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
           "BTTUUID" : "BDF3544B-6CC1-4307-8017-AB0FC905D956",
@@ -4203,7 +4203,7 @@
           "BTTEnabled2" : 1,
           "BTTShortcutKeyCode" : 124,
           "BTTShortcutModifierKeys" : 8388608,
-          "BTTOrder" : 1,
+          "BTTOrder" : 2,
           "BTTAutoAdaptToKeyboardLayout" : 0,
           "BTTAdditionalActions" : [
             {
@@ -4233,7 +4233,7 @@
               "BTTAutoAdaptToKeyboardLayout" : 0
             }
           ],
-          "BTTGestureNotes" : "Next product image"
+          "BTTGestureNotes" : "Next Product Image"
         }
       ]
     },

If I read correctly it's "just" the Preset UUID some modification time stamps and the captialization of the BTTGestureNotes that has changed.

What kind of diff viewer are you using? I'd think this would be still quite readable in a good viewer

That's why I said that the example wasn't the best one :slight_smile:

For Git, I'm usually using SourceTree and command line.

Below, I've added a slightly better example, which introduces a single shortcut and the export of this trigger took 45 lines in the bttpreset file:

diff --git a/bettertouchtool/Default.bttpreset b/bettertouchtool/Default.bttpreset
index 5df1a87..cf14e5e 100644
--- a/bettertouchtool/Default.bttpreset
+++ b/bettertouchtool/Default.bttpreset
@@ -183,7 +183,7 @@
     "BSTSnapAreaDefaultShowPictogram" : false,
     "BSTSnapAreaDefaultPictoDistanceFromBottom" : 0.10000000149011612
   },
-  "BTTPresetUUID" : "059F143E-19C5-4831-BB85-22212D782B8F",
+  "BTTPresetUUID" : "187E568B-8CBC-43BB-AE93-EEBFB357180D",
   "BTTPresetContent" : [
     {
       "BTTAppBundleIdentifier" : "com.apple.iCal",
@@ -4141,7 +4141,7 @@
       "BTTTriggers" : [
         {
           "BTTActionCategory" : 0,
-          "BTTLastUpdatedAt" : 1730825752.798893,
+          "BTTLastUpdatedAt" : 1730825858.5458369,
           "BTTTriggerType" : 0,
           "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
           "BTTUUID" : "C1CE4E4E-985E-44A7-9132-CDF235FBAE16",
@@ -4155,7 +4155,7 @@
           "BTTEnabled2" : 1,
           "BTTShortcutKeyCode" : 123,
           "BTTShortcutModifierKeys" : 8388608,
-          "BTTOrder" : 1,
+          "BTTOrder" : 0,
           "BTTAutoAdaptToKeyboardLayout" : 0,
           "BTTAdditionalActions" : [
             {
@@ -4189,7 +4189,7 @@
         },
         {
           "BTTActionCategory" : 0,
-          "BTTLastUpdatedAt" : 1730825272.6183629,
+          "BTTLastUpdatedAt" : 1730825858.545753,
           "BTTTriggerType" : 0,
           "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
           "BTTUUID" : "BDF3544B-6CC1-4307-8017-AB0FC905D956",
@@ -4234,6 +4234,43 @@
             }
           ],
           "BTTGestureNotes" : "Next Product Image"
+        },
+        {
+          "BTTActionCategory" : 0,
+          "BTTLastUpdatedAt" : 1730825861.828887,
+          "BTTTriggerType" : 0,
+          "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
+          "BTTUUID" : "46A140D1-3932-4A94-B497-DB98A8252D60",
+          "BTTPredefinedActionType" : 366,
+          "BTTPredefinedActionName" : "Empty Placeholder",
+          "BTTAdditionalConfiguration" : "8388608",
+          "BTTKeyboardShortcutKeyboardType" : 0,
+          "BTTTriggerOnDown" : 1,
+          "BTTLayoutIndependentChar" : "UP",
+          "BTTEnabled" : 1,
+          "BTTEnabled2" : 1,
+          "BTTShortcutKeyCode" : 126,
+          "BTTShortcutModifierKeys" : 8388608,
+          "BTTOrder" : 1,
+          "BTTAutoAdaptToKeyboardLayout" : 0,
+          "BTTAdditionalActions" : [
+            {
+              "BTTActionCategory" : 0,
+              "BTTLastUpdatedAt" : 1730825864.603333,
+              "BTTTriggerParentUUID" : "46A140D1-3932-4A94-B497-DB98A8252D60",
+              "BTTIsPureAction" : true,
+              "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
+              "BTTUUID" : "79C835A3-3A6B-4A4D-91B6-AFC070079ECD",
+              "BTTLayoutIndependentActionChar" : "m",
+              "BTTShortcutToSend" : "56,55,46",
+              "BTTKeyboardShortcutKeyboardType" : 0,
+              "BTTEnabled" : 1,
+              "BTTEnabled2" : 1,
+              "BTTShortcutKeyCode" : -1,
+              "BTTOrder" : 3,
+              "BTTAutoAdaptToKeyboardLayout" : 0
+            }
+          ]
         }
       ]
     },

Personally I'm usually using visual studio code because I like their diff display:

code --diff preset1.bttpreset preset2.bttpreset

Your new example also looks OK to me, I think all these added properties are needed to fully describe the new shortcut :-/

That makes sense, I was just hoping for a more concise exports :slight_smile:

I'll check how complicated it would be to not export default values (e.g. BTTKeyboardShortcutKeyboardType would always be 0 by default, so I'd only need to export it if it's not 0). However that might add too much extra complexity to the code - not sure yet!

1 Like