Command line 如何通过脚本/命令行在iTerm2上设置xterm-256colors

Command line 如何通过脚本/命令行在iTerm2上设置xterm-256colors,command-line,xterm,iterm,iterm2,256color,Command Line,Xterm,Iterm,Iterm2,256color,在iTerm2中,我们可以通过进入Preferences->Profiles->Terminal->Terminal->Terminal Emulation->Report Terminal Type并选择xterm-256color 我想添加到dotfile的安装脚本中,这样就不必手动更改它。 有没有办法通过命令行设置此选项?可能是通过iTerm本身,也可能是通过苹果的默认写入….. 谢谢大家! 在~/Library/Preferences文件夹中有一个名为com.googlecode.ite

在iTerm2中,我们可以通过进入
Preferences->Profiles->Terminal->Terminal->Terminal Emulation->Report Terminal Type
并选择
xterm-256color

我想添加到dotfile的安装脚本中,这样就不必手动更改它。 有没有办法通过命令行设置此选项?可能是通过iTerm本身,也可能是通过苹果的
默认写入…..


谢谢大家!

~/Library/Preferences
文件夹中有一个名为
com.googlecode.iterm2.plist
的文件。此文件包含您的所有iTerm首选项。我喜欢做的是在我的dotfilerepo中保留一份首选项文件的副本。在新系统上安装时,我会通过安装脚本将其复制到
~/Library/Preferences


希望有帮助

默认值仅在设置为顶级键时有效,例如

[admin@mb-125:~] : defaults read com.googlecode.iterm2 | grep -i promptonquit
    PromptOnQuit = 1;
[admin@mb-125:~] : defaults write com.googlecode.iterm2 PromptOnQuit -bool FALSE
[admin@mb-125:~] : defaults read com.googlecode.iterm2 | grep -i promptonquit
    PromptOnQuit = 0;
xterm-256color是字典的一部分,我们需要使用plistbuddy来更改它,下面是查看当前设置的命令

[admin@mb-125:~] : /usr/libexec/PlistBuddy -c "Print :\"New Bookmarks\":0:\"Terminal Type\"" Library/Preferences/com.googlecode.iterm2.plist 
xterm-256color
这就是从命令行更改它的方式

[admin@mb-125:~] : /usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:\"Terminal Type\" xterm" Library/Preferences/com.googlecode.iterm2.plist 
[admin@mb-125:~] : /usr/libexec/PlistBuddy -c "Print :\"New Bookmarks\":0:\"Terminal Type\"" Library/Preferences/com.googlecode.iterm2.plist 
xterm