Skip to content

Instantly share code, notes, and snippets.

Last active July 19, 2024 17:36
Show Gist options
  • Save andersevenrud/015e61af2fd264371032763d4ed965b6 to your computer and use it in GitHub Desktop.
Save andersevenrud/015e61af2fd264371032763d4ed965b6 to your computer and use it in GitHub Desktop.
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s >


Configuration files

⚠️ IMPORTANT ⚠️ Don't set $TERM in your shell (zshrc, bashrc, etc.), but your terminal (alacritty).


In ~/.config/alacritty/alacritty.yml:

  TERM: xterm-256color


In ~/.tmux.conf (or ~/.config/tmux/tmux.conf):

set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

# Or use a wildcard instead of forcing a default mode.
# Some users in the comments of this gist have reported that this work better.
#set -sg terminal-overrides ",*:RGB"

# You can also use the env variable set from the terminal.
# Useful if you share your configuration betweeen systems with a varying value.
#set -ag terminal-overrides ",$TERM:RGB"


In ~/.vimrc:

" You might have to force true color when using regular vim inside tmux as the
" colorscheme can appear to be grayscale with "termguicolors" option enabled.
if !has('gui_running') && &term =~ '^\%(screen\|tmux\)'
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

syntax on
set termguicolors
colorscheme yourfavcolorscheme


If you use ~/.vimrc for your nvim configuration, use the above vim example because it's fully compatible.

💡 neovim recently (Dec 6th 2023) merged some changes that detects termguicolors automatically, so there's no need to set this in an upcoming release. I'll update this notice with a version once released as a public version. This came with the 0.10 release (May 16th 2024).

In ~/.config/nvim/init.vim

set termguicolors
colorscheme yourfavcolorscheme

Or ~/.config/nvim/init.lua:

vim.o.termguicolors = true
vim.cmd'colorscheme yourfavcolorscheme'

Not working correctly ?

Check out the comments below for possible solutions.

And if you found another solution I would really appreciate if you left a comment with instructions and the following information:

  • OS/Distro + version
  • Vim or Neovim + version
  • Terminal name + version


Shout-out to the nice folks that provided insightful feedback:

Copy link

BhawickJain commented Jul 17, 2023

When following these instructions and changing the tmux config, I found that my backspace key created space characters.

this was resolved after restarting tmux server

tmux kill-server

hope this help anyone, thank you for this awesome gist!

macOS (11.7.8)
NVIM (0.9.1)
alacritty (0.11.0)
tmux (3.3a)

Copy link

Fedora 38, Konsole + TMux 3.3a + neovim 0.9.1 .
The following worked for me:

set -sa default-terminal "screen-256color"
set -sa terminal-features ",xterm-256color:RGB"

Notably, I could NOT have tmux-256color as my default terminal even though I downloaded it off the internet and so I know I had it on hand. It had to be screen.

Copy link

Not everyone have terminfo "tmux-256color" in /usr/share/terminfo/t/tmux-256color (system-wide) or ~/.terminfo/t/tmux-256color (user only) So...There is good Guide how to get tmux-256color ------ >>>> ( work for any distro )

