Skip to content

Colours

Using a pseudo-terminal

By default, rich-codex runs commands in a Python subprocess. This is not an interactive terminal, and as such many command-line tools will disable coloured output.

This is best solved at the tool level if possible, by telling the tool to force coloured output. However, if this is not possible then you can use --use-pty / $USE_PTY / use_pty (CLI, env var, action/config). This uses a Python pty pseudo-terminal instead of subprocess which may trick your tool into keeping coloured output.

Warning

Note that PTY almost certainly won't work on Windows and is generally more likely to do weird stuff / create poorly formatted outputs than the default subprocess shell.

Colour theme

You can customise the theme using --terminal-theme / $TERMINAL_THEME / terminal_theme (CLI, env, action/config).

Themes are taken from Rich, at the time of writing the following are available:

  • DEFAULT_TERMINAL_THEME
  • MONOKAI
  • DIMMED_MONOKAI
  • NIGHT_OWLISH
  • SVG_EXPORT_THEME

The terminal theme should be set as a string to one of these values.

Note

It's planned to add support for custom themes but not yet implemented. If you need this, please create a GitHub issue / pull-request.

DEFAULT_TERMINAL_THEME:

rich ../../setup.cfg -h 5 --force-terminal

MONOKAI:

rich ../../setup.cfg -h 5 --force-terminal

DIMMED_MONOKAI:

rich ../../setup.cfg -h 5 --force-terminal

NIGHT_OWLISH:

rich ../../setup.cfg -h 5 --force-terminal

SVG_EXPORT_THEME:

rich ../../setup.cfg -h 5 --force-terminal

Snippet colours

Snippets are formatted using rich Syntax objects. These use Pygments to add code colouring, which has its own set of themes - separate to the terminal theme that the snippet is wrapped in.

As such, if using snippets, you'll probably want to set both the terminal theme and the Pygments style. You can find available Pygments styles in the Pygments docs.

snippet_theme: xcode + terminal_theme: DEFAULT_TERMINAL_THEME:

DEFAULT_TERMINAL_THEME + sas

snippet_theme: monokai + terminal_theme: SVG_EXPORT_THEME:

SVG_EXPORT_THEME + monokai

snippet_theme: fruity + terminal_theme: MONOKAI:

MONOKAI + fruity