I'd like to try and get to a similar setup that I have with N/Vim in OSX, whereby Truecolor support is enabled in iTerm2 (which supports 24bit colors) but disabled in the native Terminal app (which doesn't support it). This is simply for flexibility - sometimes I forget to use iTerm, and sometimes I'm on a machine that is using my dotfiles, but isn't using iTerm.

I've checked that my terminal is rendering the truecolor palette by running this script which outputs the following in Iterm2

iTerm2 colours

and as expected, outputs the following in Terminal.app:

OSX terminal.app colours

I'm running fish shell version 2.5, and $TERM is set to xterm-256color inside of iTerm2 and also echos this in the terminal. This means if I run tput colors it outputs 256, but from reading around on the web, I don't think it ever outputs anything higher than this though.

In Vim I achieve this with the following line of code in my .vimrc file:

if has("nvim") && terminal_program == "iTerm.app"
  " has true colour support and is nvim
  set termguicolors
  colorscheme base16-materia
elseif terminal_program == "iTerm.app"
  " has true colour support but is using std vim
  set termguicolors
  colorscheme NeoSolarized
  set termguicolors
  colorscheme solarized

which lets me have a different colourscheme for nvim and distinguishes between iTerm app and the standard Terminal app.

I know that the latest version of emacs supports True color, so I installed this by running:

brew install emacs --HEAD --use-git-head --with-cocoa

emacs --version
GNU Emacs 26.0.50
... etc ...

and opening it in the cocoa windowed mode shows the additional colours when I run list-colors-display

Glorious 16 million colours in windowed mode

but doing the same in the terminal with emacs -nw only renders the standard 256, and also looks weird:

emacs in terminal with 256 colors

And running emacs with a non-standard TERM as the commit message mentions doesn't seem to work:

env TERM=xterm-24bit emacs -nw
emacs: Cannot open terminfo database file

The result is also the same with if I set $fish_term24bit to 1 in my fish.config via set -g fish_term24bit 1. So what am I missing to get the True color support working in iTerm2, before I even write the conditional code?

** edit 1 **

So further digging has thrown up the following links that could be useful:

both of which mentions requiring a custom setb24/setf24 terminfo capability to be present, as shown in the example and pasted again below.

$ cat terminfo-24bit.src

# Use colon separators.
xterm-24bit|xterm with 24-bit direct color mode,
# Use semicolon separators.
xterm-24bits|xterm with 24-bit direct color mode,

$ tic -x -o ~/.terminfo terminfo-24bit.src

TERM=xterm-24bit emacs -nw
@end example

As directed, I put this into a file called terminfo-24bit.src and ran the specified tic command, which generated the directory .terminfo in my home dir. However, now when I run emacs I get colour sequences everywhere, which leads me to believe emacs has entered 24bit colour mode, but iTerm2 isn't interpreting these correctly...

colour codes everywhere

  • 1
    My non-expert suspicion is that iterm requires a different terminfo entry than XTerm. I've no idea what, though, and can't find anything much through searches.
    – Alan Third
    Commented May 2, 2017 at 9:58
  • Thanks @AlanThird, I'm not an expert on terminfo either (this is the first time I've even encountered it!) I found this though - iterm2.com/documentation-escape-codes.html - which details the color escape codes that iterm supports. Do you think it's the case that if I rewrite the setb24 or setf24 to use these codes, then emacs will use the new format to output the correct sequences that the iterm will pick up? I'm not sure what the current xterm format is though to translate it... Commented May 9, 2017 at 20:13
  • 1
    This is unrelated to your problem, but FYI I have found the semicolon variant xterm-24bits to be better supported than the colon variant xterm-24bit. IIRC Emacs within tmux doesn't work with the latter.
    – Basil
    Commented May 10, 2017 at 11:05
  • Thanks @Basil, just confirmed that to be the case, so good to know. Will stick with the semicolon variant. Commented May 10, 2017 at 19:46
  • Great question! Commented Feb 5, 2018 at 6:22

1 Answer 1


I believe that the @ symbols in your terminfo example are part of the Texinfo markup, rather than part of the terminfo code. Your terminfo entry should look like:

# Use colon separators.
xterm-24bit|xterm with 24-bit direct color mode,
# Use semicolon separators.
xterm-24bits|xterm with 24-bit direct color mode,
  • Thanks @Alan-third, you got there just before I did! I posted a separate question on Stack overflow regarding texinfo files and just received the answer pointing out the @ symbols not being part of it. Knew they looked suspicious. Commented May 10, 2017 at 19:41
  • Ah, I ended up looking through the terminfo man page and noticed that there's no mention of @ anywhere. Glad it's sorted now.
    – Alan Third
    Commented May 10, 2017 at 22:06
  • 1
    Compiling this file produces two files - xterm-24bit and xterm-24bits, but neither is visible by shell: zsh: can't find terminal definition for xterm-24bit error when running TERM=xterm-24bit. Any ideas why? OSX 13 here. Commented Sep 4, 2018 at 12:19
  • /usr/bin/tic -x -o ~/.terminfo /path/to/whatever-you-named-xterm-24bit.src. Notice the use of system tic instead of just tic
    – Joe
    Commented Jul 22, 2021 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.