Skip to content

feat: add --color=auto|always|never - #172

Closed
nfvelten wants to merge 1 commit into
hyprwm:mainfrom
nfvelten:feat/preview-format
Closed

nfvelten wants to merge 1 commit into
hyprwm:mainfrom
nfvelten:feat/preview-format

Conversation

@nfvelten

Copy link
Copy Markdown

Closes #121.

Color was decided only by the isatty and NO_COLOR checks. --no-fancy could force it off, but nothing could force it on, so piping into anything else always stripped it. That is the case in the issue: the output is captured into a variable and reused for a notification border, the terminal, and the clipboard.

--color follows the ls convention. auto is the default and behaves exactly as before, always keeps the color across a pipe, and never is what --no-fancy already did. --no-fancy now routes through the same tri-state rather than setting the flag directly, so the last option on the command line wins instead of the order of the checks deciding.

Verified by picking a pixel with the output piped through cat -v:

$ hyprpicker | cat -v
#FAF0C6

$ hyprpicker --color=always | cat -v
^[[38;2;0;0;0;48;2;250;240;198m#FAF0C6^[[0m

An unrecognised value exits 1 with a message naming the three accepted ones.

Two notes, both easy to drop if you disagree:

  • the man page documented --no-fancy as -n, but -n is --notify and --no-fancy is -b. I corrected it in the same block I was already editing.
  • the NO_COLOR entry now says it is overridden by --color=always, matching how ls treats an explicit flag.

While looking into this I also noticed #109 is already fixed, by #123 back in May 2025. The preview honours --format on current main. Might be worth closing.

Colored output was decided solely by the isatty and NO_COLOR checks, with
--no-fancy able to force it off but nothing able to force it on. Piping the
output to another program therefore always stripped the color.

Add --color, following the ls convention. auto keeps the existing
behaviour and stays the default, always keeps the color across a pipe, and
never matches --no-fancy, which now routes through the same tri-state.
@github-actions

Copy link
Copy Markdown

Hi @nfvelten,

Thanks for your contribution! Unfortunately, Hyprland and hypr* no longer
accept contributions from unvouched contributors.

To get vouched, please see our contributing guide at wiki.hypr.land/Contributing-and-Debugging

This PR has been closed automatically and will not be re-opened.

@github-actions github-actions Bot closed this Aug 31, 2026
@nfvelten
nfvelten deleted the feat/preview-format branch August 31, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--color=always

1 participant