lazygit
lazygit copied to clipboard
Truecolors not working inside tmux
Describe the bug This is driving me nuts, I can't really find someone else mention this problem. Inside tmux lazygit colors are looking like this:
What is interesting is that if I enter neovim (in tmux as well) and launch lazygit from its terminal colors are fine:
It works OK if i set screen-256color in tmux, but then I can't have italics and underlines in SSH. I am using kitty terminal, but tested with wezterm and alacritty and the result is the same. Also when diffing outside lazygit with delta colors are fine. Here are relevant configs:
tmux:
set -g default-terminal "tmux-256color"
set -as terminal-features ",${TERM}:RGB"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
delta:
[core]
editor = nvim
pager = delta --features=interactive
[interactive]
diffFilter = delta
[delta]
navigate = true
line-numbers = true
true-color = always
syntax-theme = tokyonight_night
minus-style = "syntax #3b263a"
minus-emph-style = "syntax #5e355c"
zero-style = "syntax auto"
plus-style = "syntax #263949"
plus-emph-style = "syntax #394b70"
line-numbers-minus-style = "#f7768e auto"
line-numbers-zero-style = "#565f89 auto"
line-numbers-left-style = "#565f89 auto"
line-numbers-plus-style = "#41a6b5 auto"
hunk-header-decoration-style = "blue box"
[delta "interactive"]
side-by-side = true
lazygit:
git:
paging:
colorArg: always
pager: delta --dark --paging=never
To Reproduce Steps to reproduce the behavior:
- Start tmux session
- Launch lazygit
- Truecolors are not working
Expected behavior Colors should be fine inside tmux
Screenshots
Truecolors are working fine inside my terminal:
Version info:
commit=v0.42.0, build date=2024-05-19T10:54:29Z, build source=binaryRelease, version=0.42.0, os=linux, arch=amd64, git version=2.45.2
I'm having the same problem, as mentioned in #3362
Just for the record I have COLORTERM=truecolor setup inside tmux.
I think I have the exact same problem...
A weird-ish yellow background for both additions and deletions when inside Tmux > lazygit. The regular git-delta diff colors work when lazygit runs outside of Tmux. Or when just using git diff (using delta) inside of Tmux.
Somehow that 3rd layer (Tmux > lazygit > delta) messes up the background colors from my theme.
I don't know why I didn't think of this until now, but the solution I've found is to alias lazygit to use screen-256color env in my .zshrc / .bashrc:
alias lazygit='env TERM=screen-256color lazygit'
alias lg='lazygit'
Thanks for the workaround 😁
I guess that also sheds some more light on the underlying issue.
Inside of Tmux $TERM is usually set to tmux-256color.
Delta works fine when run standalone inside of Tmux. At least when also setting a :Tc "terminal override in Tmux like so:
set-option -ga terminal-overrides ",*-256color:Tc"
What could be going on inside of lazygit here that messes with this?
I don't know why I didn't think of this until now, but the solution I've found is to alias lazygit to use
screen-256colorenv in my.zshrc/.bashrc:alias lazygit='env TERM=screen-256color lazygit' alias lg='lazygit'
I don't know if lazygit uses italics but screen-256color does not support italics
It seems this was introduced by https://github.com/jesseduffield/lazygit/commit/ad0394aebebddc5fc17043bbeb72894b8d670abb because of https://github.com/gdamore/tcell/commit/216e30afd7d0329c44490546d6ef7e628ac8f74c removing tmux-256color terminfo.
Following, as I'm running into exact same issue. Colors output correctly outside of TMUX, Truecolor working flawlessly for everything else except lazygit with delta for pager. Delta on it's own in TMUX outputs as anticipated. TERM = xterm-kitty in my instance.
Can you test this again with current master? I don't understand the problem well enough to tell for sure, but I have the suspicion that it might be fixed by #4166 which was merged today.
I built from last commit and can confirm that it is working now, thank you @stefanhaller!
Maybe it's different problem but using alacritty lazygit works fine except I run it on a tmux session:
2025/02/09 15:40:57 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues
*exec.Error exec: "infocmp": executable file not found in $PATH
github.com/jesseduffield/lazygit/pkg/app/app.go:55 (0x558e74a75bbd)
github.com/jesseduffield/lazygit/pkg/app/entry_point.go:167 (0x558e74a77cdc)
github.com/jesseduffield/lazygit/main.go:23 (0x558e74a78e78)
internal/runtime/atomic/types.go:194 (0x558e742a4b1d)
runtime/asm_amd64.s:1700 (0x558e742e3bc1)
(infocmp comes from ncurses packages which I prefer to avoid install if not needed)
Running '$ TERM=alacritty lazygit' works fine.
Maybe it's different problem but using alacritty lazygit works fine except I run it on a tmux session:
2025/02/09 15:40:57 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues *exec.Error exec: "infocmp": executable file not found in $PATH github.com/jesseduffield/lazygit/pkg/app/app.go:55 (0x558e74a75bbd) github.com/jesseduffield/lazygit/pkg/app/entry_point.go:167 (0x558e74a77cdc) github.com/jesseduffield/lazygit/main.go:23 (0x558e74a78e78) internal/runtime/atomic/types.go:194 (0x558e742a4b1d) runtime/asm_amd64.s:1700 (0x558e742e3bc1)(infocmp comes from ncurses packages which I prefer to avoid install if not needed)
Running '$ TERM=alacritty lazygit' works fine.
Are you seeing TERM within tmux?
set -g default-terminal "${TERM}"
Otherwise it’ll use the tmux default which does not play nicely with proper colours.
Note that you might need to completely restart the tmux server to see TERM changes propagate properly.
I have this:
COLORTERM=truecolor
TERM=tmux-256color
TERM_PROGRAM=tmux
TERM_PROGRAM_VERSION=3.5a
I thought about just change it but don't sure if it's the ideal solution.
have anyone tested with tmux-direct ?
For me in,
TERM_PROGRAM_VERSION=3.5a
COLORTERM=truecolor
TERM_PROGRAM=tmux
TERM=tmux-direct
the colors are like this.
But if run it with env term=screen-256color lazygit (or tmux-256color or tmux) the colors are normal.