Skip to main content

Overview

tmux includes a sophisticated terminal feature detection system that automatically identifies and enables advanced terminal capabilities. This allows tmux to provide enhanced functionality when the underlying terminal supports it.

Terminal Features System

Feature Detection

tmux detects terminal features through multiple mechanisms:
  • terminfo capabilities: Standard terminal database entries
  • Terminal type identification: Recognizing specific terminal emulators
  • Device Attributes (DA): Querying the terminal at runtime
  • Manual specification: Using the terminal-features option
The feature detection code is implemented in tty-features.c.

Available Terminal Features

tmux supports the following terminal features:

Color Support

From tty-features.c:116-128, the RGB feature includes:
  • setrgbf: Set RGB foreground color (\E[38;2;%p1%d;%p2%d;%p3%dm)
  • setrgbb: Set RGB background color (\E[48;2;%p1%d;%p2%d;%p3%dm)
  • Support for 256-color palette alongside RGB

Text Attributes

Enables strikethrough text formatting:
Implemented as escape sequence: \E[9m
Enables overline text attribute:
Sequence: Smol=\E[53m (from tty-features.c:144-152)
Advanced underscore styling with colors:
Supports:
  • Different underscore types (single, double, curly, dotted, dashed)
  • Underscore colors independent of text color
  • RGB colors for underscores
From tty-features.c:155-166:
  • Smulx: Set underscore style
  • Setulc: Set underscore RGB color
  • Setulc1: Set underscore palette color

Advanced Features

Title Setting

Window title escape sequences:
From tty-features.c:51-60:
  • tsl=\E]0; - To status line
  • fsl=\a - From status line

Clipboard

OSC 52 clipboard integration:
Sequence: Ms=\E]52;%p1%s;%p2%s\a (tty-features.c:86-94)

Mouse Support

Xterm-style mouse tracking:
Capability: kmous=\E[M (tty-features.c:75-83)

Focus Reporting

Focus in/out events:
From tty-features.c:181-190:
  • Enable: Enfcs=\E[?1004h
  • Disable: Dsfcs=\E[?1004l

Cursor Customization

Cursor Styles
From tty-features.c:193-202:
  • Ss=\E[%p1%d q - Set cursor style
  • Se=\E[2 q - Reset cursor style
Supports various cursor shapes: block, underline, bar, with blinking variants.
Cursor Colors
From tty-features.c:205-214:
  • Cs=\E]12;%p1%s\a - Set cursor color
  • Cr=\E]112\a - Reset cursor color

Modern Terminal Features

Enhanced keyboard protocol support:
From tty-features.c:239-248:
  • Enable: Eneks=\E[>4;2m
  • Disable: Dseks=\E[>4m
Allows distinguishing more key combinations.

Graphics Features

Graphics features require terminal support and compile-time configuration.
Sixel Graphics
From tty-features.c:350-358, enables sixel image support when compiled with the appropriate libraries.
DECFRA Rectangle Fill
From tty-features.c:265-273, enables fast rectangle filling operations:
  • Capability: Rect
  • Used for optimized screen redraws
DECSLRM Margins
From tty-features.c:251-262, scroll region margins:
  • Enable: Enmg=\E[?69h
  • Disable: Dsmg=\E[?69l
  • Set margins: Cmg=\E[%i%p1%d;%p2%ds

Default Terminal Configurations

tmux includes predefined feature sets for popular terminals (from tty-features.c:468-514):

Modern Terminals Base Set

Most modern terminals support:
When running tmux inside tmux:

Configuration Examples

Override Terminal Type

Force specific features for all terminals:
~/.tmux.conf

Working Directory Tracking

OSC 7 Support

Disable Specific Features

To disable features that cause problems:
From tty-features.c:276-347, this disables kf0 through kf63 terminal capabilities.

Feature Application

1

Feature Detection

tmux applies features in this order:
  1. Default features based on $TERM environment variable
  2. Device Attributes response (if available)
  3. User-specified terminal-features option
2

Capability Override

From tty-features.c:434-464, when features are applied:
3

Verification

Check active features:

Best Practices

Let tmux auto-detect features when possible - manual overrides may cause issues
Test feature changes thoroughly - some terminals report capabilities they don’t fully support
Use wildcards carefully - * matches all terminal types
Some features interact with terminal settings. For example:
  • extkeys requires terminal support for the extended keyboard protocol
  • sync may cause artifacts on slow connections
  • margins can conflict with certain terminal scrollback implementations

Debugging Features

Enable tmux logging to see feature detection: