[FEATURE] Add persistent session color setting

Status Open
Maintainer reply None cached
Activity 4 comments · opened Mar 21, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Add a color setting in settings.json to persist the session prompt color across sessions.

Current Behavior

  • /color blue sets the color for the current session only
  • Color resets on new session
  • No color setting exists in settings.json

Proposed Solution

Add a color setting:

``json
{
"color": "blue"
}
``

Supported values could match the current /color command options: blue, red, green, yellow, magenta, cyan, white, etc.

Use Case

Users who prefer a specific color (e.g., for visual distinction, accessibility, or personal preference) currently need to run /color <color> manually at the start of every session. A
persistent setting would eliminate this repetitive step.

Alternative Solutions

None currently available — the /color command is runtime-only and cannot be automated via hooks (hooks run shell commands, not internal slash commands).

Priority

Low - Nice to have

Feature Category

Configuration and settings

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

4 Comments

chipach · 5 months ago

Related, perhaps a "session hook" could be used to set this up. That way, if I'm in a certain directory (e.g. a worktree), I could automatically set the color (and maybe /rename?) based on the worktree I'm using. Something similar to hooks could allow matchers or, for the original suggestion, just do it upon any session start.

wjf-clo · 5 months ago

Seeing lots of dupes of wanting a default color or to allow the assistant to alter the prompt color (me too!). #37749 has a more complete and helpful description of supporting a defaultColor _only_ customization.

However, a number of recently filed issues highlight a desire to persist a custom session _name_ as well as _color_ (e.g. across /clear commands) or to allow users to specify a default session name and color in settings*.json files. See #38649 and #39765 for examples.

yurukusa · 5 months ago

A Notification start hook can set terminal colors based on project:

DIR=$(basename "$PWD")
case "$DIR" in
    *-prod*|*production*)  COLOR="\033[41m" ;; # Red bg for production
    *-staging*)            COLOR="\033[43m" ;; # Yellow for staging
    *-dev*|*develop*)      COLOR="\033[42m" ;; # Green for dev
    *)                     COLOR="\033[44m" ;; # Blue default
esac
tmux set -q status-style "bg=$(echo "$DIR" | md5sum | cut -c1-6)" 2>/dev/null
echo "Session color set for: $DIR" >&2
exit 0
luis-talkagency · 5 months ago

Workaround: Automatic per-project terminal colors using hooks (macOS/Terminal.app)

I wanted different terminal colors depending on which project folder I launched Claude Code from, so I could visually distinguish sessions at a glance. Here's a hook-based solution that works today.

It's macOS/Terminal.app specific (uses AppleScript), but the pattern — SessionStart/SessionEnd hooks + a central config — is portable. You'd just swap the osascript lines for your terminal's equivalent.

Setup

1. Create a color config file (~/.claude/terminal-colors.conf):

# Format: path_pattern=bg_r,bg_g,bg_b|text_r,text_g,text_b
# RGB values are 0-65535 (Terminal.app scale)
# Pastel backgrounds with matching dark text
# Specific paths first (first match wins)

# Pastel salmon
my-projects/project-alpha=55000,35000,35000|8000,3000,3000
# Pastel sky blue
my-projects/project-beta=35000,50000,58000|3000,8000,12000
# Pastel mint
my-projects/project-gamma=35000,56000,53000|3000,10000,9000
# Pastel peach (root fallback)
my-projects=58000,45000,34000|12000,6000,2000

Add as many entries as you need. First match wins, so put specific subpaths before parent paths.

2. Create the start script (~/.claude/terminal-color-start.sh):

#!/bin/bash
CONF="$HOME/.claude/terminal-colors.conf"
SAVE_FILE="/tmp/claude-terminal-colors-${TERM_SESSION_ID:-default}"

# Save original colors
BG=$(osascript -e 'tell application "Terminal" to get background color of selected tab of front window' 2>/dev/null)
TEXT=$(osascript -e 'tell application "Terminal" to get normal text color of selected tab of front window' 2>/dev/null)
echo "$BG" > "$SAVE_FILE.bg"
echo "$TEXT" > "$SAVE_FILE.text"

# Find matching color from config (first match wins)
if [ -f "$CONF" ]; then
  while IFS='=' read -r pattern colors; do
    [[ "$pattern" =~ ^#.*$ || -z "$pattern" ]] && continue
    if [[ "$PWD" == *"$pattern"* ]]; then
      BG_COLOR="${colors%%|*}"
      TEXT_COLOR="${colors##*|}"
      osascript -e "tell application \"Terminal\" to set background color of selected tab of front window to {$BG_COLOR}"
      osascript -e "tell application \"Terminal\" to set normal text color of selected tab of front window to {$TEXT_COLOR}"
      break
    fi
  done < "$CONF"
fi

3. Create the end script (~/.claude/terminal-color-end.sh):

#!/bin/bash
SAVE_FILE="/tmp/claude-terminal-colors-${TERM_SESSION_ID:-default}"

if [ -f "$SAVE_FILE.bg" ] && [ -f "$SAVE_FILE.text" ]; then
  BG=$(cat "$SAVE_FILE.bg")
  TEXT=$(cat "$SAVE_FILE.text")
  osascript -e "tell application \"Terminal\" to set background color of selected tab of front window to {$BG}"
  osascript -e "tell application \"Terminal\" to set normal text color of selected tab of front window to {$TEXT}"
  rm -f "$SAVE_FILE.bg" "$SAVE_FILE.text"
fi

4. Make them executable:

chmod +x ~/.claude/terminal-color-start.sh ~/.claude/terminal-color-end.sh

5. Add hooks to your user-level settings (~/.claude/settings.json):

Add the following hooks key to your existing settings file. If you don't have one yet, create it with this content:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "bash ~/.claude/terminal-color-start.sh"
          }
        ]
      }
    ],
    "SessionEnd": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "bash ~/.claude/terminal-color-end.sh"
          }
        ]
      }
    ]
  }
}
Note: If you already have a ~/.claude/settings.json with other settings, merge the "hooks" key into your existing file rather than replacing it.

How it works

  • Hooks are defined once in user-level settings — they run for every session
  • The start script checks $PWD against the config file and applies the matching color
  • Original terminal colors are saved to a temp file (per tab via TERM_SESSION_ID) and restored on exit
  • To add a new project, just add a line to terminal-colors.conf — no per-project settings needed
  • Zero performance impact — just a couple of AppleScript calls on start/exit

Tips

  • Use pastel backgrounds with matching dark text for comfortable long sessions
  • Keep parent path entries (e.g., my-projects) below subpath entries so they act as fallbacks
  • If $PWD doesn't match any entry, nothing changes — your terminal stays as-is

Limitations

  • macOS Terminal.app only (uses AppleScript). Adaptable to iTerm2 (escape sequences) or Linux terminals (OSC sequences)
  • Only changes background + text color, not the full ANSI palette

Would still love a native color setting in settings.json as proposed in this issue, but this works well in the meantime.