A Message of The Day (MOTD) banner is probably fairly familiar to those of us who SSH around, but how about a richly formatted message with colour and style?
This mini-guide explains how to add a richly formatted MOTD banner that is displayed to any user starting a new terminal session, whether over SSH or physically.
I recently moved my home server from a Dell R710 to a Raspberry Pi 4 and in the process I wanted to consolidate and version control as much configuration as possible as well as standardising how services are run (with Docker) and deployed (with GitHub Actions).
Most of that is probably a story for another post.
The repository contains a
README with guidance that is useful when managing the server and so I wanted to display it on login.
README is formatted with Markdown as is fairly standard, and while Markdown looks ok when
cat'd, it's still all the same colour and risks becoming a wall of text.
The image below shows both the content of the
README as well as how it looks when rendered directly by the terminal.
Enter glow which claims to "Render markdown on the CLI, with pizzazz!"
And it certainly does that:
It does plenty more too - you can browse and navigate markdown, as well as controlling styling options - full details can be found at: https://github.com/charmbracelet/glow
The final bonus - it is available through the majority of mainstream package managers either directly or via a repo, including on arm64 Debian/Ubuntu - perfect for the Pi.
I was keen to avoid scripts or solutions requiring compilation as some of the other options did.
Running on login
Starting a new session whether over SSH or physically is effectively a new login, even changing user with sudo/su is a new session.
A number of files can be executed on login including those in
/etc/profile.d/ and these apply to all users that have a shell that respects
So I have an executable file called
echo "Notes in: /home/paul/home-stack/README.md"
echos a bit of information and then renders the
README.md file with glow.
This is a fresh SSH login: