Code2Img

Bash code screenshots.

How to screenshot Bash code properly: what Bash snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Terminal content, which is the most genre-mixed of the ten: a shebang and set -euo pipefail at the top, if [ -z "$1" ]; then conditionals, $(…) command substitution, heredocs (<<'EOF'), curl invocations with a dozen flags and line continuations (\), and often the command's output pasted underneath. Variables ($HOME, ${var:-default}) are the language's whole identity, and they are also what makes rendering tricky: ${…} nests braces, quotes and $ in one token.

How auto-detection behaves

This is the weakest detection of the ten, and it is structural: the shell rule is last in the array (17), behind JSON and YAML. It fires on a #!/bin/sh-style shebang, echo $, or a line starting with apt, curl, cd, mkdir, or export. Notice what is not a trigger: if, then, for, while, ls, grep, sed, cat, printf, and #!/usr/bin/env bash with spaces. A script starting set -e and if [ … ] therefore falls through to the typescript default and gets coloured as TypeScript — braces and all. The same rule's triggers also misfire on prose ("curl the endpoint"), so a snippet of documentation can be typed as shell.

Theme that reads best

night-owl for dark, because it was designed for terminal palettes and its string colour survives the long quoted flags in a curl line. github-light for documentation cards; shell in a README should look like the rest of the README.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.