git-quick-stats icon indicating copy to clipboard operation
git-quick-stats copied to clipboard

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

Open dexterp opened this issue 4 years ago • 6 comments

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

dexterp avatar Oct 21 '20 08:10 dexterp

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

tomice avatar Oct 21 '20 16:10 tomice

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.

dexterp avatar Oct 22 '20 00:10 dexterp

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.

tomice avatar Oct 22 '20 00:10 tomice

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.

dexterp avatar Oct 22 '20 08:10 dexterp

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.

tomice avatar Oct 22 '20 12:10 tomice

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.

ofnuts avatar May 15 '22 22:05 ofnuts