Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

92.9. glow-3.0.0

Render markdown on the command line

Version 3.0.0, release 1
Shelf cli — Command-line productivity utilities: search, view, navigation and text wrangling in the terminal
Phase 41_system (System), 290 of 1047 in build order
Licence MIT
Homepage https://github.com/charmbracelet/glow
Build time 0.4 SBU
Installed size 20.0 MiB in 7 files
Recipe ports/core/cli/glow/kpkgbuild

About

glow renders Markdown in the terminal: headings, lists, tables, code blocks with highlighting and links, in a style that suits a light or dark background. Given a file it prints it rendered; run with no argument it opens a browser of the Markdown files under the current directory. The port installs glow, a manual page and completions generated from the binary, and a desktop entry that opens a Markdown file in a terminal as Markdown Reader.

Sources

Dependencies

Depends on: go.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install glow'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/cli/glow.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/cli/glow
echo '18df6f3c09157021366b8c702b5badba405d37dbb42f132353eb50c1b0d3f464  glow-3.0.0.tar.gz' | sha256sum -c -
echo '1aa9ddde127b51a7dbaf5e3d4c328df37fe0849974dd360f15e536f61fb7e3d0  glow-vendor-3.0.0.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/glow
SRC=$SRC_ROOT/glow-3.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf glow-3.0.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz

export CGO_ENABLED=0
go build -mod=vendor -ldflags "-s -w -X main.Version=$version" -o glow
install -Dm755 glow $PKG/usr/bin/glow
HOME="$PWD/.home" XDG_CACHE_HOME="$PWD/.home" XDG_CONFIG_HOME="$PWD/.home" ./glow man | sed 's/\x1b\[[0-9;]*m//g' > glow.1
install -Dm644 glow.1 -t $PKG/usr/share/man/man1
for sh in bash zsh fish; do
	HOME="$PWD/.home" XDG_CACHE_HOME="$PWD/.home" XDG_CONFIG_HOME="$PWD/.home" ./glow completion $sh > glow.$sh
done
install -Dm644 glow.bash $PKG/usr/share/bash-completion/completions/glow
install -Dm644 glow.zsh  $PKG/usr/share/zsh/site-functions/_glow
install -Dm644 glow.fish $PKG/usr/share/fish/vendor_completions.d/glow.fish

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/glow.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Markdown Reader
GenericName=Document Viewer
Comment=Read Markdown, rendered
Exec=glow %F
Icon=x-office-document
Terminal=true
Categories=Office;Viewer;Utility;
Keywords=markdown;md;readme;render;glow;
EOF
chmod 644 "$PKG/usr/share/applications/glow.desktop"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/glow, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf glow-3.0.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/glow, and runs the triggers its paths call for.

Contents

Installed programs: glow.

Installed directories: /usr/share/licenses/glow.

Short descriptions

glow Render markdown on the CLI, with pizzazz!

Notes

glow is a pure Go program, built with cgo off from a vendor bundle, glow-vendor-<version>.tar.xz, which ports/fetch makes with go mod vendor; see Vendoring.

glow man writes the manual page with mango, which dates the page’s header with the day it runs, so two builds of the port on different days install different glow.1 files. The sed after it deletes any terminal colour sequence from the page.