-
-
Save dedy-purwanto/11312110 to your computer and use it in GitHub Desktop.
# 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. |
You are awesome. Thanks for sharing.
π Thanks for sharing
Thanks for sharing this trick
Great. Thank you!
Saved a bunch of time, thank you!
Big thx.
This isn't necessarily easier, but as an alternative for those who prefer to use GUI: Open the plist file with Xcode and use the plist editor to delete the desired key/value pairs under the 'Color Custom Presets' property.
thanks a lot!
π
Thanks!
nice, 3q.
Yep, Very useful! π
very useful π
Thank you. Saved a lot of my time.
This was exactly what I needed. Thank you.
If you have Xcode installed you can edit the file directly. When iTerm2 is closed, run the following in Terminal.app:
$ open ~/Library/Preferences/com.googlecode.iterm2.plist
Then you get a nice GUI editor. Remove any desired color settings under the key Custom Color Presets, save the file and restart iTerm.
If you have Xcode installed you can edit the file directly. When iTerm2 is closed, run the following in Terminal.app:
$ open ~/Library/Preferences/com.googlecode.iterm2.plist
Then you get a nice GUI editor. Remove any desired color settings under the key Custom Color Presets, save the file and restart iTerm.
very useful
Works great! thanks for sharing
Fantastic! Thank you!
Works like charm $ open ~/Library/Preferences/com.googlecode.iterm2.plist
π
π
Save my life!! This is awesome! π₯³
Modified self-contained version that does everything for the lazy
#!/usr/bin/env bash
# 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
# 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.
# backup the plist file just in case
cp com.googlecode.iterm2.plist com.googlecode.iterm2.plist.bkp
# remove the tags
python - << EOF
#!/usr/bin/env python3
import xml.etree.ElementTree as et
path = "com.googlecode.iterm2.plist"
tree = et.parse(path)
root = tree.getroot()
dict_element = root.find("dict")
found_custom_color_presets = False
for child in dict_element:
if found_custom_color_presets:
dict_element = child
break
elif child.tag == "key" and child.text == "Custom Color Presets":
found_custom_color_presets = True
to_remove = list()
next_is_dict_to_remove = False
for child in dict_element:
if next_is_dict_to_remove:
to_remove.append(child)
next_is_dict_to_remove = False
elif child.tag == "key" and child.text.startswith("base16"):
to_remove.append(child)
next_is_dict_to_remove = True
for child in to_remove:
dict_element.remove(child)
with open("com.googlecode.iterm2.plist", "w") as f:
f.write(et.tostring(root).decode())
EOF
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 -f ~/Library/Preferences/iTerm2.plist
rm -f ~/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.
π
Thanks π€
Thanks very much this was super useful π
ηιΌ
π
Super helpful. Thanks!