Terminal graphics
usql draws images in a terminal that can show them. \chart draws a chart, and usql shows its logo when an interactive session starts. usql draws images only in an interactive session at a terminal. The README of usql says how to draw them from a script.
A terminal draws images with a graphics protocol. A graphics protocol is a set of escape codes that carry an image to the terminal. usql knows three of them:
| Protocol | The name in usql |
|---|---|
| The Kitty graphics protocol | kitty |
| The iTerm image protocol | iterm |
| Sixel | sixel |
How usql finds out
Section titled “How usql finds out”When usql starts at a terminal, it asks the terminal which protocol it draws. It waits up to 250 ms for the answer. In tmux, it asks tmux about the terminal of the client. If the terminal does not answer, usql reads TERM, TERM_PROGRAM and the other environment variables that a terminal sets.
Keys that you type while usql waits go to the prompt. usql does not lose them.
Choose the protocol yourself
Section titled “Choose the protocol yourself”The USQL_TERM_GRAPHICS and TERM_GRAPHICS environment variables choose the protocol, and usql does not ask the terminal. Set one of them to kitty, iterm, sixel or none. none turns the images off. An empty value lets usql find out.
If usql draws nothing, or draws garbage, name the protocol of your terminal:
USQL_TERM_GRAPHICS=kitty usqlTo turn the images off:
USQL_TERM_GRAPHICS=none usqlIf both variables are set, USQL_TERM_GRAPHICS wins over TERM_GRAPHICS.
The term_graphics setting
Section titled “The term_graphics setting”The setting term_graphics holds the protocol of the session. \uset term_graphics shows it:
(not connected)=> \uset term_graphicsterm_graphics is kitty\uset term_graphics with a name changes the protocol for the session:
\uset term_graphics sixelusql uses no images when the setting holds a name that is not a protocol.
Terminals that draw images
Section titled “Terminals that draw images”These terminals work with usql:
| Terminal | Systems | Protocol |
|---|---|---|
| WezTerm | Windows, macOS, Linux and others | iterm |
| iTerm2 | macOS | iterm |
| kitty | Linux, macOS and BSD | kitty |
| foot | Linux and other Wayland systems | sixel |
Are We Sixel Yet? lists more terminals that draw Sixel images.
Your first chart shows how to draw a chart.