How to set a boolean value in an array object in a plist
Asked Answered
S

1

8

I'm trying to modify my settings for Textmate by modifying its plist. Here's what I've got so far:

defaults write com.macromates.textmate OakShellVariables -array-add '{value = "hello"; variable = "TM_HELLO";}'

This will add in a new shell variable for Textmate. I'm wanting to do this via the command line so that I can script it. The above works fine but I also want to set the enabled key (which is a boolean) to true. Unfortunately, I can't seem to figure out the correct syntax to achieve this. All my attempts result in setting the enabled key to be a string instead of a boolean. For example:

defaults write com.macromates.textmate OakShellVariables -array-add '{enabled = true ;value = "hello"; variable = "TM_HELLO";}
Sexagenarian answered 16/11, 2010 at 11:0 Comment(0)
A
12

This is how you do it Michael. I was looking for the same thing, and I happened to come across the answer. Thought I'd share. Example shown below.

defaults write com.apple.dashboard layer-gadgets -array-add "<dict><key>32bit</key><false/></dict>";

These are the data types:

  • <string></string> - string
  • <false/><true/> - boolean
  • <real></real> - real
  • <integer></integer> - integer
Abbeyabbi answered 19/4, 2011 at 15:57 Comment(1)
It's better to use e.g. -string, -dict etc. instead of "<string></string>", as Apple will take care for the correct syntax. So you should be safe, also for future changes.Gough

© 2022 - 2024 — McMap. All rights reserved.