Bring MOTD to macOS
Table of Contents
• 1. Messages of the Day (motd)
• 2. Create the Message
• 3. Load the Message
1. Messages of the Day (motd)
A message of the day is, in computer terms, a welcome message that provides information and may help users logging onto the system. This is useful for numerous reasons, depending on the system, such as community announcements, compliance requirements, contextual information for that system, etc.
In this post, I'll be walking through a simple way to generate a message of the day for macOS. You can see the end result in this screenshot below:
Figure 1: macOS message of the day
For an example of a system-provided motd, here's the motd on my Ubuntu server showing the server's default information and any relevant add-ons, such as the LAN cockpit URL:
Figure 2: Ubuntu message of the day
2. Create the Message
First, we need to create the message. In this example, I've created a custom shell script below that uses terminal formatting to generate a structured output. This script checks for:
• username
• hostname
• profile management
• WiFi SSID
• IP address
• Mullvad status
• battery status
• uptime
To do this, create a script in your user directory:
Then paste the content below and modify as needed:
Finally, modify the script file to enable execution:
3. Load the Message
At this point, the script is ready. We simply need to tell macOS to execute it whenever the user launches a new shell.
To do this, open the .zprofile file and add a line referencing the script:
All done! This method is easily customizable and allows for use of dotfile management systems, such as stow, since the files live in the user's home directory.