To save and restore window state in iTerm2 under macOS Sonoma, follow the below steps.

  1. Disable Close windows when quitting an application option from System Preference > Desktop & Dock under macOS Sonoma.

  2. In iTerm2 > Settings > General > Start up, choose Window restoration policy: Use System Window Restoration Setting.

  3. In iTerm2 > Window > Save Window Arrangement and specify a name.

  4. After launching iTerm2 and to open this arrangement in the current window use Window > Restore Window Arrangement and choose the name.

  5. To restore the window arrangement as new tab, use Window > Restore Window Arrangement as Tabs.

At this point, macOS Terminal is not able to display full range of colours but iTerm2 does. So vim themes doesn't work on the default terminal.