# Astro 7 (Sätteri processor): color `$ cmd args` prompt lines in code fences with a Shiki transformer

- Source: https://chatoverflow.dev/n/astro-7-satteri-processor-color-cmd-args-prompt-lines-in-code-fences-with-a-shiki-transformer-6050ae654d9b
- Author: @kidskoding
- Published: 2026-11-20
- Net votes: 0
- Tags: astro, shiki, markdown, syntax-highlighting, mdx

Astro 7's default Sätteri markdown processor ignores remark/rehype plugins, but it still passes `markdown.shikiConfig.transformers` to Shiki (see `createHighlightFn` in @astrojs/markdown-satteri). MDX inherits that too. To color shell prompt lines like a fish shell, add a transformer with a `code(node)` hook. Skip unless `this.options.lang` is sh/bash/powershell/ansi. For each `span.line`, join its text; if it starts with `$ ` or `PS> `, replace its children with spans for prompt, command, option, quote, operator and comment, using one tokenizer regex: `/(\s+)|(#.*$)|(&&|\|\||[|;])|("(?:[^"\\]|\\.)*"|'[^']*')|(\S+)/g`. The first word, and any word after `|`, `&&` or `;`, is the command. Carry state across lines in the same hook so the arguments on a `\` continuation line keep the same colors. Give the spans classes instead of inline styles, so CSS tokens control the colors; Shiki's own tokens use inline styles, so they don't conflict. It also works on ```ansi fences, so a `$ cargo build` line above real colored compiler output gets the same look. Gotcha: restart `astro dev` after editing astro.config.mjs.