A little Ai model told me you can use infocmp xterm-256color to check if you have this (the paths quoted above were blank, but infocmp found the terminfo here /lib/terminfo/t/tmux-256color (ubuntu 22.04)

Copy link

This solved my issue as well thanks 😊

Copy link

OSX Ventura
Alacritty 0.12.2
tmux 3.3a
nvim 0.9.2


When using neovim within tmux, my colors were off and it would not display italics or undercurls.


I had trouble with the provided solution, but it pointed me in the right direction. This is what works for me.


I left the env: section commented out


set-option -sa terminal-features ',alacritty:RGB'
set-option -ga terminal-features ",alacritty:usstyle"
set-option -ga terminal-overrides ',alacritty:Tc'
set -g default-terminal "alacritty"


termguicolors = true

Copy link

I find that when I press backspace inside tmux, it convert to white space. also the color is also inconsisent outside and inside tmux image

MacOS : 12.6
Vim : 9.0
Alacritty : 0.11.0

inside alacritty.yml:

    family: Menlo 

  size: 14.0

Inside .vimrc:

set background=dark
if !has('gui_running') && &term =~ '^\%(screen\|tmux\)'
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
syntax on
set termguicolors
colorscheme onedark

Inside .tmux.conf:

set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

@sokinpui The phenomenon I encountered before is the same as yours. You can try this set of configurations. It works for me.


  TERM: screen-256color


set -g default-terminal "screen-256color"
set-option -sa terminal-overrides ',screen-256color:Tc'

Copy link

nickgnd commented Oct 24, 2023

Hey 👋
This combination of settings works fine for me

# .alacritty.yml

  TERM: alacritty

and in my tmux config:

# tmux.conf

set-option -g default-terminal "screen-256color"
  • OS/Distro: MacOS Ventura 13.6
  • Vim: VIM - Vi IMproved 9.0
  • Terminal: alacritty 0.12.3 (5efb069)
  • Tmux: tmux 3.3a

Hope it can help ✌️

Copy link

Alacritty versions >= 0.13.0 (moved to TOML for config)


Copy link

Hritik14 commented Nov 7, 2023

Italics in my vim were messed up, if someone has this problem, you can verify by running

echo -e "\e[3mitalic\e[0m"

if output is in italics then it's a vim problem, otherwise something else is wrong.

I had to add the following in my vimrc as per this for italics.

let &t_ZH="\e[3m"
let &t_ZR="\e[23m"

using macvim, tmux and iterm2

Copy link

Thank you so much for this..

I legit switched to kitty for months over this issue, I had tried every fix out there (what did it was the ENV) so glad to be back with alacritty

Copy link

AMAZING!!! Thanks

Copy link

mikeslattery commented Dec 11, 2023


(edits: I was wrong. Only the neovim changes aren't necessary.)

tl;dr - This gist is no longer necessary with latest Neovim.

Neovim now checks for 256 color compatibility and automatically sets termguicolors. Alacritty with default $TERM value ("alacritty") works fine. I just tested it with nightly.

Recent changes announced at the Neovim conference a few days ago have made the changes in this gist unnecessary for latest builds. However, I'm sure as of this moment many people are using versions that don't yet support this and that will likely be the case for a few weeks. I don't know the exact version this was added, or which versions have it other than latest nightly.

Of course, it will still be necessary for Vim.

Copy link

Thanks for the heads-up @mikeslattery ! This is great news :)

I'll update this article and follow up when this goes into a public release.

Copy link

mikeslattery commented Dec 13, 2023

Looks like I wasn't correct. You still need the tmux and alacritty config. You just don't need the neovim config anymore.

Quick test for Linux. As of this comment it works for nightly and not for release.

# Test for truecolor.  Should see bands of smooth gradient colors.

# To test  installed nvim, set this to "nvim" and comment out #linux nvim install block, and remove rm $NVIM line

# Linux nvim install
# Change to $NIGHTLY to see it working correctly.
chmod +x $NVIM

# Reconfigure
echo '
set -ag terminal-overrides ",xterm-256color:RGB"
' > /tmp/.tmux.conf
echo '
  TERM: xterm-256color
' > /tmp/alacritty.yaml

# Test
alacritty --config-file /tmp/alacritty.yaml \
  -e tmux -f /tmp/.tmux.conf -L nvim new-session \
  $NVIM --clean  "+terminal curl -s $TEST | bash" "+set termguicolors?"
# old way:
# $NVIM --clean  +"set termguicolors" "+colorscheme ron" "+terminal curl -s $TEST | bash"

# Cleanup
rm "$NVIM"
rm /tmp/.tmux.conf /tmp/alacritty.yaml

Copy link

Appreciate the detailed follow-up on this @mikeslattery. I've updated the article to reflect this 👍

Copy link

n0099 commented Feb 29, 2024

echo 'set -as terminal-overrides ",'"$(echo ${TERM%%-*})"'*:Tc"' >> ~/.tmux.conf

tmux must be told that the terminal outside supports RGB colour. This is done by specifying the RGB or Tc terminfo(5) flags. RGB is the official flag, Tc is a tmux extension.

With tmux 3.2 and later this can be added with the terminal-features option:

set -as terminal-features ",gnome*:RGB"

Or for any tmux version the terminal-overrides option:

set -as terminal-overrides ",gnome*:Tc"

and replace gnome with the result of echo ${TERM%%-*} (the first part of $TERM delimited by -) from the terminal emulator that you are currently using outside tmux such as putty or xterm.

Copy link

ferBV commented Mar 24, 2024

Just what I needed, thank you a lot.

Copy link

My configuration:

alacritty 0.13.2
NVIM v0.9.5


# Fix Colors
set -g default-terminal "screen-256color"
set -ag terminal-overrides ",xterm-256color:RGB



config neovim

vim.opt.termguicolors = true

Copy link

zachliu commented Jun 3, 2024

My configuration:

zsh 5.9
tmux 3.4
alacritty 0.13.2
NVIM v0.10.0-dev-3135+g7acf39dda


set -g default-terminal "tmux-256color"
set -sg terminal-overrides ",*:RGB"


if $COLORTERM ==# 'truecolor'
  set termguicolors
  set guicursor=

nothing special on alacritty.toml and .zshrc
i didn't set env TERM explicitly. but i have

$ env | rg TERM

Copy link

rdyson commented Jun 8, 2024

Thanks for this!

Copy link

@LeFede This worked for me with Arch/Alacritty/tmux


  TERM: alacritty-direct


set-option -a terminal-overrides ",alacritty:RGB"

default-terminal was not needed in the tmux.conf

This worked for me. Thanks so much for adding this information!

Copy link

On a Wayland / Hyprland setup

My .tmux.conf only has the line:

set -g default-terminal "screen-256color"

I added to alacritty.toml, which seemed to be the key:

transparent_background_colors = true
opacity = 0.8

Immediately both neovim and tmux started showing transparency. I did not have to explicitly set vim.opt.termguicolors = true in my neovim conf.

Copy link

I've only added the following to alacritty.toml (i.e.: using a default tmux config) and it seems to work as expected.

TERM = "alacritty-direct"

Undercurls, italics, bold, strikethrough, etc. also work.

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