termtint

Automatically and deterministically colorizes iTerm2 tabs and backgrounds as you cd between directories.
Installation
Or build from source:
Add the shell hook to your shell config:
Zsh (~/.zshrc):
Bash (~/.bashrc):
Fish (~/.config/fish/config.fish):
termtint hook fish | source
Usage
Create a .termtint file in any directory. When you cd into that directory
(or any subdirectory), terminal colors will automatically change.
Note: termtint uses iTerm2-specific escape sequences for setting tab and background colors. These are non-standard extensions and will only work in iTerm2 on macOS.
.termtint
The .termtint file is a simple text file that specifies the color of the tab
and background for that directory.
Hex color
When .termtint contains a simple color value, it will be used as the tab
color, and the background color will be automatically calculated.
#ff5500
Colors can be specified in multiple formats:
- 6-digit hex:
#ff5500orff5500 - 3-digit hex:
#f50 - RGB:
rgb(255, 85, 0) - HSL:
hsl(20, 100%, 50%) - Named colors:
red,tomato,dodgerblue, etc.
TOML
= "#00ff00"
= "#001100" # optional, will be calculated if omitted
Auto
When .termtint contains auto, the tab and background colors will be selected
using a deterministic hash of the directory path.
auto
Automatic Colorization
You can configure termtint to automatically colorize directories without needing
to create .termtint files. Colors are deterministically generated from the
directory path, so each directory always gets the same color.
Trigger files automatically apply colors when entering directories with specific project files:
Trigger paths automatically apply colors to directories matching glob patterns:
The trigger add command automatically detects whether you're adding a file
name or a path pattern. Patterns containing /, *, ~, or ? are treated as
paths.
Manage triggers:
Commands
How It Works
- Shell hook calls
termtint applyon every directory change applysearches up from current directory for.termtintor trigger matches- If found, parses config and emits iTerm2 escape sequences
- State is tracked in
~/.cache/termtint/to avoid redundant updates
Advanced Features
Verbose Output
Use --verbose with apply or reset to see detailed output:
The verbose output for apply displays:
- Config source type (explicit
.termtintfile, trigger path, or trigger file) - Source path and format (auto, simple hex, or TOML)
- Whether background is explicit or auto-generated
- Resolved RGB colors with large color swatches
Inspect Current Directory
The inspect command shows the current directory's configuration:
Output includes:
- Current directory path
- Config source (
.termtintfile, trigger path, trigger file, or none) - Matched pattern or trigger file (if applicable)
- Resolved tab and background colors with color blocks
- Cached state information
Color Palette
The colors command displays a visual palette of available colors:
Features:
- Shows a 2D grid with hue on X-axis and saturation on Y-axis
- Displays current configuration parameters
- Shows sample tab/background color pairs
- Uses your configured color format (hex, HSL, or RGB)
Re-roll Colors
Generate a new random color for the current directory:
Features:
- Updates
.termtintwith a new random color (creates it if it doesn't exist) - Shows ASCII dice art with the new colors
- Applies colors immediately
Configuration
User configuration is stored in ~/.config/termtint/config.toml:
# Fixed lightness for darkened backgrounds (0.0 to 1.0)
= 0.18
# Saturation multiplier for backgrounds (0.0 = grayscale, 1.0 = full color)
= 1.0
# Files that trigger automatic color generation when found
= ["Cargo.toml", "package.json"]
# Path globs that trigger automatic color generation
# Directories matching these patterns get auto-generated colors
= ["~/Code/*", "~/Projects/*"]
# Color format for display: "hex", "hsl", or "rgb"
= "hex"
# Auto color generation parameters
[]
= 0.0
= 360.0
= 0.7
= 0.9
= 0.55
Edit the config:
View current settings:
Color Formats
Colors can be specified in multiple formats in .termtint files:
- 6-digit hex:
#ff5500orff5500 - 3-digit hex:
#f50 - RGB:
rgb(255, 85, 0) - HSL:
hsl(20, 100%, 50%) - Named colors:
red,tomato,dodgerblue, etc.
When using termtint init, all color formats are validated and normalized to
hex format (e.g., green becomes #008000).