使用默认值从Mac上的命令行修改Plist [英] modifying a Plist from command line on Mac using Defaults

查看:2531
本文介绍了使用默认值从Mac上的命令行修改Plist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何使用默认值从命令行修改Plist文件?
目前在 URL类型数组下有两个字典;我需要添加另一个。

Does any one know how to modify a Plist file from command line using defaults? Currently there are two Dictionaries under the URL types array; I need to add another.

我试过的每个命令都替换了整个字典,或者创建了一个名为 URL types 而不是编辑它。关于如何在默认值(控制台Mac应用程序)和不是 PlistBuddy如何做到这一点的任何想法

Every command i've tried have either replaced the entire dictionary, or created a new array called URL types instead of editing it. Any ideas of how this can be done in defaults (the console Mac app) and not PlistBuddy?

推荐答案

p>在文本编辑器中打开Info.plist以查看实际的标识符。

Open the Info.plist in a text editor to see the actual identifiers.

defaults write ~/Path/to/Info.plist CFBundleURLTypes -array-add '<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>Mac App Store URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>macappstore</string>
</array>
</dict>'

pbpaste |

pbpaste | pl converts the XML to the old-style format.

默认写入Info.plist CFBundleURLTypes -array-add' {CFBundleTypeRole = Viewer; FBundleURLName =Mac App Store URL; CFBundleURLSchemes =(macappstore);}'

这篇关于使用默认值从Mac上的命令行修改Plist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