33

ANSI art and animations were prevalent on BBS systems in the late 80s and early 90s, and the ANSI art scene continues to thrive today. There are thousands of ANSI art files, with usual extension .ans, available on the Internet, many from those retro BBS's, and many recent artists' works too.

Screenshot ANSII art

I would like to easily recreate the experience of viewing ANSI art online by viewing .ans files natively, just using a terminal window and command-line tool to display the text. Based on my limited understanding of ANSI art, I think several retro-computing environmental conditions would need to be emulated within the terminal session. Off the top of my head:

  1. Recreate the ANSI code page definitions, including all the escape codes that were commonly used in ANSI art. In the old days, I think the MS-DOS "ANSI.SYS" device driver provided this.
  2. Choose a suitable font that displays all the ANSI text characters in a manner true to the original online experience.
  3. Ditto for the color palette utilized on old EGA and VGA displays. I think both 16-color and 256-color palettes were common.
  4. Simulate appropriate output speed of characters to the terminal, allowing files to be viewed as if they were received over a modem connection at, for example, a speed of 9600 baud.

To summarize, if there was an ideal solution, it would work as simply as this:

ansi-cat http://ansiart.mydomain.net/some_ansi_art.ans --baud=9600

And the tool would fetch and display the .ans file in the terminal window using a simulated 9600 bps. Of course, a cross-platform tool is best, but I suppose there are valid reasons this might be more easily accomplished on some modern platforms than others.

Naturally, I will be thrilled with any answer that can come close to this simple experience. I would rather not have to rely on emulation software and old DOS programs to display the art.

5 Answers 5

32

There are various ANSI art viewers for modern platforms which satisfy all your feature requirements (command-line syntax excepted), for example:

Inside a terminal, at least on Linux/Unix and presumably macOS, viewing ASCII/ANSI art boils down to setting the font and colours, and slowing the display down — terminals support the required escape codes. One setup that works quite nicely is to use the Ultimate Oldschool PC Font Pack, and run xterm with the appropriate options: ansiterm provides a good base, you'll just want to change the font name (e.g. -fa "Px437 IBM VGA9" instead of -fn dos437), and change the geometry to 80×25 for some DOS files. Inside the terminal, use slowcat to slow the output:

./slowcat -d 1000000 bambi.vt

for bambi.vt for example.

You can also use less inside that terminal to view files of static images:

LESSCHARSET=dos less -R CL\!-1999.ANS

LESSCHARSET=dos reduces the character set that less considers as control codes — without that, it would display non-ASCII characters as their hexadecimal value, e.g. <DC>.

3
  • 1
    One thing none of the answers seem to have mentioned is that some commands were processed slightly differently by different terminals; some "ANSI art" files are written so as to be processed uniformly (e.g. selecting a black background before doing a clear-to-end-of-line will yield the same behavior on terminals that set the background on the cleared characters to black as with those that set it to the current background color) but some will only look good on emulators that behave a particular way. I've not seen any good summary of emulator behavioral differences, though.
    – supercat
    Jun 14, 2018 at 15:50
  • You forgot to explain that LESSCHARSET doesn’t make less(1) to encode characters into a form compatible with its (pseudo)terminal environment – that is, the example would work in a DOS codepage (such as CP437) terminal, but not in a UTF-8 terminal (unless the “ANSI art” uses graphic characters exclusively from ASCII). LESSCHARSET helps to distinguish graphic characters from controls and garbage, not provides decoding–encoding across character sets. Mar 27, 2021 at 5:39
  • @IncnisMrsi I never claimed that LESSCHARSET provides character set conversion; I wrote that command in the context of the terminal set up with ansiterm, using a CP437 font. But thanks for the explanation, it might avoid some confusion! Mar 27, 2021 at 10:02
14

This is a late answer to an old question, but there's a better way:

iconv -f 437 file-here.ans | pv --quiet --rate-limit 7000

and if viewing an online file:

curl www.ansi-art.com/ansi/ansi1.ans | iconv -f 437 | pv --quiet --rate-limit 7000

long as your terminal is set to the width of the art (usually 80) should have no issues. Can easily turn it into a .sh script: https://raw.githubusercontent.com/m00-git/ANSI-view/master/ansi-view.sh

1
  • 1
    That's a dead link Dec 2, 2021 at 17:38
12

I got bored over the weekend and created Ansi-Cat for a Windows command prompt.

https://github.com/peteri/Ansi-Cat

Does code page 437 -> Unicode conversion, tested it on Windows 8.1 & 10 but you will need the .net framework version 4.5.2 to run it. It's a bit rough (error handling just prints the exception) but works for 16 color .ans files I've tried from archive.org but doesn't deal with blink commands.

If you give it a go and run into problems add them to the GitHub issues pages.

5
  • Also see github.com/adoxa/ansicon
    – Leo B.
    Mar 14, 2017 at 0:06
  • Nice find @LeoB. Much more useful if you need Ansi for real work.
    – PeterI
    Mar 14, 2017 at 9:05
  • Excellent! This compliments Stephen's answer above nicely by adding Windows support for a console-based method.
    – Brian H
    Mar 14, 2017 at 17:00
  • Thanks I can recommend writing a ansi parser as a coding kata, I still need to finish off by adding a few more tests but it seems a shame to let it languish on my hard disk.
    – PeterI
    Mar 14, 2017 at 18:38
  • @PeterI I've converted my comment to an answer for easier reference.
    – Leo B.
    Mar 14, 2017 at 18:39
3

The ANSICON tool "provides ANSI escape sequences for Windows console programs. It provides much the same functionality as ANSI.SYS does for MS-DOS".

It can start an ANSI-capable instance of the command processor, or display standard input if redirected, or execute a specified program in an ANSI-capable window.

3

Another late answer. This slowcat implementation has specific options for ANSI viewing:

https://github.com/Eli-the-Bearded/vt100-slowcat

The program is tiny, in C. The repo is huge because it also includes a library of videos.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .