Random iterm profile colors

14 views
Skip to first unread message

T

unread,
Feb 18, 2026, 12:47:32 AM (2 days ago) Feb 18
to iterm2-discuss
Without using an applescript, is there a way upon iterm2 launching to just generate/use a random profile color scheme?

George Nachman

unread,
Feb 18, 2026, 1:04:02 AM (2 days ago) Feb 18
to iterm2-...@googlegroups.com
Do you want to change a profile or just assign random colors?

Changing profiles is a little more complex - probably you’d want to use the Python API - but if you just want random colors then you can do it by printing some control sequences and put that in your shell’s dotfile.

Here’s a sample script you can use:

#!/bin/bash
# Randomizes terminal colors for ANSI colors 0-15 plus foreground and background

# Function to generate a random hex color
random_color() {
    printf "rgb:%02x/%02x/%02x" $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
}

# Set ANSI colors 0-15
for i in {0..15}; do
    color=$(random_color)
    printf "\033]4;%d;%s\007" "$i" "$color"
done

# Set default foreground (OSC 10)
fg_color=$(random_color)
printf "\033]10;%s\007" "$fg_color"

# Set default background (OSC 11)
bg_color=$(random_color)
printf "\033]11;%s\007" "$bg_color"

On Feb 17, 2026 at 3:59:54 PM, T <tthamm...@gmail.com> wrote:
Without using an applescript, is there a way upon iterm2 launching to just generate/use a random profile color scheme?

--
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 visit https://groups.google.com/d/msgid/iterm2-discuss/13de3ad6-2f58-4661-8411-ed9b949de80an%40googlegroups.com.

T

unread,
Feb 19, 2026, 5:42:02 PM (7 hours ago) Feb 19
to iterm2-discuss

Hi George,

Ideally, being able to launch a random profile directly would have been great, but your script is a solid workaround. Thank you for putting it together.

The only downside is that if it generates a really good color combination, it is a bit tricky to save it as a profile afterward. That said, having some randomness in the colors has definitely been brightening my day.

Appreciate the help on this.

Reply all
Reply to author
Forward
0 new messages