Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Last active April 22, 2024 15:59
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.

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

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.

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