英文:
Add Terminal to dock persistent-apps with default write with foreign language macOS
问题
将Google添加到Dock中的操作如下:
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
但是使用以下方式无法将终端添加到Dock中:
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Utilities/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Pääte</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
我希望保持计算机的语言设置为芬兰语,同时仍然能够通过我的Dotfiles自定义Dock。这个问题也存在于MacOS的默认应用程序,如终端和日历等。
英文:
Adding Google to the dock works like this:
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
But adding Terminal to the dock does not work with these:
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Utilities/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Pääte</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
I would love to keep my computers language as Finnish, while still being able to have a customised dock through my Dotfiles. And this same issue is persistent with the MacOS default apps, such as terminal and calendar etc.
答案1
得分: 5
我认为我和你有类似的问题,但我不认为这是本地化问题。深入挖掘后,我觉得这些应用程序似乎并不在它们看起来的地方。
尝试前往 Finder 中的 /Applications/Lisäohjelmat
。现在打开终端并执行 ls /Applications/Lisäohjelmat
。注意有什么不同吗?在我的英语语言版本的 macOS 上,当我 ls
/Applications/Utilities
目录时,我看到一个空文件夹!
据我了解,现在大多数系统应用程序都驻留在 /System/Applications/
目录中,我想你的情况可能也是如此。
综合起来,我的首次运行 Dock 设置如下(在确认应用程序位置后根据你的需求进行调整):
#!/bin/sh
set -e
__dock_item() {
printf ''%s%s%s%s%s'' \
'<dict><key>tile-data</key><dict><key>file-data</key><dict>' \
'<key>_CFURLString</key><string>' \
"$1" \
'</string><key>_CFURLStringType</key><integer>0</integer>' \
'</dict></dict></dict>'
}
printf ''%s'' 'Setting up Dock icons...'
defaults write com.apple.dock \
persistent-apps -array "$(__dock_item /Applications/Safari.app)" \
"$(__dock_item /System/Applications/Utilities/Terminal.app)"
killall Dock
printf ''%s\n'' ' done.'
注意:我使用了
-array
而不是-array-add
,它会完全清除数组并将其设置为我提供的内容。
希望这有所帮助,祝好运!
英文:
I believe I have a similar problem to you, however, I do not think it‘s a localisation issue. Digging deeper it looks to me that these apps aren‘t really where they seem.
Try going to /Applications/Lisäohjelmat
in the Finder. Now open up Terminal and do ls /Applications/Lisäohjelmat
. Notice a difference? On my English language version of macOS, when I ls
the /Applications/Utilities
directory I see an empty folder!
As far as I can gather most of the System applications now reside in /System/Applications/
and I would assume that perhaps this is the case for you too.
Bringing it all together, my first-run Dock setup looks like (adjust for your needs after confirming where the applications are):
#!/bin/sh
set -e
__dock_item() {
printf '%s%s%s%s%s' \
'<dict><key>tile-data</key><dict><key>file-data</key><dict>' \
'<key>_CFURLString</key><string>' \
"$1" \
'</string><key>_CFURLStringType</key><integer>0</integer>' \
'</dict></dict></dict>'
}
printf '%s' 'Setting up Dock icons...'
defaults write com.apple.dock \
persistent-apps -array "$(__dock_item /Applications/Safari.app)" \
"$(__dock_item /System/Applications/Utilities/Terminal.app)"
killall Dock
printf '%s\n' ' done.'
> Note: I have used -array
instead of -array-add
which just completely clears the array and sets it to what I give.
Hope that helps and good luck!
答案2
得分: 0
我明白了,以下是翻译好的部分:
# 清除项目
defaults write com.apple.dock persistent-apps -array
for dockItem in {/System/Applications/{“Mail”,”Notes”,”System Preferences”,”App Store”,”Preview”},/Applications/{“iTerm”,”Visual Studio Code”,”Brave Browser”}}.app; do
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>'$dockItem'</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
done
请注意,我已经根据您的要求将代码部分保持不变。如果您需要任何其他帮助,请随时告诉我。
英文:
For me, I do something like this:
# clear items
defaults write com.apple.dock persistent-apps -array
for dockItem in {/System/Applications/{"Mail","Notes","System Preferences","App Store","Preview"},/Applications/{"iTerm","Visual Studio Code","Brave Browser"}}.app; do
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>'$dockItem'</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
done
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论