How to export iTerm2 Profiles
ItermIterm2Iterm Problem Overview
I needed to reformat my computer and now I'm having trouble copying the settings/profiles over.
I copied the files in ~/Library/Application\ Support/iTerm/
I also copied ~/Library/Preferences/com.googlecode.iterm2.plist
but it keeps giving me this error:
Failed to load preferences from custom directory. Falling back to local copy.
Missing or malformed file at "/
com.googlecode.iterm2.plist"
I also tried saving the profile in a directory so I could send it but it doesn't work.
Here's the location:
iTerm ▶ General ▶ Preferences ▶ Save Settings To Folder
and here's the output:
Failed to copy preferences to custom directory. Copy
/Users/alexcory/Library/Preferences/com.googlecode.iterm2.plist
to Alex_Corys_iTerm_Configuration/com.googlecode.iterm2.plist:
No such process
The colors work, (found in the path below) but I'm not simply trying to save colors, but rather all my preferences.
iTerm ▶ Preferences ▶ Profiles ▶ Colors ▶ Load Presets ▶ Export
Does anyone know how to get this to work?
Iterm Solutions
Solution 1 - Iterm
If you have a look at Preferences -> General
you will notice at the bottom of the panel, there is a setting Load preferences from a custom folder or URL:
. There is a button next to it Save settings to Folder
.
So all you need to do is save your settings first and load it after you reinstalled your OS.
If the Save settings to Folder
is disabled, select a folder (e.g. empty) in the Load preferences from a custom folder or URL:
text box.
In iTerm2 3.3 on OSX the sequence is: iTerm2 menu, Preferences, General tab, Preferences subtab
Solution 2 - Iterm
It isn't the most obvious workflow. You first have to click "Load preferences from a custom folder or URL". Select the folder you want them saved in; I keep an appsync folder in Dropbox for these sorts of things. Once you have selected the folder, you can click "Save settings to Folder". On a new machine / fresh install of your OS, you can now load these settings from the folder. At first I was sure that loading preferences would wipe out my previous settings, but it didn't.
Solution 3 - Iterm
I didn't touch the "save to a folder" option. I just copied the two files/directories you mentioned in your question to the new machine, then ran defaults read com.googlecode.iterm2
.
Solution 4 - Iterm
There is another way to do this.
From iTerm2 2.9.20140923 you can use Dynamic Profiles as stated in the documentation page:
> Dynamic Profiles is a feature that allows you to store your profiles in a file outside the usual macOS preferences database. Profiles may be changed at runtime by editing one or more plist files (formatted as JSON, XML, or in binary). Changes are picked up immediately.
So it is possible to create a file like this one:
{
"Profiles": [{
"Name": "MYSERVER1",
"Guid": "MYSERVER1",
"Custom Command": "Yes",
"Command": "ssh [email protected]",
"Shortcut": "M",
"Tags": [
"LOCAL", "THATCOMPANY", "WORK", "NOCLOUD"
],
"Badge Text": "SRV1",
},
{
"Name": "MYOCEANSERVER1",
"Guid": "MYOCEANSERVER1",
"Custom Command": "Yes",
"Command": "ssh [email protected]",
"Shortcut": "O",
"Tags": [
"THATCOMPANY", "WORK", "DIGITALOCEAN"
],
"Badge Text": "PPOCEAN1",
},
{
"Name": "PI1",
"Guid": "PI1",
"Custom Command": "Yes",
"Command": "ssh [email protected]",
"Shortcut": "1",
"Tags": [
"LOCAL", "PERSONAL", "RASPBERRY", "SMALL"
],
"Badge Text": "LocalServer",
},
{
"Name": "VUZERO",
"Guid": "VUZERO",
"Custom Command": "Yes",
"Command": "ssh [email protected]",
"Shortcut": "0",
"Tags": [
"LOCAL", "PERSONAL", "SMALL"
],
"Badge Text": "TeleVision",
}
]
}
in the folder ~/Library/Application\ Support/iTerm2/DynamicProfiles/
and share it across different machines.
This enables you to retain some visual differences among iterm2 installations such as font type or dimension, while synchronising remote hosts, shortcuts, commands, and even a small badge to quickly identify a session
Solution 5 - Iterm
Current version of iterm2 (3.4.10, as of my answer) allows to export the whole profile settings as a json file, which will include everything necessary to rebuild the environment such as colors, fonts, spacing, Command, Working Directory, keymaps, scrollbars, etc.
To do so:
- main menu -> Profiles -> Open Profiles...
- again, select the profile of interest and press Edit Profiles...
- lower left corner, choose "Other Actions..." -> "Save Profile as Json..."
To re-import the profile there's obviously also the "Import Json Profiles..." entry.
Solution 6 - Iterm
Caveats: this answer only allows exports color settings.
iTerm => Preferences => Profiles => Colors => Load Presets => Export
Import shall be similar.
Solution 7 - Iterm
Reading the iTerm2 settings from the folder can be problematic, I would suggest the URL method.
To export the .plist file,
- Go to
iTerm2 -> Preferences -> General
. - Under the
Preferences tab
, TickLoad Preferences from a custom folder or a URL:
and choose a folder and click onSave Now
. - Now go to gist.github.com, upload the file, and enure its public gist.
- Click on
raw
to see only the content and copy the URL. (like: https://gist.githubusercontent.com/name/t76...)
To import this file on new machine, It's Same steps as above,
- Go to
iTerm2 -> Preferences -> General
. - Under the
Preferences tab
, TickLoad Preferences from a custom folder or a URL:
and insert the link. - Wait for 5-10 seconds, and close & open iTerm2 again.
- All settings would be imported.
Solution 8 - Iterm
Preferences -> General -> Load preferences from a custom folder or URL
First time you choose this, it will automatically save a preferences file into this folder called "com.googlecode.iterm2.plist"