terminal escape sequences for fonts

bash, linux, shell, terminal

Solution

The standard for control sequences is pretty much the Xterm Control Sequences document ctlseqs.ms in the XTerm source code. (You can turn it into a PDF with the command `groff -ms -Tps ctlseqs.ms | ps2pdf - ctlseqs.pdf`, though the `-ms` option seems to be broken on Ubuntu 12.04).

XTerm already supports control sequences to change the font, but for the entire terminal at once. Open `xterm` and type into your shell—

echo -e "\033[?35h\033]50;#+1^G\033\\" # aka CSI ? 35 h OSC 50 ; #+1 BEL ST

the font for the entire terminal should change. This control sequence actually supports the names of True-Type fonts as well; see page 21.

If you'd like to change an existing terminal to support changing the font inline, you're welcome to choose pretty much any control sequences not already allocated in `ctrlseqs.ms` and use them. However, it's a good idea to choose new control sequences similar to the control sequences for functionality that already exists.

Your next step is to get the source code for an existing terminal and start digging. What terminal do you use right now? The source code for Konsole or gnome-terminal is probably going to be easier to work with than that for XTerm.

Problem

What I want to develop: Terminal which can use at least 2 fonts in the same time. One font I will use for shell input lines, another font for command output. For example: ``` user@host$ ls /home user user1 user2 user3 ``` Why: More readable terminal/shell How: Here I have problem. Probably shell needs to generate some new escape sequences. And terminal need to load different fonts and handle those sequences. Where to start? How to define new escaping sequence, where are standards? Future: Maybe somebody want to join me in this project?

Original source