如何删除 iTerm2 里的所有颜色预设?

如何删除 iTerm2 里的所有颜色预设?

我从 github repo 导入了一堆 iTerm 颜色预设(没有计算,但如果我需要猜测的话,有 50 多个)。我知道如何删除每个单独的颜色预设,但有什么方法可以一次性删除它们(我不想为每个预设手动删除它们)?

现在它看起来是这样的:

在此处输入图片描述

答案1

您可能能够使用在要点中找到的脚本 批量删除 iTerm2 配色方案

我重述以下要点:

# There was a day where I have too many color schemes in iTerm2 and I want to remove them all.
# iTerm2 doesn't have "bulk remove" and it was literally painful to delete them one-by-one.

# iTerm2 save it's preference in ~/Library/Preferences/com.googlecode.iterm2.plist in a binary format
# What you need to do is basically copy that somewhere, convert to xml and remove color schemes in the xml files.

$ cd /tmp/
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist .
$ plutil -convert xml1 com.googlecode.iterm2.plist
$ vi com.googlecode.iterm2.plist

# Now remove the color schemes in the <key> and <dict> tags, 
# to make it easier, record a macro in vi to remove the key (e.g: Desert/Solarized) using `dd`,
# and then remove its color dict with `dat` (delete around tag), and repeat the macro until 
# all color schemes you want to delete is gone.

# Save the file, and copy it back:

$ cp com.googlecode.iterm2.plist ~/Library/Preferences/

# Note that iTerm2 has 'fallback' configuration in case something is wrong,
# You might want to remove them as well:

$ rm ~/Library/Preferences/iTerm2.plist
$ rm ~/Library/Preferences/net.sourceforge.iTerm.plist

# Now reload the configuration

$ cd ~/Library/Preferences/
$ defaults read com.googlecode.iterm2

# Restart iTerm, and check the color-scheme list in the Preferences menu, you shouldn't see the old color-schemes now.

相关内容