b-ryan / powerline-shell

A beautiful and useful prompt for your shell
MIT License
6.22k stars 745 forks source link

hostname:colorize sometimes produces low contrast combinations #381

Open catskul opened 6 years ago

catskul commented 6 years ago

If it helps, here's an example of the FG BG pair for my hostname:
image

I think that color_compliment.py appears to do something other than it's name implies. I.e. to be the opposite it should do (x + 0.5) %1 rather than the (x + 0.2) %1 that it appears to be doing.

https://github.com/b-ryan/powerline-shell/blob/ae33f7e7cf48583c7647a3481967aa0dfdb9909e/powerline_shell/color_compliment.py#L15

Shifting it to 0.5 definitely increases contrast (though can produce some hideous combinations).

Shall I make a pull request?

b-ryan commented 6 years ago

I don't suppose the change in #353 might have affected this?

I'm not entirely sure what to do. I don't use the hostname colorization, I didn't write the code, and I don't much like maintaining it. Since I don't often get the chance, could you let me know what you use this feature for?

shikhanshu commented 6 years ago

image

I have the same issue. I am on latest release 0.5.4

shikhanshu commented 6 years ago

A simple fix would be to allow user to specify a hex color string for 'background' and 'foreground' and using hostname-colorize segment. If not provided, fall back to auto-computing the colors (as currently done). Can this be done?

Safranil commented 6 years ago

@b-ryan I have the same issue. The hostname colorization is useful when you manage ton of server, (arround 50 in my case). The hostname colorization permit to associate color code to an host.

As @shikhanshu said, add some option to set an hex color for the foreground and background will be ok.

Safranil commented 6 years ago

So, as I can write Python code, I proposed the PR #424 to implement this.

b-ryan commented 6 years ago

@shikhanshu @Safranil -- I don't quite understand the proposed solution. The idea is to allow the configuration to specify the fg/bg and if that doesn't exist in the config, then do the actual randomization?

Just to understand the situation, not to propose this as a solution, could you theoretically just use a different theme on each host and not use the colorize option at all?

Safranil commented 6 years ago

I don't quite understand the proposed solution. The idea is to allow the configuration to specify the fg/bg and if that doesn't exist in the config, then do the actual randomization?

Yes, it's the proposed solution by @shikhanshu that is implemented in the PR.

Just to understand the situation, not to propose this as a solution, could you theoretically just use a different theme on each host and not use the colorize option at all?

It's possible but it's a more complicated way to do this.

In my case, Puppet is in charge to put the powerline-shell.json, so it set the fg and bg (and others parameters) for me.

My need is different than @shikhanshu, I need to color the hostname per task:

With that, you can say "It's the 1st storage server".