Files
fish-shell/doc_src/terminal-compatibility.rst

340 lines
12 KiB
ReStructuredText
Raw Normal View History

Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
Terminal Compatibility
======================
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 :ref:`optionally <term-compat-dcs-gnu-screen>` Device Control Strings (DCS).
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
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.
For historical reasons, OSC sequences may be terminated with ``\x07`` instead of ``\e\\``.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
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.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
**NOTE:** fish does not rely on your system's terminfo database.
In this document, terminfo (TI) codes are included for reference only.
Required Commands
-----------------
.. list-table::
:widths: auto
:header-rows: 1
* - Sequence
- TI
- Description
* - ``\r``
- n/a
- Move cursor to the beginning of the line
* - ``\n``
- cud1
- Move cursor down one line.
* - ``\e[ Ps A``
- cuu
- Move cursor up Ps columns, or one column if no parameter.
* - ``\e[ Ps C``
- cuf
- Move cursor to the right Ps columns, or one column if no parameter.
* - ``\x08``
- cub1
- Move cursor one column to the left.
* - ``\e[ Ps D``
- cub
- Move cursor to the left Ps times.
* - ``\e[H``
- cup
- Set cursor position (no parameters means: move to row 1, column 1).
* - ``\e[K``
- el
- Clear to end of line.
* - ``\e[J``
- ed
- Clear to the end of screen.
* - ``\e[2J``
- clear
- Clear the screen.
* - .. _term-compat-primary-da:
``\e[0c``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Request Primary Device Attribute.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
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`` :ref:`feature flag <featureflags>`.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - n/a
- am
- Soft wrap text at screen width.
* - n/a
- xenl
- Printing 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
-----------------
.. list-table::
:widths: auto
:header-rows: 1
* - Sequence
- TI
- Description
* - ``\t``
- it
- Move the cursor to the next tab stop (à 8 columns).
This is mainly relevant if your prompt includes tabs.
* - ``\e[m``
- sgr0
- Turn off bold/dim/italic/underline/strikethrough/reverse attribute modes and select default colors.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[1m``
- bold
- Enter bold mode.
* - ``\e[2m``
- dim
- Enter dim mode.
* - ``\e[3m``
- sitm
- Enter italic mode.
* - ``\e[4m``
- smul
- Enter underline mode.
* - ``\e[4:2m``
- Su
- Enter double underline mode.
* - ``\e[4:3m``
- Su
- Enter curly underline mode.
* - ``\e[4:4m``
- Su
- Enter dotted underline mode.
* - ``\e[4:5m``
- Su
- Enter dashed underline mode.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[7m``
- rev
- Enter reverse video mode (swap foreground and background colors).
* - ``\e[9m``
- smxx
- Enter strikethrough mode
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[23m``
- ritm
- Exit italic mode.
* - ``\e[24m``
- rmul
- Exit underline mode.
* - ``\e[29m``
- rmxx
- Exit strikethrough mode.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[38;5; Ps m``
- setaf
- Select foreground color Ps from the 256-color-palette.
* - ``\e[48;5; Ps m``
- setab
- Select background color Ps from the 256-color-palette.
* - ``\e[58:5: Ps m`` (note: colons not semicolons)
- Su
- Select underline color Ps from the 256-color-palette.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[ Ps m``
- setaf
setab
- Select 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 m``
-
- Select foreground color from 24-bit RGB colors.
* - ``\e[48;2; Ps ; Ps ; Ps m``
-
- Select background color from 24-bit RGB colors.
* - ``\e[39m``
-
- Reset foreground color to the terminal's default.
* - ``\e[49m``
-
- Reset background color to the terminal's default.
* - ``\e[58:2:: Ps : Ps : Ps m`` (note: colons not semicolons)
- Su
- Select underline color from 24-bit RGB colors.
* - ``\e[59m``
- Su
- Reset underline color to the default (follow the foreground color).
* - .. _term-compat-indn:
``\e[ Ps S``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
- indn
- Scroll 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, :ref:`status test-terminal-features scroll-content-up <status-test-terminal-features>` will return 0,
which enables the :kbd:`ctrl-l` binding to use the :ref:`scrollback-push <special-input-functions-scrollback-push>` special input function.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[= Ps u``, ``\e[? Ps u``
- n/a
- Enable the kitty keyboard protocol.
* - .. _term-compat-cursor-position-report:
``\e[6n``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
- n/a
- Request 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.
Multi-line autosuggestions Unlike other shells, fish tries to make it easy to work with multiline commands. Arguably, it's often better to use a full text editor but the shell can feel more convenient. Spreading long commands into multiple lines can improve readability, especially when there is some semantic grouping (loops, pipelines, command substitutions, quoted parts). Note that in Unix shell, every quoted string can span multiple lines, like Python's triple quotes, so the barrier to writing a multiline command is quite low. However these commands are not autosuggested. From https://github.com/fish-shell/fish-shell/commit/1c4e5cadf23d38350fd281bac85a6908c2414ce2#commitcomment-150853293 > the reason we don't offer multi-line autosuggestion is that they > can cause the command line to "jump" to make room for the second > and third lines, if you're at the bottom of your terminal. This jumping (as done by nushell for example) might be surprising, especially since there is no limit on the height of a command. Let's maybe avoid this jumping by rendering only however many lines from the autosuggestion can fit on the screen without scrolling. The truncation is hinted at by a single ellipsis ("…") after the last suggested character, just like when a single-line autosuggestion is truncated. (We might want to use something else in future.) To implement this, query for the cursor position after every command, so we know the y-position of the shell prompt within the terminal window (whose height we already know). Also, after we register a terminal window resize, query for the cursor position before doing anything else (until we od #12004, only height changes are relevant), to prevent this scenario: 1. move prompt to bottom of terminal 2. reduce terminal height 3. increase terminal height 4. type a command that triggers a multi-line autosuggestion 5. observe that it would fail to truncate properly As a refresher: when we fail to receive a query response, we always wait for 2 seconds, except if the initial query had also failed, see b907bc775ab (Use a low TTY query timeout only if first query failed, 2025-09-25). If the terminal does not support cursor position report (which is unlikely), show at most 1 line worth of autosuggestion. Note that either way, we don't skip multiline commands anymore. This might make the behavior worse on such terminals, which are probably not important enough. Alternatively, we could use no limit for such terminals, that's probably the better fallback behavior. The only reason I didn't do that yet is to stay a little bit closer to historical behavior. Storing the prompt's position simplifies scrollback-push and the mouse click handler, which no longer need to query. Move some associated code to the screen module. Technically we don't need to query for cursor position if the previous command was empty. But for now we do, trading a potential optimization for andother simplification. Disable this feature in pexpect tests for now, since those are still missing some terminal emulation features.
2025-05-18 06:57:44 +02:00
This is used for truncating multiline autosuggestions at the screen's bottom edge,
by the :ref:`scrollback-push <special-input-functions-scrollback-push>` special input function,
and inside terminals that implement the OSC 133 :ref:`click_events <term-compat-osc-133>` feature.
* - ``\e[ \x20 q``
- Se
- Reset cursor style to the terminal's default. This is not used as of today but may be
in future.
* - ``\e[ Ps \x20 q``
- Ss
- Set cursor style (DECSCUSR); Ps is 2, 4 or 6 for block, underscore or line shape.
* - .. _term-compat-xtversion:
``\e[ Ps q``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
- n/a
- Request terminal name and version (XTVERSION).
This is only used for temporary workarounds for incompatible terminals.
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
* - ``\e[?25h``
- cvvis
- Enable cursor visibility (DECTCEM).
* - ``\e[?1004h``
2025-04-27 08:13:40 +02:00
- n/a
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
- Enable focus reporting.
* - ``\e[?1004l``
- n/a
- Disable focus reporting.
* - ``\e[?1049h``
- n/a
- Enable alternate screen buffer.
* - ``\e[?1049l``
- n/a
- Disable alternate screen buffer.
* - ``\e[?2004h``
-
- Enable bracketed paste.
* - ``\e[?2004l``
-
- Disable bracketed paste.
Use globals for color variables, react to light/dark mode Implicitly-universal variables have some downsides: - It's surprising that "set fish_color_normal ..." and "set fish_key_bindings fish_vi_key_bindings" propagate to other shells and persist, especially since all other variables (and other shells) would use the global scope. - they don't play well with tracking configuration in Git. - we don't know how to roll out updates to the default theme (which is problematic since can look bad depending on terminal background color scheme). It's sort of possible to use only globals and unset universal variables (because fish only sets them at first startup), but that requires knowledge of fish internals; I don't think many people do that. So: - Set all color variables that are not already set as globals. - To enable this do the following, once, after upgrading: copy any existing universal color variables to globals, and: - if existing universal color variables exactly match the previous default theme, and pretend they didn't exist. - else migrate the universals to ~/.config/fish/conf.d/fish_frozen_theme.fish, which is a less surprising way of persisting this. - either way, delete all universals to do the right thing for most users. - Make sure that webconfig's "Set Theme" continues to: - instantly update all running shells - This is achieved by a new universal variable (but only for notifying shells, so this doesn't actually need to be persisted). In future, we could use any other IPC mechanism such as "kill -SIGUSR1" or if we go for a new feature, "varsave" or "set --broadcast", see https://github.com/fish-shell/fish-shell/issues/7317#issuecomment-701165897 https://github.com/fish-shell/fish-shell/pull/8455#discussion_r757837137. - persist the theme updates, completely overriding any previous theme. Use the same "fish_frozen_theme.fish" snippet as for migration (see above). It's not meant to be edited directly. If people want flexibility the should delete it. It could be a universal variable instead of a conf snippet file; but I figured that the separate file looks nicer (we can have better comments etc.) - Ask the terminal whether it's using dark or light mode, and use an optimized default. Add dark/light variants to themes, and the "unknown" variant for the default theme. Other themes don't need the "unknown" variant; webconfig already has a background color in context, and CLI can require the user to specify variant explicitly if terminal doesn't advertise colors. - Every variable that is set as part of fish's default behavior gets a "--label=default" tacked onto it. This is to allow our fish_terminal_color_theme event handler to know which variables it is allowed to update. It's also necessary until we revert 7e3fac561d6 (Query terminal only just before reading from it, 2025-09-25) because since commit, we need to wait until the first reader_push() to get query results. By this time, the user's config.fish may already have set variables. If the user sets variables via either webconfig, "fish_config theme {choose,save}", or directly via "set fish_color_...", they'd almost always remove this label. - For consistency, make default fish_key_bindings global (note that, for better or worse, fish_add_path still remains as one place that implicitly sets universal variables, but it's not something we inject by default) - Have "fish_config theme choose" and webconfig equivalents reset all color variables. This makes much more sense than keeping a hardcoded subset of "known colors"; and now that we don't really expect to be deleting universals this way, it's actually possible to make this change without much fear. Should have split this into two commits (the changelog entries are intertwined though). Closes #11580 Closes #11435 Closes #7317 Ref: https://github.com/fish-shell/fish-shell/issues/12096#issuecomment-3632065704
2025-11-25 12:52:39 +01:00
* - ``\e[?2031h``
-
- Enable unsolicited `color theme reporting <https://contour-terminal.org/vt-extensions/color-palette-update-notifications/>`_.
When enabled, the terminal should send ``\e[?997;1n`` or ``\e[?997;2n`` whenever its color theme has changed.
This prompts fish to query for :ref:`background color <term-compat-query-background-color>`.
* - ``\e[?2031l``
-
- Disable unsolicited color theme reporting.
* - .. _term-compat-osc-0:
``\e]0; Pt \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
- ts
- Set terminal window title (OSC 0). Used in :doc:`fish_title <cmds/fish_title>`.
* - ``\e]1; Pt \e\\``
- ts
- Set terminal tab title (OSC 1). Used in :doc:`fish_tab_title <cmds/fish_tab_title>`.
* - ``\e]7;file:// Pt / Pt \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Report 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``.
* - .. _term-compat-osc-8:
``\e]8;; Pt \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Create a `hyperlink (OSC 8) <https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>`_.
This is used in fish's man pages.
Use globals for color variables, react to light/dark mode Implicitly-universal variables have some downsides: - It's surprising that "set fish_color_normal ..." and "set fish_key_bindings fish_vi_key_bindings" propagate to other shells and persist, especially since all other variables (and other shells) would use the global scope. - they don't play well with tracking configuration in Git. - we don't know how to roll out updates to the default theme (which is problematic since can look bad depending on terminal background color scheme). It's sort of possible to use only globals and unset universal variables (because fish only sets them at first startup), but that requires knowledge of fish internals; I don't think many people do that. So: - Set all color variables that are not already set as globals. - To enable this do the following, once, after upgrading: copy any existing universal color variables to globals, and: - if existing universal color variables exactly match the previous default theme, and pretend they didn't exist. - else migrate the universals to ~/.config/fish/conf.d/fish_frozen_theme.fish, which is a less surprising way of persisting this. - either way, delete all universals to do the right thing for most users. - Make sure that webconfig's "Set Theme" continues to: - instantly update all running shells - This is achieved by a new universal variable (but only for notifying shells, so this doesn't actually need to be persisted). In future, we could use any other IPC mechanism such as "kill -SIGUSR1" or if we go for a new feature, "varsave" or "set --broadcast", see https://github.com/fish-shell/fish-shell/issues/7317#issuecomment-701165897 https://github.com/fish-shell/fish-shell/pull/8455#discussion_r757837137. - persist the theme updates, completely overriding any previous theme. Use the same "fish_frozen_theme.fish" snippet as for migration (see above). It's not meant to be edited directly. If people want flexibility the should delete it. It could be a universal variable instead of a conf snippet file; but I figured that the separate file looks nicer (we can have better comments etc.) - Ask the terminal whether it's using dark or light mode, and use an optimized default. Add dark/light variants to themes, and the "unknown" variant for the default theme. Other themes don't need the "unknown" variant; webconfig already has a background color in context, and CLI can require the user to specify variant explicitly if terminal doesn't advertise colors. - Every variable that is set as part of fish's default behavior gets a "--label=default" tacked onto it. This is to allow our fish_terminal_color_theme event handler to know which variables it is allowed to update. It's also necessary until we revert 7e3fac561d6 (Query terminal only just before reading from it, 2025-09-25) because since commit, we need to wait until the first reader_push() to get query results. By this time, the user's config.fish may already have set variables. If the user sets variables via either webconfig, "fish_config theme {choose,save}", or directly via "set fish_color_...", they'd almost always remove this label. - For consistency, make default fish_key_bindings global (note that, for better or worse, fish_add_path still remains as one place that implicitly sets universal variables, but it's not something we inject by default) - Have "fish_config theme choose" and webconfig equivalents reset all color variables. This makes much more sense than keeping a hardcoded subset of "known colors"; and now that we don't really expect to be deleting universals this way, it's actually possible to make this change without much fear. Should have split this into two commits (the changelog entries are intertwined though). Closes #11580 Closes #11435 Closes #7317 Ref: https://github.com/fish-shell/fish-shell/issues/12096#issuecomment-3632065704
2025-11-25 12:52:39 +01:00
* - .. _term-compat-query-background-color:
``\e]11;?\e\\``
- n/a
- Query background color.
A valid response would be of the form ``\e]11;rgb: Pt / Pt / Pt \e\\`` or ``\e]11;rgba: Pt / Pt / Pt / Pt\e\\``
where the first three parameters consist of one to four hex digits each, representing red, blue and green components.
This is used to populate :envvar:`fish_terminal_color_theme`,
which is used to select a :ref:`theme variant <fish-config-theme-files>` optimized for the terminal's color theme.
* - .. _term-compat-osc-52:
``\e]52;c; Pt \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Copy to clipboard (OSC 52). Used by :doc:`fish_clipboard_copy <cmds/fish_clipboard_copy>`.
* - .. _term-compat-osc-133:
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
``\e]133;A; click_events=1\e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Mark 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 :ref:`cursor position reporting <term-compat-cursor-position-report>` is available.
* - ``\e]133;B\e\\``
-
- Mark prompt end (OSC 133).
* - ``\e]133;C; cmdline_url= Pt \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Mark command start (OSC 133), with kitty's ``cmdline_url`` extension whose parameter is the URL-encoded command line.
* - ``\e]133;D; Ps \e\\``
Stop reading terminfo database Our use of the terminfo database in /usr/share/terminfo/$TERM is both 1. a way for users to configure app behavior in their terminal (by setting TERM, copying around and modifying terminfo files) 2. a way for terminal emulator developers to advertise support for backwards-incompatible features that are not otherwise easily observable. To 1: this is not ideal (it's very easy to break things). There's not many things that realistically need configuration; let's use shell variables instead. To 2: in practice, feature-probing via terminfo is often wrong. There's not many backwards-incompatible features that need this; for the ones that do we can still use terminfo capabilities but query the terminal via XTGETTCAP directly, skipping the file (which may not exist on the same system as the terminal). --- Get rid of terminfo. If anyone finds a $TERM where we need different behavior, we can hardcode that into fish. * Allow to override this with `fish_features=no-ignore-terminfo fish` Not sure if we should document this, since it's supposed to be removed soon, and if someone needs this (which we don't expect), we'd like to know. * This is supported on a best-effort basis; it doesn't match the previous behavior exactly. For simplicity of implementation, it will not change the fact that we now: * use parm_left_cursor (CSI Ps D) instead of cursor_left (CSI D) if terminfo claims the former is supported * no longer support eat_newline_glitch, which seems no longer present on today's ConEmu and ConHost * Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580 * add `man fish-terminal-compatibility` to state our assumptions. This could help terminal emulator developers. * assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP * Extract all control sequences to src/terminal_command.rs. * Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really needed. * assume it's generally okay to output 256 colors Things have improved since commit 3669805627 (Improve compatibility with 0-16 color terminals., 2016-07-21). Apparently almost every actively developed terminal supports it, including Terminal.app and GNU screen. * That is, we default `fish_term256` to true and keep it only as a way to opt out of the the full 256 palette (e.g. switching to the 16-color palette). * `TERM=xterm-16color` has the same opt-out effect. * `TERM` is generally ignored but add back basic compatiblity by turning off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably not set accidentally. * Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in tests. Unset it instead. * Note that our pexpect tests used a dumb terminal because: 1. it makes fish do a full redraw of the commandline everytime, making it easier to write assertions. 2. it disables all control sequences for colors, etc, which we usually don't want to test explicitly. I don't think TERM=dumb has any other use, so it would be better to print escape sequences unconditionally, and strip them in the test driver (leaving this for later, since it's a bit more involved). Closes #11344 Closes #11345
2025-03-20 22:02:38 +01:00
-
- Mark command end (OSC 133); Ps is the exit status.
* - .. _term-compat-xtgettcap:
``\eP+q Pt \e\\``
-
- Request terminfo capability (XTGETTCAP).
The parameter is the capability's hex-encoded terminfo code.
The response must be of the form
``\eP1+q Pt \e\\`` ("boolean") or ``\eP1+q Pt = Pt \e\\`` ("string").
In either variant, the first parameter must be the same as the request parameter.
fish queries the following string capabilities:
* :ref:`indn <term-compat-indn>`
The response's second parameter is ignored.
* ``query-os-name`` (for :ref:`status terminal-os <status-terminal-os>`)
Terminals running on Unix should respond with the hex encoding of ``$(uname -s)`` as second parameter.
.. _term-compat-dcs-gnu-screen:
DCS commands and GNU screen
---------------------------
2025-12-25 10:41:01 +01:00
DCS parsing is optional because fish temporarily 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 :envvar:`STY` environment variable.
If that doesn't work for some reason, you can add this to your ``~/.screenrc``:
.. code-block:: none
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
2025-11-09 16:12:22 +01:00
.. _term-compat-unicode-codepoints:
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 :ref:`translated strings <variables-locale>`.