如何在 plist 中的数组对象中设置布尔值
我正在尝试通过修改 Textmate 的 plist 来修改我的设置。这是我到目前为止所得到的:
defaults write com.macromates.textmate OakShellVariables -array-add '{value = "hello"; variable = "TM_HELLO";}'
这将为 Textmate 添加一个新的 shell 变量。我想通过命令行来执行此操作,以便我可以编写脚本。上面的工作正常,但我还想将启用的键(这是一个布尔值)设置为 true。不幸的是,我似乎无法找出实现此目的的正确语法。我所有的尝试都会导致将启用的键设置为字符串而不是布尔值。例如:
defaults write com.macromates.textmate OakShellVariables -array-add '{enabled = true ;value = "hello"; variable = "TM_HELLO";}
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";}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
迈克尔就是这样做的。我也在寻找同样的东西,并且碰巧找到了答案。我想我会分享。示例如下所示。
这些是数据类型:
- string
- boolean< real>
- 实数
- 整数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.
These are the data types:
<string></string>
- string<false/><true/>
- boolean<real></real>
- real<integer></integer>
- integer