Skip to content

aremmell/macMOTD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

macMOTD

Dynamic MOTD (Message of the Day) for macOS.

If you're not familiar with MOTD, or what update-motd does on some *nix distributions, you should ask your friendly neighborhood LLM about it.

However, if you're feeling adventurous, here's the deal:

MOTD is a dynamically generated (usually, but can be static too) file that is sent to your terminal whenever you initiate an SSH or other login session. MOTD is awesome, and anyone who tells you otherwise simply doesn't know how to operate a computer.

This mechanism is what provides the information that you see when you log in to a remote server — details about the host name, uptime, OS, whether package updates are available, etc.

On macOS, there is no dynamic MOTD generation mechanism that I'm aware of (if you are aware of one, please let me know!). This implementation is simple: the primary zsh script (mac-motd) generates the necessary files and directories in preparation for use upon installation.

A cron-like task is enabled which periodically enumerates the zsh scripts in the MOTD update script folder (/etc/update-motd.d), and appends their output to the MOTD file, causing it to be rejuvenated.

Typically these scripts are given names like 10-header-hello. This is because when the scripts are executed, they are done so in ascending alphanumeric sort order — a script that starts with 1 will run before one that starts with 2, and so on. This ensures that the MOTD file always has its content in the correct order.

All of the output generated by these scripts (to stdout) is piped into the MOTD file, so all you have to do is generate useful output. If you use the default sample setup, implemented in ./update-motd.d/20-info-sample.zsh, you'll get the system uptime and the current date/time (or at least, the last time the MOTD was generated).

After many months of spending my time on various other things, I've finally got around to releasing version 1.1.1, which is stable and working for me on macOS Tahoe 26.4 (25E246).

  • macOS 12 (Monterey) or later
  • zsh (pre-installed on all supported macOS versions)
  • Root access or sudo

Clone the repo or download and extract a release tarball, then run macMOTD's install command from the repo root:

git clone https://github.com/aremmell/macMOTD.git
cd macMOTD
sudo ./mac-motd --install

This performs the following steps:

  1. mac-motd is copied to /usr/local/bin and its owner is set to root.
  2. All .zsh scripts in ./update-motd.d and its subdirectories are copied to /etc/update-motd.d and made executable by root.
  3. A Launch Daemon plist is written to /Library/LaunchDaemons, which runs mac-motd --generate every n seconds (default: 600 = 10 minutes).
  4. On each run, all executable .zsh scripts in /etc/update-motd.d are executed in ascending alphanumeric order and their output is written to the MOTD (/etc/motd). To regenerate the MOTD at any time, you can simply run sudo mac-motd -g.

There are useful utility functions in ./update-motd.d/motd-helpers/motd-base.zsh for easy printing of colored and stylized text in your MOTD scripts. See the sample scripts in ./update-motd.d to learn how to automatically 'include' these scripts in your own. Additionally, ./update-motd.d/motd-helpers/scratchpad.zsh contains a WIP collection of system utility functions for obtaining performance metrics, OS version information, memory and storage stats, and more. Polish is ongoing — contributions are welcome desperately needed.

sudo mac-motd --help
sudo mac-motd --uninstall [l|r|n]

You may choose how the scripts in /etc/update-motd.d are handled during uninstall:

  • [l]eave: leave all scripts in /etc/update-motd.d untouched (default)
  • [r]ename: rename them so they won't be executed, but still exist on disk
  • [n]uke: delete them irreversibly

Regardless of which option you choose, the Launch Daemon, global mac-motd script, and all other files generated during installation and operation will be deleted.

About

The missing Message of the Day (MOTD) terminal banner generator for macOS. Written in 100% zsh.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages