This looks like the DEC special graphics character set.
Reading the xterm control sequences docs, it sounds like the terminal uses those when receiving ESC
(
0
.
So you should be able to reproduce using
printf '\033(0'
or
printf '\033(0' > corrupt-my-terminal
cat corrupt-my-terminal
And get back using
printf '\033(B'
which according to the same page selects USASCII.
Other ways to restore the state include
tput sgr0 # resets all terminal attributes to their defaults
and
reset # reinitializes the terminal
You could tput sgr0
in your PROMPT_COMMAND
(bash), or precmd
(zsh) to ensure it always gets reset automatically.
Or you could just make sure to use less
, vim
, or anything other than cat
to view a file.
To make less
act like cat
and automatically quit if the file is under one page long, run less -FX
, or do export LESS=-FX
.
Or if you don't want to always use those less
options, make a new alias, e.g.
alias c='less -FX'
Square box is usually for characters which absent in your current font. Code inside is two-byte UTF-8 character code. Modern terminals are UTF8, so you may get this if you try to output some binary data to your terminal. Seems you did something really strange with your python and python outputted some garbage to the screen, which were interpreted as unknown characters and you got some utf-8 garbage. You can always get similar random garbage with 'cat /dev/urandom'.
Best Answer
This is part of the output of the
which in full looks like this screenshot from the Debian version:linuxlogo
command, specifically part of the output ofThe logos are constructed from templates that accompany the command. This is the one for the
gnu_linux
logo. There are 30 logos in the original package. Debian adds adebian_banner_2
logo.From reading these logo files, right there in the source trees, one can see how the several different forms of lettering in the various logos are constructed with ECMA-48 and ISO 8613-6 control sequences, and one can derive further logos of one's own.