How to export iTerm2 Profiles
Asked Answered
B

8

374

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?

Blakeley answered 8/4, 2014 at 17:3 Comment(0)
R
556

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 the sequence is:
iTerm2 menu > Preferences > "General" tab > "Preferences" sub-tab

Rosary answered 29/4, 2014 at 5:20 Comment(11)
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 processBlakeley
I figured it out. I was just being an idiot. I was thinking it wanted me to name a file and then choose a directory rather than just choosing a directory to save it in. I feel so stupid right now...Blakeley
Also useful: on 10.9, you have to restart a service, see apple.stackexchange.com/questions/111534/…Kinson
How can you export iTerm keybindings?Thomasenathomasin
A little complement: at very first, the button Save Current Settings to Folder is inactive. You have to check Load preferences from a custom folder or URL: first and choose a directory(which doesn't need to have an existing preferences file there yet) in order to save the preferences in the future. After that, the button Save Current Settings to Folder will become active.Heathenize
How can I load the settings after reinstalled my OS?Colombi
@MustafaOlkun after reinstall, launch iTerm2, go Preferences -> General and click on "Load preferences from a custom folder or URL" (you need to tick the box, then click on Browse and go to the folder that has your preferences, select the folder and click Apply. These preferences will then be imported to your iTerm2.) Note: Arrangements and Keys and Profiles will not be imported.. Go to Preferences->Profiles and click on "Other Actions" and click on "Copy All Profiles as JSON". Save that to a textfile, copy it to the other computer's ~/Library/Application Support/iTerm2/DynamicProfiles .Currant
yeah @KrzysztofKaczor I am finding this incredibly confusing -- am used to applications offering "save all settings and export them" coupled with "import settings", iTerm2 most certainly does not do that :oCurrant
thanks @Currant - this should be the accepted answer!Approximal
And make sure to press Don't copy when you set the custom folder.Sherbet
@Currant Is this still true as of the newest Iterm version? I know I have had issues with this in the past copying over keys so I had to do it manually. It seems it coped over my profiles and keys when I just did it.Tamekia
J
94

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.

Jonson answered 4/8, 2014 at 15:49 Comment(4)
Thanks for confirming that -- fear of overwriting my extensive profiles and settings tweaks was holding me back from trying that option.Amygdalin
Added recommendation, Uncheck Save changes to folder where iTerm2 quits. Do that manually otherwise your connected machines will be conflicting try to update their window placement settings that don't matter as much.Definite
How can I load these settings from folder. I couldn't find a way!Colombi
Wow. I absolutely love iTerm2, but this is really problematic. Without stack overflow, I never could have figured this out.Apology
H
28

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:

  1. (iTerm2 menu bar) -> Profiles -> Open Profiles...
  2. again, select the profile of interest and press Edit Profiles...
  3. lower left corner, choose "Other Actions..." -> "Save Profile as Json..."

To re-import the profile there's "Import Json Profiles...".

Haroldharolda answered 26/10, 2021 at 14:13 Comment(1)
Note: the "main menu" refers to the top bar on OSX, not any of the menus under "Preferences". You can also open the "Profiles" view via CMD + O by default.Belda
Z
26

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.

See https://apple.stackexchange.com/a/111559

Zipangu answered 17/12, 2014 at 21:51 Comment(0)
L
14

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

badge

Leede answered 16/9, 2017 at 12:36 Comment(1)
One issue, this does not retain Keys or Arrangements. Still looking for how to retain those. I can't believe iTerm2 have made this so difficult. What, 3 or more files need to be created, as opposed to "Save Preferences"?? :oCurrant
S
7

Reading the iTerm2 settings from the folder can be problematic, so I suggest the URL method.

To export the .plist file:

  1. iTerm2 -> Preferences -> General.
  2. Preferences tab > Load Preferences from a custom folder or a URL: > choose a folder and click on Save Now
  3. Go to gist.github.com, upload the file, and ensure it's a public gist.
  4. Click on raw to see only the content and copy the URL. (e.g., https://gist.githubusercontent.com/name/t76...)

To import this file on new machine, it's the same steps as above:

  1. iTerm2 -> Preferences -> General.
  2. Preferences tab > Load Preferences from a custom folder or a URL: > input the link
  3. Wait for 5-10 seconds, and close & open iTerm2 again.
  4. All settings are now imported.
Shriner answered 4/8, 2021 at 13:55 Comment(0)
S
6

Caveats: this answer only allows exports color settings.

iTerm => Preferences => Profiles => Colors => Load Presets => Export

Import shall be similar.

Solubility answered 24/4, 2014 at 0:5 Comment(3)
And it shouldn't be geeky at all but was hard to find anyways. The question stated "profiles" and colors are only one aspect, yes, but I think most people just need the colors.Dna
This only exports the colors. I have a ton of other config and I assume many people have too (such as terminal size, shortcuts) so it is not a very good answer.Kline
@AhmetAlpBalkan what's a better answer? I'll change the actual answer if this isn't the best answer.Blakeley
L
1

Preferences -> General -> Load preferences from a custom folder or URL

First time you choose this, it will automatically save a preferences file into a folder named com.googlecode.iterm2.plist

Lon answered 19/12, 2016 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.