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

Support light themed terminals through detection and use an alternate color scheme #116

Open
dexterp opened this issue Oct 21, 2020 · 6 comments
Assignees

Comments

@dexterp
Copy link

dexterp commented Oct 21, 2020

I used a light themed terminal as do many others. Personally I find it easier to focus if the terminal is light (white background in my case).

I realise that Git-quick-stats has the environment variable "_MENU_THEME=legacy" which makes the output visible in light themed terminals but it is inconvient to have to set this.

This is the screenshot from the integrated terminal in VS Code.
Screenshot from 2020-10-21 18-53-56

@tomice
Copy link
Collaborator

tomice commented Oct 21, 2020

You can set that variable in your respective shell's .rc or .profile so you don't have to set it manually every time.

@dexterp
Copy link
Author

dexterp commented Oct 22, 2020

Hello Tom,

Before addressing your comment, I'm happy to contribute this feature once I've finished with another project I'm working on.

I do have it in my .zshrc file, the convenience of having this "out of the box" was what I was aiming for.

The variable _MENU_THEME uses "legacy" as its value implying that it will some day disappear. Perhaps _MENU_THEME=(dark|light) would be better suited.

This is potentially two features.

  1. Detect the background and set the theme accordingly.

  2. Forcibly set the theme using _MENU_THEME=(dark|light).

If you have any thoughts on how this should be done or not done let me know.

@tomice
Copy link
Collaborator

tomice commented Oct 22, 2020

Colors are a hard thing in general. Being able to create themes that work across a multitude of systems (certain systems are more limited in color choices than others), adhering to accessibility (four types of red-green color blindness, two types of blue-yellow color blindness, and complete color blindness, for example), and having them all work across different user's custom shell colors is definitely a challenge. The current theme colors are a result of one user's preferences via a pull request. The "legacy" name was the original theme from its inception. In reality, neither one is perfect and both have limitations.

An ideal theme, if there is such a thing, would be one that could work in both light terminals and dark terminals alike. Neither would choose colors that clash with each dark/light theme, albeit those themes may be more optimal for one color scheme than another. So for example, preferring a grey or silver would be more optimal than choosing white because, as your picture shows, white just is not visible with certain themes. It would also contain colors that are generally acceptable for those with color disabilities.

Attempting to parse a terminal's background color could prove to be quite difficult when you consider this software runs on all different flavors of Linux and UNIX, along with Cygwin, Putty, and so on. Apple's terminal doesn't always respect xterm control sequences, for example; neither does MATE. Even the way vim does it is 100% guessing (https://github.com/vim/vim/blob/05c00c038bc16e862e17f9e5c8d5a72af6cf7788/src/option.c#L3962). So there's a lot to think about when it comes to colors, themes, and how it works across systems.

I'm more than happy to let someone work on this, so if you'd like to, please feel free! :) I'm personally not really tied to any theme or any color scheme, so if you decide for light or dark to be the main theme, that's perfectly fine by me. Not sure if @arzzen has any preferences on colors, so we'll ping him just in case. ;)

I'd be very excited to see what someone comes up with when it comes to developing a nice theme for this piece of software that works across multiple different terminal color schemes! It's definitely a lot to research and think about. We would also want to test this on a myriad of systems, too. I can assist with testing if you'd like to move forward with this.

@dexterp
Copy link
Author

dexterp commented Oct 22, 2020

Colors are a hard thing in general. Being able to create themes that work
across a multitude of systems

Indeed trying to solve completely is near impossible. There are 1772 potential
$TERMs from the terminfo database, I'm thinking that mostly supporting xterm
and a handful of derivatives would make this manageable.

(certain systems are more limited in color choices than others)

I'm planning to keep it at the current implementation of 16 bit colours.

An ideal theme, if there is such a thing, would be one that could work in
both light terminals and dark terminals alike

Having a handful of themes and turning off colors completely is the best one
can hope for. My thought is to use VIMs colour schemes (peachpuff, ron perhaps
others) which isn't quite a standard but a least people will be somewhat
familiar with it.

I don't want to go overboard with themes.

If you have access to MAC can you find out what the $TERM value holds, I'm
thinking it will be "xterm-256color"

edit: "tput colors" is all I need.

@tomice
Copy link
Collaborator

tomice commented Oct 22, 2020

Sure can! :)

Toms-MacBook-Pro:~ tomice$ tput colors
256
Toms-MacBook-Pro:~ tomice$ echo $TERM
xterm-256color

Tested both Apple's Terminal program and iTerm 2. Results are both the same. This is on 10.15.6.

@ofnuts
Copy link

ofnuts commented May 15, 2022

I think the default could be no color at all, which would work everywhere. Personally I have changed the code::

    # Adjustable color menu option
    case "${_theme}"  in
        "legacy" )
            TITLES="${BOLD}${RED}"
            TEXT="${NORMAL}${CYAN}"
            NUMS="${BOLD}${YELLOW}"
            HELP_TXT="${NORMAL}${YELLOW}"
            EXIT_TXT="${BOLD}${RED}"
            ;;
        "none" )
            TITLES="${BOLD}"
            TEXT="${NORMAL}"
            NUMS="${BOLD}"
            HELP_TXT="${NORMAL}"
            EXIT_TXT="${BOLD}"
            ;;
        *)
            TITLES="${BOLD}${CYAN}"
            TEXT="${NORMAL}${WHITE}"
            NUMS="${NORMAL}${BOLD}${WHITE}"
            HELP_TXT="${NORMAL}${CYAN}"
            EXIT_TXT="${BOLD}${CYAN}"
            ;;
    esac

Works fine on my black-on-light-yellow vintage-style console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants