Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify sub key in *plist files

I'm would like to modify a subkey in a plist file (i.e. "TB Item Identifiers"):

NSNavPanelExpandedStateForSaveMode = 1;
NSPreferencesContentSize = "{508, 413}";
NSPreferencesSelectedIndex = 6;
"NSToolbar Configuration BrowserWindowToolbarIdentifier" =     {
    "TB Display Mode" = 2;
    "TB Icon Size Mode" = 1;
    "TB Is Shown" = 1;
    "TB Item Identifiers" =         (
        BackForwardToolbarIdentifier,
        HomeToolbarIdentifier,
        InputFieldsToolbarIdentifier
    );
    "TB Size Mode" = 1;
    "TB Visibility Priority Values" =         {
        BackForwardToolbarIdentifier =             (
            999
        );
        InputFieldsToolbarIdentifier =             (
            1000
        );
    };
};

I'm using the following command in a shell script :

defaults write com.apple.file key keyvalue

So each time I want to change "TB Item Identifiers", I'm modifying the entire "NSToolbar Configuration BrowserWindowToolbarIdentifier". How to directly modify a plist sub key or a sub sub key ?

like image 827
Kami Avatar asked Sep 06 '25 16:09

Kami


1 Answers

Use the PlistBuddy

/usr/libexec/PlistBuddy -c "set Key:SubKey1:SubKey2:Subkey3 value" ./Path/To/Your.plist

like image 72
anon Avatar answered Sep 08 '25 10:09

anon