Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hunk Adaptive Theme

A Hunk extension that selects a light or dark theme from the terminal background.

Built-in Hunk support

theme = "auto"          # switches between GitHub's default light/dark themes
transparent_bg = true   # follows terminal theme changes during a review

Use this extension when you want custom themes for each mode.

Install

Requires Hunk 0.19.0 or later.

hunk extension install astwys/hunk-adaptive-theme

For a one-off local test:

hunk diff --extension . --theme adaptive-theme

Configure

theme = "adaptive-theme"

[extension.hunk-adaptive-theme]
light = { base = "catppuccin-latte", accent = "#1e66f5" }
dark = { base = "catppuccin-mocha", accent = "#89b4fa" }

The light and dark tables accept the same fields as Hunk custom themes. The configuration table name must match the extension directory name.

Detection

At startup, the extension queries the terminal with OSC 11, classifies the response by luminance, and registers the matching theme. Detection runs once per process. If the terminal does not answer within 150 ms, or stdin/stdout is not a TTY, it uses the dark table.

Hunk recommends that extensions do not write to stdout. This extension intentionally writes one fixed OSC 11 query before the renderer mounts, matching Hunk's startup detection. It never writes to renderer-owned stdout afterward; diagnostics use hunk.log.

Check terminal support:

printf '\033]11;?\033\\'; sleep 0.3; echo

Supported terminals print a response such as:

rgb:1e1e/1e1e/1e1e

If the command prints nothing before the blank line, the terminal does not answer OSC 11 and the extension will use the dark theme.

Development

pnpm install
pnpm test
pnpm typecheck
pnpm test:pty

pnpm test:pty requires Bun, Python 3, and a real terminal.

License

MIT. Includes code derived from Hunk; see NOTICE.

About

Select a custom Hunk theme based on your terminal background.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages