-字符串中正确的反斜杠定义(macOS默认通过外壳写入)

问题描述 投票:1回答:1

我正在尝试从终端设置macOS键盘快捷键(ctrl+shift+up_arrow

从“系统偏好设置”手动创建后,我发现'^$\\U2191'是我要查找的字符串。

所以:

defaults write com.hello.app NSUserKeyEquivalents -dict-add 'Test' -string '^$\\U2191'

但是,这是我通过运行defaults read com.hello.app NSUserKeyEquivalents得到的:

{"Test" = "^$\\\\\\\\U2191";}

为什么每个反斜杠都重复两次?如何正确输入only两个反斜杠?

macos shell nsdictionary nsuserdefaults
1个回答
0
投票

-string参数使用双引号(“)而不是单引号('):

defaults write com.hello.app NSUserKeyEquivalents -dict-add 'Test' -string "^$\\U2191"

© www.soinside.com 2019 - 2024. All rights reserved.