fish-terminal-compatibility - Man Page

fish writes various control sequences to the terminal. Some must be implemented to enable basic functionality, while others enable optional features and may be ignored by the terminal.

The terminal must be able to parse Control Sequence Introducer (CSI) commands, Operating System Commands (OSC) and optionally Device Control Strings (DCS). These are defined by ECMA-48. If a valid CSI, OSC or DCS sequence does not represent a command implemented by the terminal, the terminal must ignore it.

Control sequences are denoted in a fish-like syntax. Special characters other than \ are not escaped. Spaces are only added for readability and are not part of the sequence. Placeholders are written as Ps for a number or Pt for an arbitrary printable string.

NOTE: fish does not rely on your system's terminfo database. In this document, terminfo (TI) codes are included for reference only.

Required Commands

SequenceTIDescription
\rn/aMove cursor to the beginning of the line
\ncud1Move cursor down one line.
\e[ Ps AcuuMove cursor up Ps columns, or one column if no parameter.
\e[ Ps CcufMove cursor to the right Ps columns, or one column if no parameter.
\x08cub1Move cursor one column to the left.
\e[ Ps DcubMove cursor to the left Ps times.
\e[HcupSet cursor position (no parameters means: move to row 1, column 1).
\e[KelClear to end of line.
\e[JedClear to the end of screen.
\e[2JclearClear the screen.
\e[0cRequest Primary Device Attribute. The terminal must respond with a CSI command that starts with the ? parameter byte (so a sequence starting with \e[?) and has c as final byte.

Failure to implement this will cause a brief pause at startup followed by a warning. For the time being, both can be turned off by turning off the query-terminal feature flag.
n/aamSoft wrap text at screen width.
n/axenlPrinting to the last column does not move the cursor to the next line. Verify this by running printf %0"$COLUMNS"d 0; sleep 3

Optional Commands

SequenceTIDescription
\titMove the cursor to the next tab stop (à 8 columns). This is mainly relevant if your prompt includes tabs.
\e[msgr0Turn off bold/dim/italic/underline/reverse attribute modes and select default colors.
\e[1mboldEnter bold mode.
\e[2mdimEnter dim mode.
\e[3msitmEnter italic mode.
\e[4msmulEnter underline mode.
\e[4:2mSuEnter double underline mode.
\e[4:3mSuEnter curly underline mode.
\e[4:4mSuEnter dotted underline mode.
\e[4:5mSuEnter dashed underline mode.
\e[7mrevEnter reverse video mode (swap foreground and background colors).
\e[23mritmExit italic mode.
\e[24mrmulExit underline mode.
\e[38;5; Ps msetafSelect foreground color Ps from the 256-color-palette.
\e[48;5; Ps msetabSelect background color Ps from the 256-color-palette.
\e[58:5: Ps m (note: colons not semicolons)SuSelect underline color Ps from the 256-color-palette.
\e[ Ps msetaf setabSelect foreground/background color. This uses a color in the aforementioned 256-color-palette, based on the range that contains the parameter: 30-37 maps to foreground 0-7, 40-47 maps to background 0-7, 90-97 maps to foreground 8-15 and 100-107 maps to background 8-15.
\e[38;2; Ps ; Ps ; Ps mSelect foreground color from 24-bit RGB colors.
\e[48;2; Ps ; Ps ; Ps mSelect background color from 24-bit RGB colors.
\e[49mReset background color to the terminal's default.
\e[58:2:: Ps : Ps : Ps m (note: colons not semicolons)SuSelect underline color from 24-bit RGB colors.
\e[59mSuReset underline color to the default (follow the foreground color).
\e[ Ps SindnScroll up the content (not the viewport) Ps lines (called SCROLL UP / SU by ECMA-48 and "scroll forward" by terminfo). When fish detects support for this feature, status test-terminal-features scroll-content-up will return 0, which enables the ctrl-l binding to use the scrollback-push special input function.
\e[= Ps u, \e[? Ps un/aEnable the kitty keyboard protocol.
\e[6nn/aRequest cursor position report. The response must be of the form \e[ Ps ; Ps R where the first parameter is the row number and the second parameter is the column number. Both start at 1.

This is used for truncating multiline autosuggestions at the screen's bottom edge, by the scrollback-push special input function, and inside terminals that implement the OSC 133 click_events feature.
\e[ \x20 qSeReset cursor style to the terminal's default. This is not used as of today but may be in future.
\e[ Ps \x20 qSsSet cursor style (DECSCUSR); Ps is 2, 4 or 6 for block, underscore or line shape.
\e[ Ps qn/aRequest terminal name and version (XTVERSION). This is only used for temporary workarounds for incompatible terminals.
\e[?25hcvvisEnable cursor visibility (DECTCEM).
\e[?1004hn/aEnable focus reporting.
\e[?1004ln/aDisable focus reporting.
\e[?1049hn/aEnable alternate screen buffer.
\e[?1049ln/aDisable alternate screen buffer.
\e[?2004hEnable bracketed paste.
\e[?2004lDisable bracketed paste.
\e]0; Pt \x07tsSet terminal window title (OSC 0). Used in fish_title.
\e]2; Pt \x07tsSet terminal tab title (OSC 1). Used in fish_tab_title.
\e]7;file:// Pt / Pt \x07Report working directory (OSC 7). Since the terminal may be running on a different system than a (remote) shell, the hostname (first parameter) will not be localhost.
\e]8;; Pt \e\\Create a hyperlink (OSC 8) <https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>. This is used in fish's man pages.
\e]52;c; Pt \x07Copy to clipboard (OSC 52). Used by fish_clipboard_copy.
\e]133;A; click_events=1\x07Mark prompt start (OSC 133), with kitty's click_events extension. The click_events extension enables mouse clicks to move the cursor or select pager items, assuming that cursor position reporting is available.
\e]133;C; cmdline_url= Pt \x07Mark command start (OSC 133), with kitty's cmdline_url extension whose parameter is the URL-encoded command line.
\e]133;D; Ps \x07Mark command end (OSC 133);  Ps is the exit status.

\eP+q Pt \e\\

Request terminfo capability (XTGETTCAP). The parameter is the capability's hex-encoded terminfo code. To advertise a capability, the response must be of the form \eP1+q Pt \e\\ or \eP1+q Pt = Pt \e\\. In either variant the first parameter must be the hex-encoded terminfo code. The second variant's second parameter is ignored.

Currently, fish only queries the indn string capability.

DCS Commands and Gnu Screen

Fully-correct DCS parsing is optional because fish switches to the alternate screen before printing any DCS commands. However, since GNU screen neither allows turning on the alternate screen buffer by default, nor treats DCS commands in a compatible way, fish's initial prompt may be garbled by a DCS payload like +q696e646e. For the time being, fish works around this by checking for presence of the STY environment variable. If that doesn't work for some reason, you can add this to your ~/.screenrc:

altscreen on

Or add this to your config.fish:

function GNU-screen-workaround --on-event fish_prompt
    commandline -f repaint
    functions --erase GNU-screen-workaround
end

Unicode Codepoints

By default, fish outputs the following non-ASCII characters:

× ► ¶ ⏎ • ● … μ – ’ ‘ “ ” ← → ↑ ↓

as well as control pictures (U+2400 through U+241F), and locale-specific ones in translated strings.

Author

fish-shell developers

Info

Nov 10, 2025 4.2 fish-shell