简体   繁体   English

使用OSX defaults命令更改Iterm2设置

[英]Change Iterm2 settings with OSX defaults command

I am trying to do the following 我正在尝试执行以下操作

disable Iterm2 settings like "Draw bold text in bold font" from COMMAND line, I know it is easy to disable with few mouse clicks, because I am using Boxen to setup my Mac, just want to be able to get some application settings sorted as well. 从COMMAND行禁用Iterm2设置,如“以粗体字体绘制粗体文字”,我知道只需点击几下鼠标即可轻松禁用,因为我使用Boxen设置我的Mac,只是希望能够将某些应用程序设置排序为好。

I run following command to verify the settings first 我运行以下命令首先验证设置

defaults read com.googlecode.iterm2 | grep -i bold

it returns 它返回

"Bold Color" =             {
        "Use Bold Font" = 1;
        "Use Bright Bold" = 1;

That looks good and when I try to modify it, following command did not work, it created another key. 这看起来不错,当我尝试修改它时,以下命令不起作用,它创建了另一个键。

defaults write com.googlecode.iterm2 '{ "Use Bold Font" = 0;}'

defaults read com.googlecode.iterm2 | grep -i bold
        "Bold Color" =             {
        "Use Bold Font" = 1;
        "Use Bright Bold" = 1;
"Use Bold Font" = 0;

so looks like "Use Bold Font" is a subkey or one level deep, I am not sure how to modify it. 看起来像“使用粗体字体”是一个子键或一个深度,我不知道如何修改它。

any suggestions? 有什么建议?

Did some research and found answer myself, post it here just to share with others 做了一些研究,发现自己回答,在这里张贴,只是为了与他人分享

"Use Bold Font" is part of a dictionary, and we need to use plistbuddy to change it, here is the command to see the current settings “使用粗体字体”是字典的一部分,我们需要使用plistbuddy来改变它,这里是查看当前设置的命令

[admin@mb-125:~] : /usr/libexec/PlistBuddy -c 'Print :"New Bookmarks":0:"Use Bold Font"' ~/Library/Preferences/com.googlecode.iterm2.plist
true

And this is how you change it from command line 这就是你如何从命令行更改它

[admin@mb-125:~] : /usr/libexec/PlistBuddy -c 'Set :"New Bookmarks":0:"Use Bold Font" false' ~/Library/Preferences/com.googlecode.iterm2.plist

Check again 再检查一遍

[admin@mb-125:~] : /usr/libexec/PlistBuddy -c 'Print :"New Bookmarks":0:"Use Bold Font"' ~/Library/Preferences/com.googlecode.iterm2.plist
false

So basically you should be able to change all the settings from command line. 所以基本上你应该可以从命令行更改所有设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM