1

This is what I currently have. It displays black on bright white. However, I want to have blue (0;34m) on bright white.

^[[0;7;34;37;5mWelcome!^[[0m

I used this website as a reference, but I did not manage to get it working. Any help would be greatly appreciated.

Z0q
  • 549
  • 1
  • 5
  • 6

2 Answers2

1

I would advise not following those instructions. The motd is presented to all interactive logins, regardless of terminal type. This means that embedding control characters in the output is going to be wrong for at least one user, at least once.

If you feel you really must, then use tput to generate the correct codes for the user's terminal. That's much safer. For blue on white, use

tput setaf 4; tput setab 7
Toby Speight
  • 8,460
  • 3
  • 26
  • 50
1

The /etc/motd file is data (cannot contain a script, such as "echo -e"), and is presented to all logins irregardless of their actual terminal type. While you can do this for some configurations, the usual recommendation is that /etc/motd should be plain text (no escape sequences) because:

  • attempting to print colored text does not take into account whether the user's terminal can display the escape sequences,
  • the colors do not take into account the current (or default) foreground and background colors of the terminal, and
  • do not take into account that some logins may translate nonprinting characters to "readable" form.

If you really want to do this, you should be aware that

  • getting a particular background color depends upon the terminal,
  • the text background color is not necessarily the same (or even close) to the terminal's default background color,
  • some terminals color erased areas of the screen, such as when clearing the screen, using the current "ANSI colors", while other terminals do not.

Further reading:

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268