Frage

In iTerm2 we can set the xterm-256color option by going to Preferences -> Profiles -> Terminal -> Terminal Emulation -> Report Terminal Type and chosing xterm-256color

I want to add to my dotfile's installation script so I don't have to change it manually. Is there a way of setting this option via command line? Maybe via iTerm itself or maybe via apple's defaults write.....

Thank you!

War es hilfreich?

Lösung

default works only if the setting is a top level key, for example

[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 is part of a dictionary, and we need to use plistbuddy to change it, here is the command to see the current settings

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

And this is how you change it from command line

[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    

Andere Tipps

In the ~/Library/Preferences folder there's a file called com.googlecode.iterm2.plist. This file contains all your iTerm preferences. What I like to do is keep a copy of that preferences file inside my dotfile repo. When I'm installing on a new system I copy it into ~/Library/Preferences via my installation script .

Hope that helps!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top