# Bell (BEL)

> Ring the terminal's bell.

- **Sequence:** `BEL`
- **ECMA-48:** [§8.3.3 BEL – Bell, p. 33](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n46/mode/1up)
- **DEC STD 070:** [§5.7 Warning Bell, p. 5-114](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n368/mode/1up)
- **VT220:** [§4.2 Control Characters](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2)
- **VT510:** [4.2 Control Characters](https://vt100.net/docs/vt510-rm/chapter4.html#S4.2)

Ring the bell: get the attention of the person at the terminal. DEC STD 070
asks for a warning "bell", "or some similar audible indicator", whose volume
the user may be able to change or turn off. libghostty-vt only reports the
bell to its host, which decides what to do. Nothing on the screen changes,
and the cursor does not move.

BEL has a second job: it ends an operating system command, such as
[setting the window title](https://control-codes.page/osc/title/index.html.md), in place of the string terminator
`ESC \`. There it is part of the command, and does not ring.

A control character sent in the middle of a control sequence is carried
out as if it had come just before the sequence, and the sequence then
carries on; DEC STD 070 gives control characters precedence over every kind
of sequence
([§3.5.1.1, p. 3-18](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n122/mode/1up)).
It also warns that ANSI and ISO standards treat this as an error, so a
program should not rely on it.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | Yes | [§4.2 Control Characters](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | Yes | [Table 4–1](https://vt100.net/docs/vt510-rm/chapter4.html#T4-1) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | rings the bell, except where BEL ends an OSC |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes | reports the bell to its host |
| pyte | 0.8.2, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/pyte.json) | Yes | passes the 4 cases that show it working |
| xterm.js headless | 6.0.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/xtermjs.json) | Yes | passes the 4 cases that show it working |
| alacritty_terminal | 0.26.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/alacritty.json) | Yes | passes the 4 cases that show it working |
| rxvt-unicode | 9.31, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/urxvt.json) | Yes | passes the 4 cases that show it working |
| VTE | 0.84.1, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/vte.json) | Partly | fails BEL-2 of the 4 cases that show it working |

## Validation

### BEL-1: Rings, and moves nothing

Input, one step per line:

```text
AB
\a
C
```

Expected screen:

```text
|ABC__|
cursor 1,4
bell 1
```

### BEL-2: Once for each

Input, one step per line:

```text
\a\a\a
```

Expected screen:

```text
|_____|
bell 3
```

### BEL-3: Ending a command does not ring

Input, one step per line:

```text
\e]2;hello\a
```

Expected screen:

```text
|_____|
title "hello"
bell 0
```

### BEL-4: In the middle of a control sequence

Input, one step per line:

```text
\e[2\a;3H # BEL inside CUP
```

Expected screen:

```text
|_____|
|_____|
cursor 2,3
bell 1
```

---

This is the Markdown version of <https://control-codes.page/c0/bel/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
