Instead of configuring colors separately for both Vim and the rest of the terminal, limiting Vim’s color scheme to 16 ANSI colors allows setting all color preferences in the terminal’s theme. Doing so results in consistent colors among terminal utilities and a color theme that’s quick to swap out for another one. Figure 1. Vim and a git log side by side in tmux in Terminal.app. By using Dim as Vim’s color scheme, all color values are set by the terminal theme (showing both dark and light mode). The font is SF Mono, 14pt, with a line spacing of 1.2. I’ve been using a customized version of Vim’s default color scheme for the last couple of years. Unlike Vim’s default, it exclusively uses 16 ANSI colors by setting each color to a value between 0 and 15. The terminal emulator’s theme sets the specific color values instead of hard coding them into the Vim color scheme and relying on true color support. By using the terminal theme exclusively, all utilities use the same color values. For example, I don’t configure tmux’s colors, as the green color the terminal theme uses is already a shade I like.

Terminal colors and ANSI escape sequences Terminal emulators use ANSI escape sequences to–amongst other things like controlling the cursor’s position–read the desired text and background color when printing output. $ echo -e "\033[31mred\033[m" # Prints “red” in red. Although most terminal emulators support at least 256 colors, most utilities use one of the main sixteen colors (black, red, green, yellow, blue, magenta, cyan, white, and a high intensity or bright version of each). For example, git shows diffs with additions in green and deletions in red, and most testing frameworks print green dots for passed tests and red F’s for failures. Normal Bright Black 0 8 Red 1 9 Green 2 10 Yellow 3 11 Blue 4 12 Purple 5 13 Cyan 6 14 White 7 15 The terminal emulators we use today assign each of these relative named colors with a 24-bit color value. This separates the utility’s intent (“print this error in red”) from the terminal emulator’s styling (“#C31633 is a nice shade of red”). These colors are configurable in your terminal emulator’s settings, along with the used font and other options. 8-bit and 24-bit ANSI color Beyond the first sixteen named colors numbered 1 through 16, we arrive in absolute color territory. The color codes from 16 to 255 are used to print 8-bit colors, from which 232 to 255 are grayscale values from black to white. # prints “hotpink” in #205 (HEX: #f69, RGB: 255, 102, 153) $ echo -e "\033[38;5;205mhotpink\033[m" Then, there’s 24-bit color, also named true color, which has 16.777.216 different color values. # prints “giant goldfish” in 24-bit orange (HEX: #F38630, RGB: 243, 134, 48) $ echo -e "\033[38;2;243;134;48mgiant goldfish\033[0m" Being absolute color values, they’re not configurable in the terminal emulator’s settings.

Terminal themes By changing the terminal theme, using one like appsignal.terminal or any of the hundreds of other available themes, the terminal emulator can display the relative colors in any true color value you like. Using #C31633 for red will color deletions in git’s diff output in that exact color, for example. Tip: In Terminal.app, use ⌘ + I to open the Inspector to change the current window’s theme without opening a new terminal window. Setting the precise color values in the terminal emulator’s profile or using a terminal theme allows the utility to mark some output as “yellow”, without having to supply an exact shade. The shade is either up to the terminal or the user’s preferences.