The /etc/motd
file is simply cat
'd to the terminal, and more than likely the terminal supports ANSI color escape sequences. You can embed that using (not quite any) many text editors. However the essential part is inserting (and keeping track) of the escape character (usually entered as a control[
on the keyboard). According to nano's documentation,
All keys, with the exception of Control and Meta key sequences, will enter text into the file being edited.
That exception seems to apply to the escape character. Reading further, it says that any character can be entered by typing escape twice, then entering its decimal value (27 for escape). But that does not work for the machine where I am typing. Perhaps it works for you, perhaps not.
You could work around that by reserving some relatively useless character (such as #
) to act as the escape and then using tr to translate to/from, e.g.,
tr '\033' '#' /etc/motd >/tmp/motd
nano /tmp/motd
tr '#' '\033' /tmp/motd >/etc/motd
Doing that, bold text would be something like
#[1mBOLD#[0m
(\033 is the escape character, of course - some people prefer \x1b).