# Change Log File (OSC 46)

> Tell xterm which file to log its session to, in a build that can log.

- **Sequence:** `OSC 46 ; Pt ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **xterm:** [Operating System Commands](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

xterm can copy everything it receives to a log file, and `OSC 46 ; Pt ST`
names that file. Logging is turned on with the private mode `CSI ? 46 h`
or from xterm's menu.

Both are compiled out of a default xterm: logging needs
`--enable-logging`
([`configure.in`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/configure.in#L811-L818)),
and without it `OSC 46` is not one of the numbers xterm acts on. Even a
build with logging does not let a program choose the file unless it was
also built with `ALLOWLOGFILECHANGES`, since that would let anything
written to the terminal overwrite any file its user can; otherwise it
rings the bell twice
([`do_osc`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L4300-L4318)).

libghostty-vt has no `OSC 46`, and ignores it as a default xterm does, so
the case passes.

## Validation

### OSC46-1: Ignored

Input, one step per line:

```text
A
\e]46;/tmp/session.log\a
B
```

Expected screen:

```text
|AB____|
cursor 1,3
reply none
bell 0
```

---

This is the Markdown version of <https://control-codes.page/osc/logfile/>. 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>.
