Skip to content
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

Custom color palette #9540

Closed
mrdgo opened this issue Aug 29, 2024 · 18 comments
Closed

Custom color palette #9540

mrdgo opened this issue Aug 29, 2024 · 18 comments
Labels
enhancement a request to improve CLI needs-triage needs to be reviewed needs-user-input

Comments

@mrdgo
Copy link

mrdgo commented Aug 29, 2024

Describe the feature or problem you’d like to solve

I use gruvbox for everything. gh uses a different color scheme. Gruvbox feels very warm, your default theme is more on the cool side. To me, this is a big issue - is the color palette configurable? Or do I have to fork this repo to get what I want?

Proposed solution

Additional configuration possible via the config file.

Additional context

A community-driven selection of themes can put hype to a project :)

@mrdgo mrdgo added the enhancement a request to improve CLI label Aug 29, 2024
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Aug 29, 2024
@williammartin
Copy link
Member

Heyo!

Can you take a couple of screenshots to show which cases you're running into palette issues? In most cases gh should be using the base 16 colours that are configured by your terminal.

Definitely we expect there to be some level of customisation to the colour schemes.

@mrdgo
Copy link
Author

mrdgo commented Aug 29, 2024

Hello thanks for your quick reply! Now that you say it ... only the indented text seems to be off palette. I double checked and it surely is the only color that I didn't specify anywhere in my terminal config.
image

@williammartin
Copy link
Member

Ahha! This is rendered markdown which is controlled by https://github.com/charmbracelet/glamour and GLAMOUR_STYLE env var.

Some of them should be baked in (https://github.com/charmbracelet/glamour/tree/master/styles/gallery) but I know there is a possibility to create custom ones as well and I believe GLAMOUR_STYLE can be pointed at a file location.

@williammartin
Copy link
Member

williammartin commented Aug 29, 2024

You might be able to use or draw inspiration from the theme here: charmbracelet/glamour#168

I put it in /tmp/gruvbox.json and ran:

GLAMOUR_STYLE=/tmp/gruvbox-dark.json gh issue view 9000

Which gave me:

Image

Looks like it could be a good match or starting point?

@mrdgo
Copy link
Author

mrdgo commented Aug 30, 2024

Thank you so much! That is indeed a great starting point :)

The text "Newest comment" is styled in gh, right? How do I override the style?
image

@williammartin
Copy link
Member

That's styled here to use Cyan Bold:

fmt.Fprint(&b, cs.CyanBold("Newest comment"))

I believe that's one of the base 16 ANSI colours that can be overridden. For example in iTerm2:

Image

Image

Image

Image

I'm not too familiar with your theming setup or what gruvbox does with cyan.

@mrdgo
Copy link
Author

mrdgo commented Aug 30, 2024

Cyan is ANSI number 6, right? It is configured to #689d6a in my terminal. But it doesn't render as that. It stays the github-theme cyan

@williammartin
Copy link
Member

Yes I believe it's 6. It is bolded with \e[1;36m though.

What happens if you do:

echo -e "\e[0;36mcyan?\e[0m"
echo -e "\e[1;36mcyan?\e[0m"

In iterm these are managed separately so perhaps they are in your theme as well?

Image

Image

@mrdgo
Copy link
Author

mrdgo commented Aug 30, 2024

image
Seems correct to me

@williammartin
Copy link
Member

williammartin commented Aug 31, 2024

That does look like it's applying your colour scheming correctly. Not sure what to make of that 🤔

Let's have a closer look at the actual colour codes. You can force all the ANSI raw strings to file by doing:

GH_FORCE_TTY=true gh issue view <number> > /tmp/ansi

Then opening up /tmp/ansi with vim we can see the codes like:

^[[0;1;39mmrdgo^[[0m^[[0;1;39m • 15h^[[0m^[[0;1;39m • ^[[0m^[[0;1;36mNewest comment^[[0m

So on my end it looks like we're seeing:

echo -e "\e[0;1;36mNewest comment\e[0m"

Worth having a look to see whether yours is the same?

Also I thought you needed to use the -e switch for echo when doing this but I see you haven't. Maybe double check that as well? Though it doesn't seem to matter on my end, so maybe I always made that up.

@mrdgo
Copy link
Author

mrdgo commented Sep 2, 2024

Funny, it looks correct: ^[[0m^[[0;1;36mNewest comment^[[0m and when I echo that on my terminal, it also looks correct. But gh still renders the wrong color.

And no, you didn't make up -e, I use nushell - there -e doesn't exist, because it is default behavior.

Interesting observation: this doesn't happen everytime. It only happens on this PR with gh pr view mrdgo:main. This PR displayed with the same command line renders correctly.

@williammartin
Copy link
Member

That's very strange. I can't reproduce that at all and I can't see any possible variation in the codepath

if newest {
fmt.Fprint(&b, cs.Bold(" • "))
fmt.Fprint(&b, cs.CyanBold("Newest comment"))
}
fmt.Fprintln(&b)

Could you take two screenshots, one of each PR, that includes both the command and the styled text?

@mrdgo
Copy link
Author

mrdgo commented Sep 2, 2024

image

It's not consistent. I had to run it (right side) a few times with different font sizes. As soon as it had to use the pager - the color broke. Hah, and now I can reproduce: it only shows the wrong color in my pager. Now I will try different pagers to see if it happens across pagers or if it is nvimpager.

Edit: correct behavior with less and bat, only nvimpager seems to break the highlights. Can you reproduce, by any chance? I would also understand if that's out of scope for you :)

@williammartin
Copy link
Member

Ahha! I can confirm that nvimpager ignores the styling set in iterm.

First without paging:

Image

Then with paging:

Image

I'm afraid that I don't know anything about nvimpager and how it handles terminal colours.

lucc/nvimpager#101 could be related but I think this seems out of scope for me at this point.

@mrdgo
Copy link
Author

mrdgo commented Sep 2, 2024

Hmm, I feel like the issue addresses a different problem. I have colors, but some of them are incorrect. Namely the colors from github-cli are incorrect, while the ones drawn by glamour are shown correctly.

Edit: thank you so much for all the help debugging :)

@williammartin
Copy link
Member

Could be! In my case the Open also had a different green so it seemed like at least something else was happening.

Note that the labels are using 256-bit colour to match the Web UI so I wouldn't expect them to be restyled.

Good luck figuring it out!

@williammartin
Copy link
Member

Pager mode seems to always exhibit this issue on my end:

echo -e "\e[0;1;36mNewest comment\e[0m" | nvimpager -p

Image

@williammartin
Copy link
Member

I suspect it relates to https://github.com/lucc/nvimpager/blob/da3bbf02fac10fa3f1d5df501f856c2959329ebf/lua/nvimpager/pager.lua#L53 but now I really need to stop being nerd sniped byeeeeee 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI needs-triage needs to be reviewed needs-user-input
Projects
None yet
Development

No branches or pull requests

3 participants