我想要一个域名 com.apple.keyboard.modifiermapping.1452-628-0
包含以下数组:
(
{
HIDKeyboardModifierMappingDst = 2;
HIDKeyboardModifierMappingSrc = 0;
},
{
HIDKeyboardModifierMappingDst = 0;
HIDKeyboardModifierMappingSrc = 2;
},
{
HIDKeyboardModifierMappingDst = 0;
HIDKeyboardModifierMappingSrc = 10;
}
)
我可以通过删除当前值并运行三个来实现它 -array-add
命令:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }'
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }'
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; }'
defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
我可以使用什么语法在单个命令中定义数组?
如果我运行以下脚本:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0 defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array '( { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; } )' defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
我在一个数组中得到一个数组:
( ( { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; } ) )
如果我尝试
-plist
代替-array
我得到了Unexpected argument
。如果我运行以下脚本:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0 defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array ' { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; }' defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
我收到语法错误
defaults[22044:679428] Could not parse: ... Try single-quoting it.
再次提问:我可以使用什么语法在单个命令中定义数组?