Setting color scheme for the current terminal without Touch Bar

155 views
Skip to first unread message

Claudio Satriano

unread,
Aug 17, 2023, 5:41:37 AM8/17/23
to iterm2-discuss
Hi,

I'm moving from a MacBook with Touch Bar to a new Mac without it.

One thing I use a lot is the color wheel selector on the Touch Bar to change the color scheme of the current terminal only.

Is there any way to have the same thing without the Touch Bar?

I tried with the "Action..." button in the Status Bar, using "Load Color Preset", but that changes the color for all the terminals (and the change is persistent after quitting iTerm2).

Thanks in advance for your help!

Claudio

Adrian Bool

unread,
Aug 18, 2023, 6:44:55 AM8/18/23
to iterm2-discuss
Hi Claudio

The Session → Edit Session menu, which at least on my machine can be accessed with the ⌘-I shortcut, allows you to change the colours used in just the current terminal window.

Cheers

aid

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/6e560acf-5100-4516-aabe-3a3f566d5755n%40googlegroups.com.

Claudio Satriano

unread,
Aug 18, 2023, 7:43:17 AM8/18/23
to iterm2-discuss
Hi Adrian,
thanks for the quick reply!

It would be nice to have a shortcut in the Status Bar for that ;-)

I also found a scripting solution, which implies creating a different script for each color profile: the advantage is that it is fewer clicks away: "Scripts-->script_name.py".

Here's an example script I made by copy-paste from the examples.
I called it "light_background.py":

#!/usr/bin/env python3
import iterm2


async def SetPresetInSession(connection, session, preset_name):
    preset = await iterm2.ColorPreset.async_get(connection, preset_name)
    if not preset:
        return
    profile = await session.async_get_profile()
    if not profile:
        return
    await profile.async_set_color_preset(preset)


async def main(connection):
    app = await iterm2.async_get_app(connection)
    session = app.current_terminal_window.current_tab.current_session
    await SetPresetInSession(connection, session, 'Light Background')

iterm2.run_until_complete(main)

Reply all
Reply to author
Forward
0 new messages