Thursday·26·March·2020
Pictures in pure HTML with chafa and aha //at 05:55 //by abe
I recently stumbled upon chafa, a tool to display pictures, especially color pictures on your ANSI text terminal, e.g. inside an xterm.
And I occasionally use aha, the Ansi HTML Adapter to convert a colorful terminal content into HTML to show off terminal screenshots without the requirement of a picture — so that it also works in e.g. text browsers or for blinds.
Combining chafa and aha: Examples
A moment ago I had the thought what would happen if I feed the output
of chafa
into aha
and expected nothing
really usable. But I was surprised by the quality of the outcome.

looks like this after chafa -w 9 -c full -s 160x50 DSCN4692.jpg
| aha -n
:
▆▅▆▃▆▃⎽⎺▄▆▄▂▅▄━▄━▂⎽▆▘▂▍▝■▌▆▘▚▄▂▄╸▂╲▌▄▚▅▶▄⎺▅▄▃▃▮▗▆▃▅▂▅━▃▆▃▃▂▌▆▮┛┷▅⎽⎻┛▚▅⎺▅●▚▋▋▘▃⎽⎺╱■▄▚▊▄▎⎺▄▗▂▄▂▅▆▃▅■▃▅▂▆▄▂⎽▍▄▃▅╲▅▄▖╱╸▖▘▂▼●▋▅⎽▚▃⎽⎺▅▂▅▃▅▆ ┻⎺⎽╸⎺▅▃▅▂▆▆▃▅▃▂▅▃▃⎺■⎺▃⎽▅▝▂━▚▃●▄▅▶▆▖╸⎺▋━▆▆┍▂●╱▅━▄▆▍⎺▅▃▄▂▄▅▃▅▃▂▂⎺▮▗╸▃⎻━╸▂▶▝▂▝▖▖▝▗▘▆▂▘▄▅▘▗▆▃╸▆▃▍▂▝▅⎺▆▃▄■▃▅▂▆▄▂▝▖▄▅▆▂▅▝▖▄▃▖▃▆▚●▃⎽▖▝▗▃⎺▃⎺▄ ⎺▄▃━▂▗▖⎺▅▂▄▂▄▅▂▄▃▆▅▖▚▗▃╸⎺▖⎺▗▝▂▂▅▃▄▖▆╺▄╲╾▃▚▃▝╸▂▲▂▄■▂▘▊▆▅▆▄■▃▅▂▅▂▃▃▄■▚▅▮▃▃▅●▅⎺▍▆⎺━▃▖╺▖⎺━┓▲▘┛▗▅▌▎╲▌╱▝▄▚▅▆▄▆▃▄▂▅▃▂▝▖⎺▅▝▅▄▂▃▖▆▃▖◼▃▚╾▘⎼▗▃▂⎽ ▃▃▂╺▘╼▝▂▃▂▆▄▆▃⎽▄▄▆▃▂▂╾▆▘▃▄▄▄╾▍▲▃▄▃▂╺▖▃▃▋▄▃◀▅▘▂▅━▘▅●▖╾▃▆⎺▆▄▆▃▆━▄■▄▃⎽▃┚⎼▆▄▚▂╴▖▅▂▗▶▃┙▘▅▂⎼▃▄▅╱▝▄▌┺╍▖▅●▄┙▍▅⎺▅▆▃▅▂▄▂▆▄▃▂▶▂⎽▃▅▄▂▝╸▖▅▌▖┛▅▖▆▃▄ ▝⎽▝▃▶▅╱⎼▃▄▂╱▅▅▂▅▂▆▆▃▅▃▖▌▄▄▂●╸╴▝▗▄━▖▖⎼▆┖▗▃┗▄▲┖╾⎺▆·▃╲▂▂╲▅▃▚▅⎺▆▄▅▃▅╾▃▆▃▃▃▄▖▃▄▃▂╸╴━▚▄■▅▆⎼┒▅⎼▆▃⎽▖╸▖╸▋▃▝▃▝▂▃▄▄▂▆▄▆▃▅▂▄▂▅▃⎽▆▂▅▆▝▗▃▂╺╼▄▖┍▍▊▌▝ ▄╺▘▲▆━▘┒▗▍▝▮▅▚▖▆▅■▄▂▄▅▂▄▂▃▃┗▂⎽▄▝▆╺▅▅▋╺▃▃▆▖╲▝▂▂▄▃▄⎺▂⎺▂╸▚▂▚▝▄▗▅⎺▅▂▄▂▄▅▂▅▂▃⎽▗▘▋╺▝▄·▄╱╸╸▍▂▃▄┰▂▎▃▂▚▅┎┎╸▂▋▅▘⎼▅◼▃▝▚▆▃▅▂▅▂▄▂▅▃▂▅▄▆▄▅▖▃▌■▄▖▝╲▅ ╸▃╱▗▄⎺╺▅▗▖▄▌━▖╾▚▂▆▆▄▆▄▚▘▄■▃▖▝▃▆▗▄▘▝▅━▖▗╺▃⎽⎼▖┭▃▄▅■▃▚▝┱╺▆■▖▂╲▅▖▊▆▃⎺▅▆▄■▃▄▂▅▃▂▝▚▖╱▄╴┛▊▄▄▂▃▂▗▖▆╾▝━▂╱━·┓┺┑⎽▌▄▃▘⎺▆▂▝⎺▆⎺▄▂▅▂▃▂▅▃▅■▂▅▖▖━▄▂┗▝■ ▋▂╼╹▅╼┏▃▃⎻▃▗▆⎼▅▚▃╸▖╸▝▅▃▅▂▆▆▃▅▃⎽▄╸▅▘┙▘▘▘▄▖▄▝▅▄╺▖▆▆▃▅▂⎽▲▘▅━▆▅▝▖▃▝╺╸▖▃▆▄▆▃▆▃▄━▄▃▖⎻╾▄▃▅▃▄▄▄▆▅▅▃━·▅▘╸▆⎼▂╴▆▆■▝┑▋▄▅▼╸▅▅▃⎺▅▆▄●▄╾▃⎽▅▖╾▝▂▃▅┗▄▝▅ ▝▅◼▂▆━▝▎▎╸▖▖▖▄▃⎽▝▃▝▖▆▂▂⎺▄●▄▂▅▅▂▄▂⎽▖▄▗▃▃⎽▅■▖▖▅⎺▃▚▘┒▂▂■▃▚╺▌▄▃▅▂■▃▂▖▆■▄▃⎺▆▃▅▃▅■▃▆▃▂▂▅┓▄⎻▍⎽─▄▖┎━▆▆▆▅▆▂▼┳▆▚▆▆▃╸▗◆┳▃▂▊▅▚◀▆⎺▅▆▘⎽▆▄▂▆▄▂▄▄▘▄◀▃ ▃▌▝╸▅▆▄▖⎻▗┳·▆▚▆▃▅▖▗▝▂▝▂▅⎻⎺▆▄▆▃▚▄▄■▄▂▂▆▖▂▅▅▆╸⎺▍▃■━▅▗▖▄▃▃╾▖▄▂▗▘▘⎺▅▃▄▝╺▅▃▲▌▝▆⎺▄▂▄▅▃▅▃▂▚▘▃▆▃▂▖▚⎼▃▃◼▘╼╺▂⎻▚▄┗▅▆▄▅▄▅▗┍▃▃╸▃▃▗▅▄▆▄▄▃⎺▆▄▂▅▃▂▆▃▃ ▝▍▌╱┗▗▅▃▗▃▄▼▆▖▘▂▆▆▘▂▘▝⎻▆▃▆▅▄▝▆▃▅▃▆▃▄▆▃▖▖▅▄▂▃▍▍▂▖╺▂▄▆■▅▗▂▆▅▝▚▃━▅▚▅▝▅▂⎽╲▃▃▃▅▖⎺▅▆▄■▃▅▂▅▂▖▝▆▆┗┒⎺▃▄⎽▗▝▘▂▝▅▅▃▅⎺⎼▄▄▄▂▝╸◀▆▅▖━▃┓▆▂▂▆▄▄▂⎺▆▄▂▃▃⎽ ▂╾▃·▅▚▖▖▅▝▂▂▌▆╾▝▄▃▄■▍▘▖▅▝▂⎽▆▆▆⎺⎺▅●▄▂▆▅▃▅▃▖▚■▃▃▄⎽⎽▅▃▖▖▗▄▚▃▗▆▅▃▂▆▄▋▂▄▂▂▅▃▄▃▆▅▄▌▃▆▄▅▃▆▃▄▆▄▂▄⎺▂⎺▃╾▲■▆⎺▅▂▂⎺▃▂⎽▃▃▆▆▆▝▖╺▎▂▃⎺▍╸●▆▆▆▅▚▆▄▄▃⎺▅▃▂ ▼▚▂▖╸▆╲▄⎺▌▆▂▖▃⎽▄◼▗╺▃▅▊▃▃▘▝▗╸▂▚▗▃▮⎺⎺▄▆▃⎽▅▄▂▅▃▗⎽▆▃⎽▆▅▂╹▊┗▆▅▄⎽●▅▄▃━▚▅▆▅▄▗▍⎽▄▃▃⎺▆▅▄▃▝▅⎺▅▂▅▂▃▆▄▂▄▆━▗▂▄▂▂▅⎺▂▘▃▄▃▄▄▅▅▆▆▆▅▝▘▍▂▄▃▃▃▗▂▝▄▅⎺▅▄▄▂⎺ ▄▂▖▄━╾◀▅▂▝▋╺▝▘▃⎽▃●⎻⎺▅▆▃▅▄▆▖╏▅▗▂▌┺▆▄▃⎺▆▃▅▂▆▃▂⎺▄▂▄▆▅▃▂▅▃◀▝▆▅⎽▂▅▆┳▃▅▄▃▄▄▃⎽▗▄▂▄▄▄▃▘╺▆▄▃━▅⎺▄▂▄▂▂▆▃▂▗▂▄▆▄▝⎽▝▅⎺▃▘▘▄▅╲╺▂⎽▆▌▃▄▅▄▆▃▂⎽▂▅▅━▅▃▃⎺▅▄ ▅▃▅▃⎽▍▆▝▝▘▘▖╺▖▖▄▆⎽▗▅▄▶▂▃▅▅▄▂▄▂▃▃▆▂▂▃▄▃▂⎺▅⎺▄▂▆▃▂▆▃▖⎺▃▅▅▃▂▂▃▌▃▃▄▅▂╍▗▅▆▄▂▅▅▃▃▆▃▃▆━▃▄▃⎽⎺▅▅⎺▅▆▃■▄⎽▂▂▝▖▘▃▅▄▂▅▅▆▄▅▄▅▆▄▆▄▄▘▅▅▄▃▅▄▄▂▄▂▃▂▆▆▆▅▃▃ ▃⎽▆▄▂▅▂⎽⎽▄▘▅▖▄▄▄⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽■⎽⎽▅⎽⎽⎽▂⎽▂▂⎽⎽⎽⎽⎽⎽▗▄▄▄⎽⎽⎽⎽⎽▂⎽▗▂▂⎽⎽⎽⎽⎽▂⎽▂▂▂▂▂▂▂⎽⎺▅▃▂▂▂▂▂▂▂▂▃▂▂▂▂▂▂▂▂▂▃▂▂▂▂▂▂▂▂▃▄▄▃▄▃▂▂▃▂▅▅▂ ▅▂▅▂▘▆▄⎺▆▆▆▆▆▖▆▌▍⎺⎺⎽⎺⎺▝▆▌▊▍⎽⎺⎺⎺⎺▅▋▍▎⎺⎽⎽⎽⎺▝▆▌▋▍▂▂▂⎺⎺▖▋▊▏▼▗▂▂⎺▌▋▝▌▍▊▂⎺▂⎺▎▌▉▎▘▗▂▗⎺▝▍▝▋▌▄▉▂▗▅▌▉▘▌▎▅▂▂⎽▆▍▝▊▎▏▗▃▃⎽▝▎▍▋▋▗▃▃▃▃▋▍▃▃▃▃▃▃▃▂▅▃▃▂▄ ▂▄▆▄■▄⎽▏╺▖▄▄▖▌▋▌▍▝▍⎺▌▏▋▌▌▋▎┗▘╲╱▉▎▋▍▎▅▌─╴▝▋▋▌▌▎▉▍┮▘▉▍▌▊▋▋▋▍⎺▖▋▋▎▍▎▝▝▗▆▊▍▌▊▎▌▋▎▌▎▉▎▋▋▍▊▉▋▌▍▌▎▊▍▎▋▍▋▍▉▍╿▊┃▏▊━▃▘▊▎▎▋▋▘┻━╸▗▋▎▄▆▅▆▄▂▆▆⎺▄▂▆▅ ▂■▆▃▆▅▃▏▂⎺⎺⎺▃▌▋▌▍▃⎺▅▅▆▋▌▌▋▎▝▘▝▘▉▎▋▍▎▂▝▅▅▂▋▋▌▌▎▅▘▝▘▗▎▋▋▋▂▎▆▂▃▌▋▎▍▎▂▝▆▃▊▎▌▊▎▂▘▆▆▄▊▍▋▋▍▂▉▆▅▃▌▎▊▌▎▂▆▆▆▂▍▖▋▎▂▝▆▝▅▊▎▍▌▋▆▆▆▆▆▋▎╸╲◀⎽▌▆▖▃⎽▆▖▋╾ ▖▆▃▘╺▅▊▎▆▆▂▃▂▝▌▋▍▃▃▂▂▂▘▌▋▋▃▂▂▂▂▂▌▋▉▏▂▂▂▂▂▘▌▌▍▃▃▂▂▂▂▌▋▋▃▃▃▂▂▂▌▋▉▝▃▃▃▂▃▂▌▌▋▃▃▃▃▃▃▂▌▊▝▃▃▃▃▃▃▌▎▋▃▃▃▃▃▃▃▍▉▝▄▄▄▃▃▃▃▍▊▝▄▃▃▃▃▃▘▍⎽▄▗▆⎺▅┙▆⎽▃▊▗▌ ▃▘▝╴▅▖▆▝▄▖▍▅▂▂▂▅┷▃▋▃▃▃▃▃▂▄▄▆▃▃▃▃▃▃▄▄▆▗▃▃▃▃▃▃▄▖▋▃▃▃▃▂▂▄▄▆▄▃▃▃▃▂▃⎻▗▗▃▃▃▃▂▂▄▗▂▗▃▃▃▃▂▂▂⎺▗▄▃▃▃▃▃▂⎻■▗▄▃▃▃▃▃▂⎻━▗▄▃▃▃▃▃▖■╺▄▃▃▃▃▃▃▖▖▆▂▅▃▌▂▆▖▝▆ ▮⎻╺▶▆▄▅▼▉▎▄⎽▖▝▖▋▌▌▋▎▍▗▖▖▊▎▌▉▋▖▗▃▖▄▌▋▌▍▏▗▃▃▖▊▎▌▋▍▌▗▄▘▌▌▋▎▎▏▊▄▄▚▉▎▍▋▌▌╻▍▃▖▋▍▊▋▎▌▌▉▖▌▌▎▊┃▅▗▂▃▖▊▎▅▋▋▝▗▏▌▋▊▎▊▌▍▌▉▋▎▍▋▎▊▍▎▝▌◆▎▖▌▎▝▂╸●▘▄▝▃▃▃ ▂·▄▄▝▲▖▅▊▎▊▍▂▼▍▋▋▌▌▏▗╱┶▖▊▎▌▉▌▍▍⎻▖▝▌▋▌▍▏▊▍▂▍▊▎▌▋▍▋▎⎻▖▃▌▋▉▎▏▊▂▍▎▉▎▍▋▍▊┃⎻┃▍▋▌▋▌▎▝▗▂▌▃▌▍▊┃▍▌▄▄▖▊▎╽▋▌▖▌▂▂⎽▊▎▊▌▍▖▉▖▋▍▋▎▊▍▎▋▗⎽▌▋▋▎▝▮▄▖▅▝━⎽▝▂ ▆▃▝▆▄▂▅▘▊▎▂⎽⎽⎽▝▌▋▌▌▃▂⎽▂⎺▊▎▋▊▝▂▂⎺▘▗▍▋▌▎▂⎽⎺⎺▍▊▎▌▋▝⎽⎽▍▝▃▍▋▉▎▂⎽⎺⎺▋▗▎▍▌▝⎽⎺⎽⎺⎽▋▌▊▌▖▂⎽⎺▆▃▌▎▊┠▃⎺▂⎺⎺▗▎◼▋▝▃⎺⎺⎺⎽▋▍▊▌▍▃▉▘▘⎽▌▍▋▍▍▂▝▘▌⎽▌▎▖·▍▚▄▃▌▘▃▅ ■▄◆╾▃⎽▅▅▊▎▂▃▃▄▄▃▌▌▍▄▃▃▃▃▃▂▋▊▃▃▃▃▃▃▃⎽▌▎▃▃▃▃▃▃▂▋▌▄▃▃▃▃▃▂▌▊▃▃▃▃▃▃▃▂▌▝▄▃▃▃▃▃▃▍▋▃▄▃▃▃▃▄▘▎▝▄▄▄▃▃▄▄▘▂▝▅▄▄▄▄▄▄▎▋▄▄▄▄▄▃▄▘▂▝▄▅▄▄▄▄▄▘▍▂▂▃▄▃▄▂▋▅⎽ ┕⎽▃━▆▅▝▖▝⎺⎺▖▆▆▆━━▆▆▆▊▆▅▄▄▄▃▆▆▆▗▆▅▅▄▄▆▆▆▋▅▅▅▄▄▃▆▆▄▆▅▄▄▄▃▃▆▌▌▅▄▄▄▄▃▖▗▅▗▄▄▄▄▃▃▆▆▖▅▄▄▄▄▃▖▆▅▗▄▄▄▄▄▃▖▆▄▗▄▄▄▄▄▃▖▆▖▅▄▄▄▄▄▃▖▅▖▄▄▄▄▄▄▃▖▂▗▄▘▋⎻▄▃ ▃▅▄▄▂▂▝▖▖▗▊▍⎽⎽⎽⎽⎽▋▋▌▋▎╺━▅╸▊▎▋▍▎▅╺▂▖╾▋▋▌▋▍▖▄━▖▆▍▋▉▎▄▗▖▗╸▊▋▍▋▍▅┏─▖▅▌▌▊▍▆▗▖▗▖▉▎▗▊▋▉▖▂▗▖▊▎▉▌▍▖╺╺▏▅▌▎▉▌▎▝▌▂▘▆▍⎻▊▍▎▄▋▘▌▉▍▍▋▊▂⎽⎽⎽⎽▖▎▅▅▄▖▅▅╺╸ ▮▗⎽⎽▃▅▚▂▄▝▊▎▃▄▄▘▝▋▋▌▌▏▗╱┷▖▊▏▋▉▏▋▗▄┓▖▋▋▌▌▎▝╲▄▖▗▎▋▊▏■▝╲▘▝▊▋▍▋▎▋▏■▎▄▌▌▊▍▏▋▆▖▎▉▎▎▊▋▉▗┳▖▎▊▎▊▌▍▝▉▂▅▂▌▎▉▌▎▝▊▂▖▝▍▎▊▍▎▝▗╺▖▂▍▎▋▊▄▄▄▝▄▘▎▂▂▆▅▄▂▂▂ ▊▝▲▂▃┓▘┙▖▆▊▎▄▃▃▃▗▌▖▌▌▄▄▃⎼⎼▊⎽▋▉▝▄▃▃▃▂▍▌▌▌▝▄▃⎼▂▗▎▋▊▮▄▃▃⎽▂▋▋▍▍▝▄▃⎼⎽▗▍▍▊▍▖▃⎼⎽▂▗▍▎▋▲▄▃▃⎽▂▋▍▊▌▌▄▄▆▂▂▍▎▊▘▍▄⎼⎺▂▂▍▍▗▍▎▄▆⎽⎽▂▍▄▌┗▄▄⎼⎽⎽▗▎⎽▆▄▃⎽▆▅▄ ▋▍·▝▃▅╶╲▝▂▝▃▂⎽▃▃━━▃▃▘▆▅▅▅▅▅▄▃▊▅▄▄▄▄▄▄▃▘▝▄▄▄▄▄▅▄▃▝▄▄▄▄▄▄▄▘▃▅▅▅▄▄▄▅▄▍▘▅▅▅▅▅▅▅▂▂▝▅▅▅▅▅▅▅▂▘▅▅▅▅▅▅▅▅▃▝▆▆▅▅▅▅▅▘▃▝▆▅▅▅▅▅▅▂▃▅▆▆▅▅▅▅▅▘▂▂▆▘▅▄▂⎺ ▂▍▝▃━╺▅▄▝⎼▅▗▘▌▆▅▅▅▅▅▖▋▊▆▆▆▆▅▅▖▋▌▍▆▅▅▅▅▄▖▋▊▆▅▅▅▅▅▖▋▘▍▆▅▅▅▅▄▍▘▊▆▅▅▅▅▅▅▅▅▅▅▅▅▅▅▄▖⎺▆▗▆▅▅▅▅▄▖▝▋▆▅▅▅▅▄▄▖▆▋▆▅▅▅▅▅▄▖▆▌▆▅▅▅▅▅▖⎺▝▗▅▅▅▅▅▅▖▎⎻⎻▌▝▅ ▄▅▂⎽╺▆▄▃▂▅▝▝▄▍▗▖▖▄▃▊▎▌▊▍▄▃▃▖▆▍▋▍▍▃▃▃▃▃▉▎▌▊▍▊▃▖▗▘▌▋▎▍▂▃▂▂▃▃▎▍▊▊▖▋▍▆▃▃▃▃▂▃▃▂▖▌▌▌▍▉▍▗▃▂▂▃▖▍▌▊┃▝▂▂⎽⎽▉▎▋▋▋▅▋▗⎽▋▊▎▍▋▍▂▗▅▖▌▋▎▊▌▍▊⎽▂⎽▍▋▎━▝▖▗▄ ▃⎽▅▆▄▂▃╼▅▃▍▄▘▍▆▘▘⎺▆▊▎▌▊▍▖▘▆▘▂▍▋▍▎▅▅▅▅▅▊▎▌▋▍▝▆▅▆▍▌▋▗▍▄▅▆▅▅▅▎▍▊▊▋▌▅▃▃▃▄▄▄▆▄▃▝▝▄▌▎▖▍▝▅▅▅▅▘▍▗▊▊▌▆▅⎺⎺▉▎▖▋▋▂▝▖▘▎▊▎▎▋▍▍⎺▶⎺▖▋▗▊▌▍▆▆▅▆▆▋▎▍▗▅▃▃ ▄▂▅▂▅▃▅▃▂▘▆▄▊▎━━━▂▃▋▂▝▋▌▅━▃▃▅▂▂▗▎▅▅▂▂▃▋▂▌▌▍▅━▂▂▄▍▝▗▍╸▘▂▂▃▅▍▂▃●▅━▂▂▂▂▂▂▂▂⎽⎽⎽▂▃▍▊▖▝╸▂▂▂▂▗▎▗▗▲▄▂▂▂▂▗▎▖▌▶▅▄▂▂▂▊▊▎▘▘▅─▂▂▂▋▗▃▘▌▄▂⎽▂▂▘▍▂▄▅▅▂ ▆▅▄▄▆▄⎽▅■▄▂⎺▆▝▅▄▄▄▄▄▄▃▄▄▄▄▄▄▄▄▃▃▄▃▃▃▃▃▃▃━▃▃▃▃▃▃▃▄▃▃▄▃▃▂▄▃▃▃━▃▄▄▄▄▄▄▄▃▃▄▄▄▄▄▄▄▄▄▃▃▃▃▄▃▄▃▄▝▃▃▃▃▃▃▂▂▂▃▂▄▄▄▄▄▄▄▃▃▃▄▄▄▄▄▄▄▝▃▄▄▄▄▄▄▄▄▅▆▅▅▃▃ ▃▃▄⎺▆▄▃▅▃▆▃▅▂⎽▅▂▗▃▂╺▄▝▄▝▘▝┗╍▃╲▗▂▼▅▅▗▆▅▅▄▃▘▆▅▄▆▶▃▆▆▄▂▄▖▄▆▃▅▃⎽▂▅▆▆▆╸▗▆▃▗▖╲▄■▄▘╲··▌▄▆┍■▗▗▄▍▆▆▆▃▆⎻⎺▆▄▃▃▂⎺▅▃▆▄⎽▅▅▄▂▃⎽▂▝▖▍◼▖▅━▆⎺▅▄╾▄▂▂▝▗┯▃■ ▚▄▆▅▅▆▼▅▄⎺▅▃▅■▄▂▃▝▄▃▆▃▊▚▋▃▗▂▃▲▂▄▌▗▖▚▖▄▄╲▃▍▆▃▗▅⎽▚▆▄▅▆▆▄▆▃▂▆▄▂▅▂⎽▚▖▘▅▂━▋■▃▘⎺▘▃╸▂▗▶▄▘⎺╺▝┱▆▅┍▅┗▚┻▅━⎺▝⎺▆▄▃▃▂⎺▅▂▅▃▂▃▅╲▅▄▂▖╲▃╸━▅▄▆▃▌▖⎺▄●▅▅▃▂ ▃▃▃┷▆●▃╱▅▆▆▄▆▅▃▃▆▃⎽▝━▂▄▅⎽⎺▋▆▝⎺▖╇▼▝▃▎▝▃▖╺▂╺▍▝▝▅╺▖▄┇⎽▂▃▚▝▅▂▅▂▆▆▃▆▃▂▄▃▖⎽▗▂▅▂╏⎺▝▘▗▘╸▝▅┗▄▅▃▆▄▂╺▝▄▝⎼▂▅▋⎽▄▂▆▅▃▄▂▆▆▄▂▄▖▃▆▅▃▂⎺▆▄▄⎽▮▅╺⎽┑▝▗⎻┣⎺▃▆ ▂▄⎺▃▃╼┑┒▎▊▍▅▅▅▃▅▅▃▂▅▂▄━▄▅▖▌▗▃▆▄⎺▅┙▗▝▆▃▆▄▃▂▖▂▅▝▃▆⎽▃┤▅▄▗▂▃▅▆▄⎺▄⎽⎺▅▂▅▃⎽┛⎺▆▝╸⎽▌⎺▃▅╺▂⎽▃╺▆▅▂▚▅▂▃▄▃▄▄▝▃⎽▎▆▎▃▄⎺▆▃▃▄⎽⎺▆▃⎽▅▖╺▄▖▃▂▃▄▅▃━▆▅▂▂▂┻▄▄▂ ▆▃▆▂━▝▖▖▅╾▄▂▃▆▆▄▃▅▂▆▃■▃⎽▄┓╴┓▅▄▝▄▄▃▂▚▅▆▃▄╼▝◀●⎺▄▚▅▘▝▅▮◀⎽▅■▂⎽▝⎺▅▃▆▃⎽▆▄▂▄▂▘▖▝▌▃▝▌▘╶▊╺╼┳━▄━▮⎼▅▂▂▃━▄▃▂▌▝▂▃▗▂▘⎼▅⎺▅▃▄▃▂⎺▅▂▆▄▂▂◀⎼⎽▗▝▄▗⎺▆▅▂▄▖╾▅ ▄▄╾▼▍▄┲▅■▄▖▖▲▅▋▝▆▅▃⎺▃·▆▃▅▂▂■╸━▖⎺▃▂▘▄╾▃▝▄■▆▖▄▖▖▝▄▋▝▃▄▗▄▄┎▆╺▝▃▄▮▆▄▂▅▂▅▅▃▆▃▂▚▃⎺▃▝▂▄▄⎺┏▄▖⎼⎺━⎼▅▃▖▆▄▂▃▆▖▄▅▂▋▍┗⎺▄▃▂▆▄▂▃▂▅⎺▄▂▃▖▖▃╺▘▗▄▄▂▘▅▃▂▼▃ ▄▅▄┷╾▃▝▃▆▅▅▄▝▗▄▃▌⎺▃▆▄▃▆▂▄▅▂▄▂▖⎽▂▅▃▃▅▄▝━▼▆▚▃▖▖╲▂▗━▅▘▖▃┺▅▍▖╸▆▄⎺▖▆╸▝▄▃▆▃▂▆▄▂▅▂▗▃▄▄▅─▝▘●⎺▅▖▃━▃▍▖▂▝▂▄▝▂▗▖▂▂▆▆━╸▅⎺▼▆╾▆▄▄▃▃⎺▆▄⎽▃▂▄▃▂╺▆╸╼▆▄▗▘ ╸━▃▘▆╸▼▄▃▘▖▶▆▆▂▝╸▆▄▃▆▃▝▄⎺▅▂●▄▅▂▂▖▂■▂▃▖●╸▖▂▆▄▃▖▃┑▋▂▂▅▃■╸▅▗┗▅▍╾⎼◀▝▍▝■▆▅▂▃▂⎺▆▃■▄▂▂▂▂▃╸▗▃·▘╴╺▅⎽⎼▗▖▋▂▅▄┛━▘■●▄▌▆▅━▂╺╺▝▂⎺▅▃▄▂⎽⎺▆▃⎽▄▖▄▄▄▃▃▃▄▃ ╸▖╾╸▅┺━▖┲╺▝▖▄▆▄▄▅▖╲▄▄▅▆▃▆▆▃▆▃⎽▆━▄▂▖▅▘╾▍▆▅▅▃▋▝▚▅▂▖▄▖▖▅▚▄▅┗▗▍▖╺▆╺▄▘▌╴▄▼▝▆▄▂▃▝▆▅▃▆▃⎽▝▃▃▘⎺▅▃▂▚╾▆▝▃▖╾▄▖◼━▃▅▆▝▄▝━·▼▗▂▄▗┓▆▂▆▄▃▃▂◼⎺▅▂▅▃▆▅▅▅▅▅ ▅⎺▆▝╸▼⎺▄▄┗▅▄▂▄▃╺▗▅▄▅▅▄▃▂▆▅▆▆▄▂▅▂▄▄▅▃▂╺▂▘▝⎽▝▅▍╼▖▗▝▄▄▂▆▄┲▅▚▃▄■▘▘⎺▖╺▅▄▆▅▚▖▅▅▅▄▄▃▅▄▃▂▅▂▅▆┷▊╲╏▝━▚╸▃▆▄▅⎺▆▃⎻╸▃┗▖▗▖▘▅┵▎▗▃╺▄▂▖▄▝▆▄▅▃▂▌▆▄▂▄▃▮▄▅ ▆▂▅▄▗▆▃━▼━▂━▝▆▄⎺▃▂▅▅▄▂⎺▝▅▄⎺▝▄▖▆▄▆▄▂▅▆▄▂▃━⎺◀▎┠▍▗▅▗▂▅▄▚▄▆▄┑▆▂▄━▃▃▃▂▄▃▃━⎽▖⎺▄▝▂▆▅▃▄▂⎺▅▃▆▄▂▆▆▆┎▄▗⎺▄╼┻▍▍━╺■▎╺▗▅▖▗▘╸▗▆▗▂▅━▆▎▃▆▗▅▝▅▃▄▂▖⎺▆▄▂▄▖ ▆▂▆▄⎻▖▅▖╸▖▅▖╺▅▍▂▅▃▅▝▄▂▝▂▃╲▂▃▝▝▄▆▆▃▂▅▃▆▄▆▃⎽▖▂┕▘▂▄▃▆■▖▃▗▖▂■▝■▃▝▂▝▗▘▅▃┒━⎺▃┳▝▌▝▃╸▂▆▄▃▃▂⎺▅▂▅▃⎽▍⎼▂⎻▼▚▅▅▂━▝━⎺▖▄⎽▖▂▋━┗⎺▖▖▃▄━■▅▆▅▗▆▝⎺▆▄▃▄▂▅⎺▆▅ ╲⎽▄▚▖▂⎽▅▃▗▃▄━▅▘▅▃▲▘▄▅▝▅▂▝▅▃▃⎻⎽━▅▝▃▄▅▃⎺▄▂▆▃▄▂▍▅▍▅▅▘╸▅╲▃▅▃▂▅▂▅▃┗▝◆▅▄▚▖▄⎺▂▖⎽▄▖▚▃▃▊▅▆▅▃▃▃⎺▆▄⎽▄▂⎽▝▃▃▚▃⎺╱·┕▅━▘▆▝▘▚▂▆▃▄▍▂▂▗▘▄▗▘▄■▅▌▘▋▝▅▄▅▃▘▘ ▃▂▂▝▆▄⎽▆⎽▅▖⎽╺▆▘▘▂▅▅▅▖▃▃▃▂▄▼▆▖■▗▘╸▝▝▝▅▌▄▂▅▃▖▅▆▄▂▝┷▝▃▃⎺▍▖▗▝▚▖⎺▆▆▶▆▖▃■▌◼▆▃■▋▃▂▅▝■▗▃■▖▄⎺▄▂▄▂⎺▅▃▆▃▂▆▅▃▚▘╲▄▃▗▃▂▖▘▗⎽━▄▘▆╺▄▂▆▝┗▝⎽◀╺▅━◼▗▃▂▗▘▅▅ ▅▂▄▂▂╾▃▂▂▅▄▅▘▌▏▆▄▂⎺▃▅▃╱▌▗▆▖▆▄▂▃▄┑▗▂▄▆▃▆▄▅▄⎺▄▂▆▃▅▃⎽▝·╾┣▝▍▌▘━▆▃▂▂╸▼■▅▝╲▖▖■▃▃⎺▃▗▃▗▅▆▝▘▂▅▃▅▄▃▃▂▆▄▂▅▃▂●▆▄▖▃▘▆▄▝▅▗▆╸■▃▘▗▗▂⎼╸▃▖╸▄▄▖▗▄▅▗▗▘▄■⎼
Checking the Look in Text Browsers
It even looks not that bad in elinks — as far as I know the only text browser which supports CSS and styles:

