Is there any way to change tab colour for new tabs in iTerm2 (automatically, random colour)?


Create a new python script in the scripts folder, name it new_colored_tab.py:

#!/usr/bin/env python3

import iterm2
import random

def rand_color():
    return random.randint(0,255)

async def main(connection):
    app=await iterm2.async_get_app(connection)
    window = app.current_window
    if window is not None:
        await window.async_create_tab()
        print("No current window")

    change = iterm2.LocalWriteOnlyProfile()
    color = iterm2.Color(rand_color(),rand_color(),rand_color())

    await session.async_set_profile_properties(change)


Every time you want a new tab, go to the Scripts menu and run it.

| improve this answer | |

With iTerm open, go to the iterm2 menu item and select preferences. From preferences, you'll get a panel that looks like the image below.

enter image description here

From this image select the Profiles icon in the top row. This shows the following panel.

enter image description here

From this panel click on colors that brings up this final panel.

enter image description here

you can see in this panel there is a checkbox labeled tab color. This allows you to set your tab color. All tabs opened now will use this new color.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .