Skip to content

feat: support ANSI color indices in theme configuration#771

Merged
dlvhdr merged 3 commits intodlvhdr:mainfrom
graelo:feat/support-ansi-color-indices
Feb 13, 2026
Merged

feat: support ANSI color indices in theme configuration#771
dlvhdr merged 3 commits intodlvhdr:mainfrom
graelo:feat/support-ansi-color-indices

Conversation

@graelo
Copy link
Contributor

@graelo graelo commented Feb 12, 2026

Hello again, thanks for your kind message in #770.

Here's my PR. I tested it by

  • running tests (added 3 new tests)
  • building locally with go build -o gh-dash . and moving the binary to ~/.local/share/gh/extensions/gh-dash/ and then running gh dash, with the config file below.

In a nutshell, this PR replaces the hexcolor validator with a custom color validator that accepts both hex and ansi (0-255) formats. It's a strictly additive change — all previously valid configs remain valid.

Config file and screenshot:

Details `~/.config/gh-dash/config.yml`
theme:
  ui:
    sectionsShowCount: true
    table:
      showSeparators: true
      compact: false
  colors:
    text:
      primary: '2' # green
      secondary: '6' # cyan
      inverted: '15' # base3 (brightwhite)
      faint: '8' # base03 (brightblack)
      warning: '1' # red
      success: '2' # green
      actor: '4' # blue
    background:
      selected: '7' # base2 (white)
    border:
      primary: '0' # black
      secondary: '5' # magenta
      faint: '14' # base1 (brightcyan)
    icon:
      newcontributor: '037'
      contributor: '133'
      collaborator: '136'
      member: '136'
      owner: '166'
      unknownrole: '125'
  icons:
    newcontributor: "\U000F0394"
    contributor: ''
    collaborator: ''
    member: ''
    owner: ''
    unknownrole: "\U000F0B59"
Screenshot 2026-02-12 at 21 48 30

Changes

  • Renamed the HexColor type to Color and swapped the built-in hexcolor tag for a custom color validator that accepts hex colors or numeric ANSI indices (0–255)
  • Renamed the _shimHex helper in theme.go to _shimColor (pure rename, no logic change — lipgloss already handles both formats)
  • Updated the documentation schemas to reflect the broader accepted format
  • Added tests for valid and invalid inputs, including edge cases ("256", "-1", leading zeros, etc.)

Closes #770

The theme config validation only accepted hex colors (#RGB / #RRGGBB)
via the built-in hexcolor validator, even though the default theme
already uses ANSI indices like "013" and "008" internally. This relaxes
validation to also accept ANSI color indices (0-255), letting users
reference terminal palette colors directly in their config.

Closes dlvhdr#770
@graelo
Copy link
Contributor Author

graelo commented Feb 12, 2026

I just saw the lint issue, on it!

@graelo
Copy link
Contributor Author

graelo commented Feb 13, 2026

@dlvhdr Hi, I think there's a CI issue with the docker workflow. It looks unrelated to my PR.

@dlvhdr
Copy link
Owner

dlvhdr commented Feb 13, 2026

Yeah it's unrelated. Still need to review the code 🙏

Copy link
Owner

@dlvhdr dlvhdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! just a minor comment

description: >-
Specifies the color for text on an inverted background. Must be a valid hex color,
like `#a3c` or `#aa33cc`.
Specifies the color for text on an inverted background. Must be a valid hex color
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to update docs/src/content/docs/configuration/theme.mdx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks, I had missed it. I just pushed a commit for this.

@dlvhdr dlvhdr merged commit 3ad757c into dlvhdr:main Feb 13, 2026
3 of 4 checks passed
@graelo
Copy link
Contributor Author

graelo commented Feb 13, 2026

Thank you!

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.

Support ANSI color indices in theme configuration

2 participants