From 264f006c4b56b3330381168e2ac815751d39dc9d Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Tue, 11 Aug 2020 17:14:33 -0600 Subject: [PATCH] Creates syntactically valid old-style ASCII property lists This uses a combination of `plutil` and `pl` to create the ASCII format property list representation. First, `plutil` converts the property list to XML format for consumption by `pl`. Then `pl` converts the XML into old-style ASCII format. The output from `pl` is formatted identically to that of `defaults`. This also adds a 'Convert to Pretty ASCII' command in order to preserve the existing functionality that uses `pretty_plist`. --- Commands/Convert to Old-Style ASCII.plist | 7 +++-- Commands/Convert to Pretty ASCII.tmCommand | 32 ++++++++++++++++++++++ info.plist | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 Commands/Convert to Pretty ASCII.tmCommand diff --git a/Commands/Convert to Old-Style ASCII.plist b/Commands/Convert to Old-Style ASCII.plist index 9e6d064..06e1da8 100644 --- a/Commands/Convert to Old-Style ASCII.plist +++ b/Commands/Convert to Old-Style ASCII.plist @@ -6,7 +6,10 @@ nop command #!/bin/sh -exec "${TM_BUNDLE_SUPPORT}/bin/pretty_plist" +if ! /usr/bin/plutil -convert xml1 -o - -- - | /usr/bin/pl; then + . "$TM_SUPPORT_PATH/lib/bash_init.sh" + exit_show_tool_tip +fi input document @@ -23,7 +26,7 @@ exec "${TM_BUNDLE_SUPPORT}/bin/pretty_plist" outputLocation newWindow scope - text.xml.plist, source.plist.binary + source.plist, text.xml.plist uuid 827E8A23-2C7A-4BDD-987F-A3B67B51F239 version diff --git a/Commands/Convert to Pretty ASCII.tmCommand b/Commands/Convert to Pretty ASCII.tmCommand new file mode 100644 index 0000000..413aca0 --- /dev/null +++ b/Commands/Convert to Pretty ASCII.tmCommand @@ -0,0 +1,32 @@ + + + + + beforeRunningCommand + nop + command + #!/bin/sh +exec "${TM_BUNDLE_SUPPORT}/bin/pretty_plist" + + input + document + inputFormat + text + keyEquivalent + ^H + name + Convert to Pretty ASCII + outputCaret + afterOutput + outputFormat + text + outputLocation + newWindow + scope + text.xml.plist, source.plist.binary + uuid + 7BB2E008-C144-4898-AD7D-3C27ACFBA10A + version + 2 + + diff --git a/info.plist b/info.plist index 76b9939..182fa11 100644 --- a/info.plist +++ b/info.plist @@ -54,6 +54,7 @@ 9EE98508-0697-4220-8D0F-A7E393703FE5 596D33EB-DACF-4B92-97E7-501AF5A3BAED 1CE7E2B3-0A9B-4BA4-A5ED-91E62775C93E + 7BB2E008-C144-4898-AD7D-3C27ACFBA10A name Convert