Skip to content
v0.5.0

Escape sequences

Programs talk to the terminal through escape sequences. The ones that begin with ESC ] are OSC sequences: they set the title, send a notification, mark a link, reach the clipboard. This page lists the ones Cogno understands.

SequenceWhat it does
OSC 0, OSC 2Set the title of the tab. The title shows only while the command that set it runs.
OSC 4, OSC 104Set, query or reset one of the 256 palette colors.
OSC 10, 11, 12Set or query the foreground, background and cursor color.
OSC 110, 111, 112Reset the foreground, background and cursor color.
OSC 8Hyperlink: text that leads somewhere else.
OSC 9Send a notification.
OSC 9;4Show progress in the terminal’s header.
OSC 52Read or write the clipboard.
OSC 777;notifySend a notification with a title.
OSC 1337;FileShow an image (iTerm2’s protocol). Off by default.
SixelShow an image (DCS q, not an OSC sequence). Off by default.

Everything else is ignored.

A program can make any text a link, the way ls --hyperlink or gcc do:

Terminal window
printf '\e]8;;https://example.com\e\\This is a link\e]8;;\e\\\n'

These links behave like the URLs and paths Cogno finds in the output by itself: a click copies the target, Ctrl+click (Cmd+click on macOS) opens it. The text of such a link does not show where it leads, so hover it first: the tooltip shows the target.

Cogno opens http, https and mailto links. A file link opens like a path printed in the output. Links of any other kind can only be copied.

Terminal window
printf '\e]9;Build finished\a' # a message
printf '\e]777;notify;Build;3 warnings\a' # a message with a title
printf '\e]9;4;1;40\a' # progress: 40 %
printf '\e]9;4;0\a' # progress: done, hide it

Notifications from programs are off by default. Switch them on, and choose where they show up, in the notification settings:

notification.source.terminal.osc9.enabled = true

The progress states are 1 normal, 2 error, 3 indeterminate, 4 warning and 0 hidden. Hide the bar altogether with terminal.progress_bar.enabled = false.

Other numbered OSC 9 commands from ConEmu and Windows Terminal, such as 9;9 for the working directory, are ignored. They do not show up as notifications.

With OSC 52 a program can copy to your clipboard and read from it. This is how copying works in vim or tmux over SSH. But anything printed in the terminal can ask for your clipboard, even a file you cat.

So before a program may read your clipboard, Cogno asks you in a dialog:

clipboard.read = ask # ask (default), allow or deny
clipboard.write = allow # allow (default) or deny

These settings only affect programs, not your own copy and paste.

Programs can print images into the terminal: imgcat and others with iTerm2’s OSC 1337, img2sixel, chafa and many plotting tools with sixel. Cogno shows them when you switch it on:

terminal.images.enabled = true
terminal.images.storage_limit_mb = 32

Each terminal keeps up to storage_limit_mb megabytes of images. When that is full, the oldest images are replaced by a placeholder. Images are not restored with a session.