1

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

1
+50

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)
    session=app.current_terminal_window.current_tab.current_session
    window = app.current_window
    if window is not None:
        await window.async_create_tab()
    else:
        print("No current window")

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

    change.set_tab_color(color)
    change.set_use_tab_color(True)
    await session.async_set_profile_properties(change)

iterm2.run_until_complete(main)

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

| improve this answer | |
1

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 .