In Lynx and Links 2, the text composing the image is displayed only in black and white, but you at least can recognise the edges in the picture:

Same Functionality in One Tool?
I knew there was a tool which did this in one step. Seems to have been png2html.
Tried to play around with it, too, but neither really understood how to use it (seems to require a text file for the characters to be used — why?) nor did I really got it working. It always ran until I aborted it and it never filled the target file with any content.
Additionally, png2html insists on one character per pixel, requiring to first properly resize the image before converting to HTML.
The Keyboard in the Pictures
Oh, and btw., the displayed keyboard is my Zlant. The Zlant is a 40% uniform staggered mechanical keyboard. Currently, only Zlant PCBs are available at 1UP Keyboards (USA), i.e. no complete kits.
It is shown with the SA
Vilebloom key cap set, currently available at MechSupply (UK).
Tagged as: 1UPKeyboards, 40% Keyboard, aha, chafa, CSS, elinks, Graphics, HTML, Keyboard, Links2, Lynx, Mechanical Keyboard, MechSupply, png2html, SA Vilebloom, Text Browser, Text Mode, xterm, Zlant
// show without comments // write a comment
Related stories
Friday·16·November·2012
Useful but Unknown Unix Tools: dwdiff better than wdiff + colordiff //at 01:18 //by abe
A year ago I wrote in Useful but Unknown Unix Tools: How wdiff and colordiff help to choose the right Swiss Army Knife about using wdiff and colordiff together. Colordiff’ed wdiff output looks like this:
$ wdiff foobar.txt barfoo.txt | colordiff [-foo-]bar fnord gnarz hurz quux bla {+foo+} fasel
But if you have colour, why still having these hard to read wdiff markers still in the text?
There exists a tool named dwdiff which can do word diffs in colour without
textual markers and with even less to type (and without being
git diff --color-words
;-). Actually it looks like
git diff --color-words
, just without the git:
$ dwdiff -c foobar.txt barfoo.txt foo bar fnord gnarz hurz quux bla foo fasel
Another cool thing about dwdiff (and its name giving feature) is that you can defined what you consider whitespace, i.e. which character(s) delimit the words. So lets do the example above again, but this time declare that “f” is considered the only whitespace character:
$ dwdiff -W f -c foobar.txt barfoo.txt foo bar bar fnord gnarz hurz quux bla foo fasel
dwdiff can also show line numbers:
$ dwdiff -c -L foobar.txt barfoo.txt 1:1 foo bar fnord 2:2 gnarz hurz quux 3:3 bla foo fasel $ dwdiff -c -L foobar.txt quux.txt 1:1 foo bar fnord 1:2 foobar floedeldoe 2:3 gnarz hurz quux 3:4 bla foo fasel
(coloured shell screenshots by aha)
Tagged as: aha, colordiff, dwdiff, git, UUUT, wdiff
// show without comments // write a comment
Related stories
Wednesday·14·March·2012
SSH Multiplexer: parallel-ssh //at 03:10 //by abe
There are many SSH multiplexers in Debian and most of them have one or two features which make them unique and especially useful for that one use case. I use some of them regularily (I even maintain the Debian package of one of them, namely pconsole :-) and I’ll present then and when one of them here.
For non-interactive purposes I really like parallel-ssh aka
pssh. It takes a file of hostnames and a bunch of common ssh
parameters as parameters, executes the given command in parallel in up
to 32 threads (by default, adjustable with -p
) and waits
by default for 60 seconds (adjustable with -t
). For
example to restart hobbit-client on all hosts in kiva.txt,
the following command is suitable:
$ parallel-ssh -h kiva.txt -l root /etc/init.d/hobbit-client restart [1] 19:56:03 [FAILURE] kiva6 Exited with error code 127 [2] 19:56:04 [SUCCESS] kiva [3] 19:56:04 [SUCCESS] kiva4 [4] 19:56:04 [SUCCESS] kiva2 [5] 19:56:04 [SUCCESS] kiva5 [6] 19:56:04 [SUCCESS] kiva3 [7] 19:57:03 [FAILURE] kiva1 Timed out, Killed by signal 9
(Coloured “Screenshots” done with ANSI HTML Adapter from the package aha.)
You easily see on which hosts the command failed and partially also why: On kiva6 hobbit-client is not installed and therefore the init.d script is not present. kiva1 is currently offline so the ssh connection timed out.
If you want to see the output of the commands, you have a two choices. Which one to choose depends on the expected amount of output:
If you don’t expect a lot of output, the -i
(or
--inline
) option for inline aggregated output is probably
the right choice:
$ parallel-ssh -h kiva.txt -l root -t 10 -i uptime [1] 20:30:20 [SUCCESS] kiva 20:30:20 up 7 days, 5:51, 0 users, load average: 0.12, 0.08, 0.06 [2] 20:30:20 [SUCCESS] kiva2 20:30:20 up 7 days, 5:50, 0 users, load average: 0.19, 0.08, 0.02 [3] 20:30:20 [SUCCESS] kiva3 20:30:20 up 7 days, 5:49, 0 users, load average: 0.10, 0.06, 0.06 [4] 20:30:20 [SUCCESS] kiva4 20:30:20 up 7 days, 5:49, 0 users, load average: 0.25, 0.17, 0.14 [5] 20:30:20 [SUCCESS] kiva6 20:30:20 up 7 days, 5:49, 10 users, load average: 0.16, 0.08, 0.02 [6] 20:30:21 [SUCCESS] kiva5 20:30:21 up 7 days, 5:49, 0 users, load average: 3.11, 3.36, 3.06 [7] 20:30:29 [FAILURE] kiva1 Timed out, Killed by signal 9
If you expect a lot of output you can give directories with the
-o
(or --outdir
) and -e
(or
--errdir
) option:
$ parallel-ssh -h kiva.txt -l root -t 20 -o kiva-output lsb_release -a [1] 20:36:51 [SUCCESS] kiva [2] 20:36:51 [SUCCESS] kiva2 [3] 20:36:51 [SUCCESS] kiva3 [4] 20:36:51 [SUCCESS] kiva4 [5] 20:36:53 [SUCCESS] kiva6 [6] 20:36:54 [SUCCESS] kiva5 [7] 20:37:10 [FAILURE] kiva1 Timed out, Killed by signal 9 $ ls -l kiva-output total 24 -rw-r--r-- 1 abe abe 98 Aug 28 20:36 kiva -rw-r--r-- 1 abe abe 0 Aug 28 20:36 kiva1 -rw-r--r-- 1 abe abe 98 Aug 28 20:36 kiva2 -rw-r--r-- 1 abe abe 98 Aug 28 20:36 kiva3 -rw-r--r-- 1 abe abe 98 Aug 28 20:36 kiva4 -rw-r--r-- 1 abe abe 102 Aug 28 20:36 kiva5 -rw-r--r-- 1 abe abe 100 Aug 28 20:36 kiva6 $ cat kiva-output/kiva5 Distributor ID: Debian Description: Debian GNU/Linux 6.0.2 (squeeze) Release: 6.0.2 Codename: squeeze
The only annoying thing IMHO is that the host list needs to be in a file. With zsh, bash and the original ksh (but neither tcsh, pdksh nor mksh), you can circumvent this restriction with one of the following command lines:
$ parallel-ssh -h <(printf "host1\nhost2\nhost3\n…") -l root uptime […] $ parallel-ssh -h <(echo host1 host2 host3 … | xargs -n1) -l root uptime […]
And in zsh there’s an even easier way to type this:
$ parallel-ssh -h <(print -l host1 host2 host3 …) -l root uptime […]
In addition to parallel-ssh
the pssh
package also contains some more ssh based tools:
parallel-scp
andparallel-rsync
for parallel copying files onto a set of hosts.parallel-slurp
for fetching files in parallel from a list of hosts.parallel-nuke
to kill a bunch of processes in parallel on a set of machines.
I though think that parallel-ssh
is by far the most
useful tool from the pssh package. (Probably no wonder
as it’s the most generic one. :-)
Tagged as: aha, Multiplexer, parallel-ssh, pconsole, pssh, SSH, UUUT
// show without comments // write a comment
Related stories
Thursday·01·September·2011
Useful but Unknown Unix Tools: How wdiff and colordiff help to choose the right Swiss Army Knife //at 12:18 //by abe
In light of the fact that it seems possible to fit the plastic caps of a Debian branded Swiss Army Knife (Last orders today!) on an existing Swiss Army Knife (German written howto as PDF), I started to think about which Victorinox Cybertool would be the best fitting for me.
And because the Victorinox comparison page doesn’t really show diffs, just columns with floating text which are not very helpful for generating diffs in your head, I used command line tools for that purpose:
wdiff
Because the floating texts are not line- but just whitespace-based,
the tool of choice is not diff
but wdiff
, a word-based diff. It encloses additions and removals
in {+…+}
and [-…-]
blocks.
(No, those aren’t Japanese smileys although they look a lot like some.
^^).
The easiest and clearest way is to copy and paste the texts from Victorinox’ comparison page into some text files and
compare them with wdiff
:
$ wdiff cybertool34.txt cybertool41.txt
{+Schraubendreher 2.5mm,+} Pinzette, Nähahle mit Nadelöhr, {+Holzsäge,+} Bit-Schlüssel( 5 mm Innensechskant für die D-SUB Steckverbinder, 4 mm Innensechskant für Bits, Bit Phillips 0, Bit Phillips 1, Bit-Schlitzschrauben 4 mm, Bit Phillips 2, Bit Hex 4 mm, Bit Torx 8, Bit Torx 10, Bit Torx 15 ), Kombizange( Hülsenpresser, Drahtschneider ), Stech-Bohrahle, Kugelschreiber( auch zum DIP-Switch verstellen ), Mehrzweckhaken (Paketträger), {+Metallsäge( Metallfeile, Nagelfeile, Nagelreiniger ),+} Dosenöffner( kleiner Schraubendreher ), Kleine Klinge, Grosse Klinge, Ring, inox, Mini-Schraubendreher, Kapselheber( Schraubendreher, Drahtabisolierer ), {+Holzmeissel / Schaber,+} Bit-Halter, Stecknadel, inox, Schere, Korkenzieher, Zahnstocher
So this already extracted the information which are the seven tools which are in the Cybertool 41, but not in the Cybertool 34. Nevertheless the diff is still not easily recognizable on the first glance. There are several ways to help here.
First wdiff
has an option --no-common
(the
according short option is -3
) which just shows added and
removed words:
$ wdiff -3 cybertool34.txt cybertool41.txt ====================================================================== {+Schraubendreher 2.5mm,+} ====================================================================== {+Holzsäge,+} ====================================================================== {+Metallsäge( Metallfeile, Nagelfeile, Nagelreiniger ),+} ====================================================================== {+Holzmeissel / Schaber,+} ======================================================================
This is already way better to quickly recognize the actual differences.
But if you still also want to see the common tools of the two knifes you need some visual help:
One option is to use wdiff
’s --terminal
(or
short -t
) option. Added words are then displayed inverse
and removed words are shown underlined (background and foreground
colors hardcoded as there is no “invert colors” style in CSS or HTML):
$ wdiff -t cybertool34.txt cybertool41.txt
Schraubendreher 2.5mm, Pinzette, Nähahle mit Nadelöhr, Holzsäge, Bit-Schlüssel( 5 mm Innensechskant für die D-SUB Steckverbinder, 4 mm Innensechskant für Bits, Bit Phillips 0, Bit Phillips 1, Bit-Schlitzschrauben 4 mm, Bit Phillips 2, Bit Hex 4 mm, Bit Torx 8, Bit Torx 10, Bit Torx 15 ), Kombizange( Hülsenpresser, Drahtschneider ), Stech-Bohrahle, Kugelschreiber( auch zum DIP-Switch verstellen ), Mehrzweckhaken (Paketträger), Metallsäge( Metallfeile, Nagelfeile, Nagelreiniger ), Dosenöffner( kleiner Schraubendreher ), Kleine Klinge, Druckkugelschreiber, Grosse Klinge, Ring, inox, Mini-Schraubendreher, Kapselheber( Schraubendreher, Drahtabisolierer ), Holzmeissel / Schaber, Bit-Halter, Stecknadel, inox, Schere, Korkenzieher, Zahnstocher
But some still like to to use color instead of the contrast-rich inverse and the easily to oversee underlining. This is where colordiff comes into play:
colordiff
colordiff is like syntax highlighting for diffs on the
command line. I works with classic and unified diffs as well as with
wdiffs and debdiffs (the debdiff
command is part of the
devscripts package).
$ wdiff cybertool34.txt cybertool41.txt | colordiff
{+Schraubendreher 2.5mm,+} Pinzette, Nähahle mit Nadelöhr, {+Holzsäge,+} Bit-Schlüssel( 5 mm Innensechskant für die D-SUB Steckverbinder, 4 mm Innensechskant für Bits, Bit Phillips 0, Bit Phillips 1, Bit-Schlitzschrauben 4 mm, Bit Phillips 2, Bit Hex 4 mm, Bit Torx 8, Bit Torx 10, Bit Torx 15 ), Kombizange( Hülsenpresser, Drahtschneider ), Stech-Bohrahle, Kugelschreiber( auch zum DIP-Switch verstellen ), Mehrzweckhaken (Paketträger), {+Metallsäge( Metallfeile, Nagelfeile, Nagelreiniger ),+} Dosenöffner( kleiner Schraubendreher ), Kleine Klinge, Grosse Klinge, Ring, inox, Mini-Schraubendreher, Kapselheber( Schraubendreher, Drahtabisolierer ), {+Holzmeissel / Schaber,+} Bit-Halter, Stecknadel, inox, Schere, Korkenzieher, Zahnstocher$ wdiff cybertool29.txt cybertool41.txt | colordiff
{+Schraubendreher 2.5mm,+} Pinzette, Nähahle mit Nadelöhr, {+Holzsäge,+} Bit-Schlüssel( 5 mm Innensechskant für die D-SUB Steckverbinder, 4 mm Innensechskant für Bits, Bit Phillips 0, Bit Phillips 1, Bit-Schlitzschrauben 4 mm, Bit Phillips 2, Bit Hex 4 mm, Bit Torx 8, Bit Torx 10, Bit Torx 15 ), {+Kombizange( Hülsenpresser, Drahtschneider ),+} Stech-Bohrahle, {+Kugelschreiber( auch zum DIP-Switch verstellen ), Mehrzweckhaken (Paketträger), Metallsäge( Metallfeile, Nagelfeile, Nagelreiniger ),+} Dosenöffner( kleiner Schraubendreher ), Kleine Klinge, [-Druckkugelschreiber,-] Grosse Klinge, Ring, inox, Mini-Schraubendreher, Kapselheber( Schraubendreher, Drahtabisolierer ), {+Holzmeissel / Schaber,+} Bit-Halter, Stecknadel, inox, {+Schere,+} Korkenzieher, Zahnstocher
(Coloured “Screenshots” done with ANSI HTML Adapter from the package aha.)
Some, especially those who are used to git, are probably
confused by the default choice of diff colors. This is easily fixable
by writing the following into you ~/.colordiffrc
:
newtext=green oldtext=red diffstuff=darkblue cvsstuff=darkyellow
(See also /etc/colordiff
for the defaults and hints.)
colordiff
has by the way two operating modes:
- Without parameter it reads diffs from standard input as seen above.
- With parameters it works as drop-in diff replacement including all diff options as shown below.
So now let us compare the Cybertool 29 with Cybertool 34 in a normal diff (by using the texts from above and replacing all commata with newline characters) with git-like colors:
$ colordiff cybertool29-lines.txt cybertool34-lines.txt 12a13,14 > Kombizange( Hülsenpresser > Drahtschneider ) 13a16,17 > Kugelschreiber( auch zum DIP-Switch verstellen ) > Mehrzweckhaken (Paketträger) 16d19 < Druckkugelschreiber 25a29 > Schere
Or as unifed diff with some context:
$ colordiff -u cybertool29-lines.txt cybertool34-lines.txt --- cybertool29-lines.txt 2011-08-31 20:55:37.195546238 +0200 +++ cybertool34-lines.txt 2011-08-31 20:55:11.667710504 +0200 @@ -10,10 +10,13 @@ Bit Torx 8 Bit Torx 10 Bit Torx 15 ) +Kombizange( Hülsenpresser +Drahtschneider ) Stech-Bohrahle +Kugelschreiber( auch zum DIP-Switch verstellen ) +Mehrzweckhaken (Paketträger) Dosenöffner( kleiner Schraubendreher ) Kleine Klinge -Druckkugelschreiber Grosse Klinge Ring inox @@ -23,5 +26,6 @@ Bit-Halter Stecknadel inox +Schere Korkenzieher Zahnstocher
So if you want nicely colored diffs with Subversion like you’re used
to with git, you can use svn diff | colordiff
.
Tagged as: aha, colordiff, Colorful Console, Cybertool, debdiff, Debian, devscripts, diff, git, nuggets, SAK, svn, Swiss Army Knife, UUUT, Victorinox, wdiff
// show without comments // write a comment
Related stories
Wednesday·31·August·2011
Useful but Unknown Unix Tools: Calculating with IPs, The Sequel //at 20:09 //by abe
This is a direct followup on my previous blog posting about calculating IPs and netmasks with the tools netmask and prips. Kurt Roeckx (via e-mail) and Niall Donegan (via a comment to that blog posting) both told me about the package sipcalc, and Kurt also mentioned the package ipcalc. Thanks for that! And since I found both useful, too, let’s put them in their own blog posting:
Both tools, ipcalc and sipcalc offer a “get all information at once” mode which are not present in the previously presented tool netmask.
ipcalc
ipcalc by default outputs all information and even in ANSI colors:
$ ipcalc 192.168.96.0/21 Address: 192.168.96.0 11000000.10101000.01100 000.00000000 Netmask: 255.255.248.0 = 21 11111111.11111111.11111 000.00000000 Wildcard: 0.0.7.255 00000000.00000000.00000 111.11111111 => Network: 192.168.96.0/21 11000000.10101000.01100 000.00000000 HostMin: 192.168.96.1 11000000.10101000.01100 000.00000001 HostMax: 192.168.103.254 11000000.10101000.01100 111.11111110 Broadcast: 192.168.103.255 11000000.10101000.01100 111.11111111 Hosts/Net: 2046 Class C, Private Internet
(Coloured “Screenshots” done with ANSI HTML Adapter from the package aha.)
You can suppress the bitwise option or directly output HTML via
commandline options. For example ipcalc -b -h 192.168.96.0/21
outputs the following content:
Address: 192.168.96.0 Netmask: 255.255.248.0 = 21 Wildcard: 0.0.7.255 => Network: 192.168.96.0/21 HostMin: 192.168.96.1 HostMax: 192.168.103.254 Broadcast: 192.168.103.255 Hosts/Net: 2046 Class C, Private Internet
Yes, that’s an HTML table and no preformatted text, just with a monospaced font. (I just removed the hardcoded text color from it, otherwise it would not look nice on dark backgrounds like in Planet Commandline’s default color scheme.)
Like netmask, ipcalc can also deaggregate IP ranges into largest possible networks:
$ ipcalc 192.168.87.0 - 192.168.110.255 deaggregate 192.168.87.0 - 192.168.110.255 192.168.87.0/24 192.168.88.0/21 192.168.96.0/21 192.168.104.0/22 192.168.108.0/23 192.168.110.0/24
(ipcalc -r 192.168.87.0 192.168.110.255
is just another
way to write this, and it results in the same output.)
To find networks with at least 20, 63 and 30 IP addresses within a /24 network, use for example:
Address: 192.0.2.0 Netmask: 255.255.255.0 = 24 Wildcard: 0.0.0.255 => Network: 192.0.2.0/24 HostMin: 192.0.2.1 HostMax: 192.0.2.254 Broadcast: 192.0.2.255 Hosts/Net: 254 Class C 1. Requested size: 20 hosts Netmask: 255.255.255.224 = 27 Network: 192.0.2.128/27 HostMin: 192.0.2.129 HostMax: 192.0.2.158 Broadcast: 192.0.2.159 Hosts/Net: 30 Class C 2. Requested size: 63 hosts Netmask: 255.255.255.128 = 25 Network: 192.0.2.0/25 HostMin: 192.0.2.1 HostMax: 192.0.2.126 Broadcast: 192.0.2.127 Hosts/Net: 126 Class C 3. Requested size: 30 hosts Netmask: 255.255.255.224 = 27 Network: 192.0.2.160/27 HostMin: 192.0.2.161 HostMax: 192.0.2.190 Broadcast: 192.0.2.191 Hosts/Net: 30 Class C Needed size: 192 addresses. Used network: 192.0.2.0/24 Unused: 192.0.2.192/26
sipcalc
sipcalc is similar to ipcalc. One big difference seems to be the IPv6 support:
$ sipcalc 2001:DB8::/32 -[ipv6 : 2001:DB8::/32] - 0 [IPV6 INFO] Expanded Address - 2001:0db8:0000:0000:0000:0000:0000:0000 Compressed address - 2001:db8:: Subnet prefix (masked) - 2001:db8:0:0:0:0:0:0/32 Address ID (masked) - 0:0:0:0:0:0:0:0/32 Prefix address - ffff:ffff:0:0:0:0:0:0 Prefix length - 32 Address type - Aggregatable Global Unicast Addresses Network range - 2001:0db8:0000:0000:0000:0000:0000:0000 - 2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff
(Thanks to Niall for the pointer to RFC3849. :-)
It can also split up networks into smaller chunks, but only same-size chunks, like e.g. split a /32 IPv6 network into /34 networks:
sipcalc -S34 2001:DB8::/32 -[ipv6 : 2001:DB8::/32] - 0 [Split network] Network - 2001:0db8:0000:0000:0000:0000:0000:0000 - 2001:0db8:3fff:ffff:ffff:ffff:ffff:ffff Network - 2001:0db8:4000:0000:0000:0000:0000:0000 - 2001:0db8:7fff:ffff:ffff:ffff:ffff:ffff Network - 2001:0db8:8000:0000:0000:0000:0000:0000 - 2001:0db8:bfff:ffff:ffff:ffff:ffff:ffff Network - 2001:0db8:c000:0000:0000:0000:0000:0000 - 2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff -
Similar thing with IPv4:
sipcalc -s27 192.0.2.0/24 -[ipv4 : 192.0.2.0/24] - 0 [Split network] Network - 192.0.2.0 - 192.0.2.31 Network - 192.0.2.32 - 192.0.2.63 Network - 192.0.2.64 - 192.0.2.95 Network - 192.0.2.96 - 192.0.2.127 Network - 192.0.2.128 - 192.0.2.159 Network - 192.0.2.160 - 192.0.2.191 Network - 192.0.2.192 - 192.0.2.223 Network - 192.0.2.224 - 192.0.2.255
sipcalc also has a “show me all information” mode with the -a option:
$ sipcalc -a 192.168.96.0/21 -[ipv4 : 192.168.96.0/21] - 0 [Classfull] Host address - 192.168.96.0 Host address (decimal) - 3232260096 Host address (hex) - C0A86000 Network address - 192.168.96.0 Network class - C Network mask - 255.255.255.0 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.96.255 [CIDR] Host address - 192.168.96.0 Host address (decimal) - 3232260096 Host address (hex) - C0A86000 Network address - 192.168.96.0 Network mask - 255.255.248.0 Network mask (bits) - 21 Network mask (hex) - FFFFF800 Broadcast address - 192.168.103.255 Cisco wildcard - 0.0.7.255 Addresses in network - 2048 Network range - 192.168.96.0 - 192.168.103.255 Usable range - 192.168.96.1 - 192.168.103.254 [Classfull bitmaps] Network address - 11000000.10101000.01100000.00000000 Network mask - 11111111.11111111.11111111.00000000 [CIDR bitmaps] Host address - 11000000.10101000.01100000.00000000 Network address - 11000000.10101000.01100000.00000000 Network mask - 11111111.11111111.11111000.00000000 Broadcast address - 11000000.10101000.01100111.11111111 Cisco wildcard - 00000000.00000000.00000111.11111111 Network range - 11000000.10101000.01100000.00000000 - 11000000.10101000.01100111.11111111 Usable range - 11000000.10101000.01100000.00000001 - 11000000.10101000.01100111.11111110 [Networks] Network - 192.168.96.0 - 192.168.103.255 (current)
Thanks again to Kurt and Niall for their contributions!
Now listening to the schreimaschine and fausttanz
submissions for the interactive
competition at the Bünzli/DemoDays in Olten (Switzerland)
Tagged as: aha, Bünzli, CLI, Colorful Console, Contribution, Debian, DemoDays, Fausttanz, IP, ipcalc, IPv6, netmask, nuggets, Planet Commandline, RFC, RFC3849, Schreimaschine, sipcalc, UUUT
// show without comments // write a comment
Related stories
Tuesday·30·November·2010
Useful but Unknown Unix Tools: colored cal(endar) //at 02:09 //by abe
Another thing I regard as useful on the commandline are colors. (Others commonly refer to my color preferences as eye cancer, but that’s not relevant here. ;-) Colors help to easily distinguish between relevant and non-relevant things or to separate different things.
One colored command line program I use nearly everyday is the colored fork of bsdmainutils’s well know (or at least better known) “cal” program whose output looks like this:
$ cal
November 2010
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
$
Since the colored fork calls itself still “cal” (as the Debian source package is called), to avoid conflicts with bsdmainutils’s cal, the binary package and the binary itself are called ccal (short for colored cal) and its output looks like this:
$ ccal November 2010 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29<30> $
ccal also use the locale definitions (LC_TIME), if available, that’s why the one “screenshot” is Sun-Sat and the other one is Mon-Sun.
According to the man page, ccal has some more improvements over the classic cal:
If displaying the single-month format, ccal will look for a date file (the default file or whatever you specify with the -d option). If found, ccal will read the file, looking for special date descriptions for that month which will be displayed to the right of the calendar. By default, up to 24 appointments (number may be changed with -m) may be displayed per month. If the current date happens to fall on one of these special dates, it will be flagged by an asterisk. If there is room, appointments for the next month may also be displayed (next monthâs dates having definitions like “2nd Thursday” will be skipped).
But I must admit, I don’t use that feature. I just use it as on-demand calendar sheet.
The colored “screenshot” above is btw. generated with Adam Borowski’s ansi2html which popped up after I published my Intent to package “aha” (for Ansi HTML Adapter), the first ANSI colors to HTML converter I found on the net. (And yes I searched for it because of this and some yet to come blog postings. No spoilers here though. ;-)
While capturing colored output of “ls” and some other tools was easy, it needed a little hack to capture ccal’s output, because if you pipe ccal output to anything, it drops its colors. Always. The solution was to run it in GNU Screen, log the output and then pipe the log file through “aha” or “ansi2html”:
$ screen -c /dev/null -L ccal; cat screenlog.0 | ansi2html > ccal.html
Probably the output of every program which drops colors when writing to a pipe instead of a terminal can be fetched that way.
Update, 2:04 CET: As Adam Borowski points out in message 62 of #605380, “script” is the better tool for making tools believe they talk to a terminal:
$ script -q /dev/null -c "ccal" | ansi2html
Catching the output of a whole year’s calender (“ccal 2011”) failed
with GNU screen though, as it was truncated on the 24th of September
by GNU screen (as it was already truncated in the screenlog.0), so no
“screenshot” of that for the moment. And with script, I’d get the
whole output, but would have to manually fix the styles so they don’t
get posted literally to Planet Debian. So look for yourself how the
output of “ccal 2011” looks like by installing ccal. ;-)
Tagged as: aha, ANSI, ansi2html, cal, calendar, ccal, Colorful Console, Eye Cancer, GNU Screen, HTML, ITP, LC_TIME, locales, nuggets, Planet Debian, screen, UUUT
// show without comments // write a comment