Skip to content

Instantly share code, notes, and snippets.

@michenriksen
Created November 4, 2023 15:35
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michenriksen/a3fd9e4104548c960696748d994309a3 to your computer and use it in GitHub Desktop.
Save michenriksen/a3fd9e4104548c960696748d994309a3 to your computer and use it in GitHub Desktop.
πŸ’… Get italic text and curly underlines in macOS + Alacritty + tmux + Neovim

Italic text and other styles in Alacritty, tmux, and Neovim on macOS

This is a quick guide to get properly set up with italic text, curly underlines and other advanced styles in Alacritty, tmux, and Neovim on macOS. It assumes you're using the latest versions of all three programs.



Screenshot Neovim showing italicized comments and curly underline under a misspelled word
Looks pretty nice, huh?


After living without italicized comments and fancy underlines under misspelled words for way too long, I finally found a way to get them working in Alacritty, tmux, and Neovim on macOS. It seems that many people struggle with this too so I decided to write this guide. I hope it helps.

Installing the Alacritty terminfo profile

This little detail is something I completely missed when I installed Alacritty. It comes with its own terminfo profile that needs to be installed to make it work correctly. Download and install it by running the following commands:

user@example:~$ curl -L -o alacritty.info "https://github.com/alacritty/alacritty/blob/master/extra/alacritty.info"
user@exampke:~$ sudo tic -xe alacritty,alacritty-direct alacritty.info 
user@example:~$ rm alacritty.info

Next, restart Alacritty and ensure that the $TERM environment variable is set to alacritty:

user@example:~$ echo $TERM
alacritty

If that's not the case, you most likely have it set to something else in your Alacritty configuration file, or in a shell configuration file such as .zshrc.

Testing it

Run the following commands to verify that styling works correctly in Alacritty (NOT in tmux):

echo -e '\e[1mBold\e[22m'
echo -e '\e[2mDimmed\e[22m'
echo -e '\e[3mItalic\e[23m'
echo -e '\e[4mUnderlined\e[24m'
echo -e '\e[4:3mCurly Underlined\e[4:0m'
echo -e '\e[4:3m\e[58;2;240;143;104mColored Curly Underlined\e[59m\e[4:0m'

If everything looks as expected, you are good to go to the next step.

Configuring tmux

Open your ~/.tmux.conf file and add the following lines to it:

set -g default-terminal "alacritty"
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'  # colored underscores
set -as terminal-overrides ',alacritty:RGB' # true-color support

πŸ‘‹ Heads-up: if you are using the tmux-sensible plugin, be aware that it overrides the default-terminal setting to screen-256color, so be sure to add the preceding lines after the line that loads the plugin.

Make sure tmux picks up the new configuration by restarting the server:

user@example:~$ tmux kill-server # WARNING: this will kill all tmux sessions

Start a new tmux session and run the same commands as before to verify that everything looks as expected.

Configuring Neovim

This step can vary by how you configure your Neovim, but essentially, this configuration needs to be set:

vim.opt.termguicolors = true -- enable true-color support

You can verify that everything is good by running :checkhealth nvim in Neovim. The output should include $COLORTERM="truecolor" and a bunch of green OK messages.

You can disregard the $TERM should be "screen-256color" or "tmux-256color" error if it's present in the output.

That's it

Congratulations! You should now have italic text, curly underlines, and other advanced styles working. If not, feel free to leave a comment and I'll try to help.

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