lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Add support of all possible terminal color themes

Open okravets-intellias opened this issue 4 years ago • 21 comments

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

okravets-intellias avatar May 28 '21 07:05 okravets-intellias

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

mjarkk avatar May 28 '21 08:05 mjarkk

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?

okravets-intellias avatar May 28 '21 14:05 okravets-intellias

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.

mjarkk avatar May 28 '21 17:05 mjarkk

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.

KeqiZeng avatar May 31 '21 07:05 KeqiZeng

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?

Cokile avatar Jul 25 '21 07:07 Cokile

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

mjarkk avatar Jul 25 '21 09:07 mjarkk

@Cokile Can you checkout #1395 ?

mjarkk avatar Jul 25 '21 10:07 mjarkk

@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
  1. change config to:
gui:
  theme:
    lightTheme: true
    selectedRangeBgColor:
      - '#00ff00'
  1. 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

Cokile avatar Jul 25 '21 11:07 Cokile

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 avatar Jul 25 '21 12:07 mjarkk

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

mjarkk avatar Jul 25 '21 13:07 mjarkk

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

mjarkk avatar Jul 28 '21 10:07 mjarkk

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

Cokile avatar Jul 28 '21 10:07 Cokile

@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

jesseduffield avatar Oct 17 '21 09:10 jesseduffield

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

mjarkk avatar Oct 17 '21 13:10 mjarkk

what are your thoughts @okravets-intellias ?

jesseduffield avatar Oct 17 '21 22:10 jesseduffield

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.

okravets-intellias avatar Oct 19 '21 10:10 okravets-intellias

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

jesseduffield avatar Oct 19 '21 10:10 jesseduffield

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.

okravets-intellias avatar Oct 19 '21 10:10 okravets-intellias

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.

wimstefan avatar Apr 02 '22 09:04 wimstefan

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

FlyinPancake avatar May 18 '22 07:05 FlyinPancake

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?

WhiteBlackGoose avatar Aug 19 '22 05:08 WhiteBlackGoose