jesseduffield / lazygit

simple terminal UI for git commands
MIT License
47.99k stars 1.72k forks source link

Add support of all possible terminal color themes #1339

Open okravets-intellias opened 3 years ago

okravets-intellias commented 3 years ago

Is your feature request related to a problem? Please describe. I have a light theme in my terminal emulator. I can't even try lazygit because apparently it does not know abouth color themes other than default one.

Describe the solution you'd like Support other color schemes.

Describe alternatives you've considered Not using lazygit :(

Additional context this is unusable

mjarkk commented 3 years ago

Do you know about /docs/Config.md#light-terminal-theme?
If not hopefully that will fix your issue :)

okravets-intellias commented 3 years ago

Will that fix everyone else's issues with any custom theme person wants? What if a person likes to switch themes several times a day? Personally I like to switch every other month. Do I need to edit config every time or write my own automation around this?

mjarkk commented 3 years ago

Currently yes, you'll have to write some script around auto changing the config file. There isn't really a good way of checking if the terminal has a light or a dark background sadly.

Maybe we can implement a shell variable for changing config file location so you can have 2 config file and then you'll only have to change one shell var to change the theme.

KeqiZeng commented 3 years ago

Hi, I find the difference between lightTheme: true and lightTheme: false is only the color of some fonts. If we can choose a color for these fonts, just like we can choose a color for activeBorderColor, then it can work good both in light and dark terminal.

Cokile commented 2 years ago

Do you know about /docs/Config.md#light-terminal-theme? If not hopefully that will fix your issue :)

Is it possible to support hex color too?

mjarkk commented 2 years ago

@Cokile No but i think we can quite easily support i will look into it!

mjarkk commented 2 years ago

@Cokile Can you checkout #1395 ?

Cokile commented 2 years ago

@mjarkk I tried the following steps:

  1. clone lazygit to Desktop:

    cd ~/Desktop && git clone https://github.com/mjarkk/lazygit.git && git checkout allow-hex-theme-colors
  2. change config to:

    gui:
    theme:
    lightTheme: true
    selectedRangeBgColor:
      - '#00ff00'
  3. execute go install && go run main.go

The selection background color is not shown at all. However the color is rendered correctly if I change '#00ff00' to red.

I'm a newbie to Go, am I doing something wrong?

FYI: OS: MacOS 11.4 Terminal: Alacritty (Latest version) Shell: Fish (Latest version) $TERM: xterm-256color

mjarkk commented 2 years ago

Yea that's probably because my changes do not work on text.
The library we use for giving text color doesn't support RGB text colours and I'm not yet sure what todo about that 🤔

mjarkk commented 2 years ago

Maybe we can use one of these libaries to color text as they seem to support rgb colors:

mjarkk commented 2 years ago

@Cokile can you checkout #1401 it should allow text hex colors to be set

Cokile commented 2 years ago

@mjarkk I have tried with selectedRangeBgColor set to '#ff0000' and it turns out lazygit works great with hex color. Thanks for the awesome work.

jesseduffield commented 2 years ago

@mjarkk now that your PR is in for the multiple config files thing, I wonder if that means we can close this ticket? I'm not aware of any preference in e.g. iterm2 that lets you set env vars for certain profiles though, so it would need to be something the user automates themselves somehow

mjarkk commented 2 years ago

I think so. It will require a new instance of the shell whenever you change your system theme but i think you can read the system theme into a shell variable.

On MacOS the system theme can be read using the following:

# Light theme
$ defaults read -g AppleInterfaceStyle
2021-10-17 15:09:39.426 defaults[85381:7976117] 
The domain/default pair of (kCFPreferencesAnyApplication, AppleInterfaceStyle) does not exist

# Dark theme
$ defaults read -g AppleInterfaceStyle
Dark

On Linux with Gnome you can read the theme to determine if you are using a dark or light theme:

$ gsettings get org.gnome.desktop.interface gtk-theme
'Pop'

On Windows (Powershell) you probably do something like, tough i haven't tested this

Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme
0 = darkmode
1 = lightmode

Then you can create an alias for lazygit using the new Overriding default config file location

jesseduffield commented 2 years ago

what are your thoughts @okravets-intellias ?

okravets-intellias commented 2 years ago

To be honest I like to customize configuration only when I really need to. IMO theme switching is something that can be fully automated even if not for everyone's custom color selection but at least it can have some reasonable defaults. Take a look at tig for example. It just works with all standard themes I've tried to switch to in iTerm. But of course it's your project and if you think current support is enough you can close this issue.

jesseduffield commented 2 years ago

I'd be interested to see how tig goes about it: there might be some easy way of checking whether the user is in light/dark mode, and we could supply some sensible defaults based on that

okravets-intellias commented 2 years ago

I don't think it distinguishes light and dark themes. I may be wrong but I think it uses curses which has support for terminal palette.

wimstefan commented 2 years ago

I just chime in to support the idea of using the terminal colours. Being not a programmer I don't have any idea how hard it is to implement but it seems to be the way to go to make this wonderful program as readable as possible.

FlyinPancake commented 2 years ago

My desktop switches light and dark themes depending on time of date, so when I want to lazygit I have to fire up a special profile

WhiteBlackGoose commented 1 year ago

Hi. Thanks for this great program. I found this issue as I was trying to find a way to change the color of the font. I think having a setting for it would solve all problems for me: I'd just set it to gray and it will work regardless of the terminal theme. Is there an option for this?