Escape code 50 in xterm
Looking at the list of xterm escape codes reveals that (esc)]50;name(bel)
sets the xterm's font to the font name
, or to an entry in the font menu if the first character of name
is a #
.
The simplest way to reset it is to use the xterm's font menu (Ctrl + right mouse click) and select an entry other than Default
. Alternatively, you can find out which font the xterm uses on startup, and set that with the escape sequence.
In the font menu you'll also find an option Allow Font Ops
; if you uncheck that, you cannot any more change the font using escape sequences.
To answer the question of how to reset it:
The xterm escape code OSC 50 ... BEL
can be used to set the font (See the answer of @celtschk).
Besides setting it to a font name, it can also be set to an index in the font menu you get with Ctrl and right mouse button.
We can use this to reset to the default font by using the menu index 0:
echo -n "\e]50;#0\a
From XTerm Control Sequences - (2014/05/26):
OSC P s ; P t BEL Set Text Parameters.
P s = 5 0 → Set Font to P t. These controls may be disabled using the
allowFontOps resource. If P t begins with a "#", index in the font menu,
relative (if the next character is a plus or minus sign) or absolute. A
number is expected but not required after the sign (the default is the
current entry for relative, zero for absolute indexing).
The same rule (plus or minus sign, optional number) is used when querying
the font. The remainder of P t is ignored.
A font can be specified after a "#" index expression, by adding a space
and then the font specifier.
If the "TrueType Fonts" menu entry is set (the renderFont resource),
then this control sets/queries the faceName resource.
The comment about "reserved" is puzzling because OSC 50
has been documented in xterm's control sequences since 1991 for changing the font. Here's a link to the X11R5 version.
The typography in the webpage could be improved. Here's a quick polish to help you see the problem:
Ps =
5 0
-> Set Font to Pt.These controls may be disabled using the
allowFontOps
resource. If Pt begins with a "#", index in the font menu, relative (if the next character is a plus or minus sign) or absolute. A number is expected but not required after the sign (the default is the current entry for relative, zero for absolute indexing). The same rule (plus or minus sign, optional number) is used when querying the font. The remainder of Pt is ignored.A font can be specified after a "#" index expression, by adding a space and then the font specifier.
If the "TrueType Fonts" menu entry is set (the
renderFont
resource), then this control sets/queries thefaceName
resource.
Very likely the problem is in the last paragraph, i.e., you were using TrueType fonts and (not just any text) set the font's facename to a value that did not correspond to a font. Fontconfig has ... no useful error checking to speak of ... and will simply "recover" by using a default font, not bothering to tell an application that something went wrong. If you did that, you cannot reset via the menu the TrueType fontname (the obvious choices on the fonts menu only change sizes). Control sequences still work, however.
OSX Terminal complements this situation by having no useful documentation. But some of its features are copied from various places (or may be copied to other places). The profile-change feature appeared in KDE Konsole in 2008 as part of the changes for bug report #155801 (curiously citing a rather old copy of xterm's control sequences document which someone made into a webpage). Actually the 50
was in the code from 2007 (hardcoded). But the change in 2008 gave it a name and commented that it conflicted with xterm's OSC 50
.
Add support for setting background and foreground colors of a session's displays (2008)
Initial version of a command-line tool (konsoleprofile) to change profile options (2007)