-
-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't include ANSI codes when output is non-interactive #1836
Comments
Hi @Fryuni, thanks for filing this. I am leaning against implementing this feature, and I want to document why here, but I also want to be open to input from the community on this, so I'm tagging this as a discussion for now. jrnl has two categories of output formats: "display formats" intended for human consumption, and "data formats" intended for machine consumption. The default format The data formats, however, will never include color codes. In particular, the If you want the best of both worlds with having to add the
While I think these workarounds are relatively simple, I also know that all of these approaches involve extra steps that come as an unwelcome surprise to people expecting color suppression while piping. After all, lots of CLI programs suppress colors when piping, and I think there's a real benefit to mimicking the default behaviors of popular CLI programs so jrnl is easier to pick up for new users. Maybe there's a compromise out there that has already been implemented in some of those programs. I'm open to examples and suggestions. |
A somewhat simple compromise to have the automatic color suppression by what you said would be to have a format (say Keeping the default as is for backwards compatibility of course |
@Fryuni How about if we introduce a new color setting? Something like what bat does (see
This would allow us to not bake in the preference to any format, but still allow the flexibility for users to choose their preference. |
That sounds good. That |
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:
Other Information
This can be detected using
sys.stdout.isatty
The text was updated successfully, but these errors were encountered: