aha converts ANSI shell output to HTML
05 February 2025
aha converts ANSI escape sequeneces, like those used for coloured shell output, into HTML.
I tried:
brew install aha
echo -e "\033[34mHello\033[0m" | aha
and got the output
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. https://github.com/theZiz/aha -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8"/>
<title>stdin</title>
</head>
<body>
<pre>
<span style="color:blue;">Hello</span>
</pre>
</body>
</html>
which is indeed the world Hello in blue.
If I want to include the HTML output in another page, such as this blog post, the —no-header
option gives you just the body contents:
echo -e "\033[34mHello\033[0m" | aha -n
Hello
Great tip from Jujutsu VCS Introduction and Patterns | Kuba Martin by Kuba Martin.