#1836·jrnl

Don't include ANSI codes when output is non-interactive

Author: FryuniCreated Nov 27, 2023Updated Oct 10, 2025
Labelsenhancementdiscussion

Use Case/Motivation

When stdout is not a tty it would be better to not output any ANSI special codes (for colors).

This allows piping entries from JRNL to other CLI tools, like Charm's Mods to use with a chatbot.

Example Usage

jrnl -2 | mods 'extract action items from these notes'

What is sent as prompt is this:

log
❯ mods -s a893ef5

  Prompt: extract action items from these notes. Format the response as
  markdown without enclosing backticks.

  [1m[30m2023-10-13 06:00:00 AM[0m [1m[36m<NOTE TITLE>[0m |
  <NOTE CONTENT>

  [1m[30m2023-10-13 05:09:30 PM[0m [1m[36m<NOTE TITLE>[0m |
  <NOTE CONTENT>

Other Information

This can be detected using sys.stdout.isatty