Colored pre-login text

Hi,

By editing the file /etc/issue, one can change the pre-login message. Does anyone know how to make it use different colors for the text? I just thought it might be useful to highlight some keywords. Thanks!
 
shuxuef said:
Hi,

By editing the file /etc/issue, one can change the pre-login message. Does anyone know how to make it use different colors for the text? I just thought it might be useful to highlight some keywords. Thanks!

/etc/issue did you mean motd()?

I have a welcome message in my shell's rc file which is in color.

You can do colors with escaping. Here is an example:

Code:
echo -e "\e[1;37mWelcome to the\e[0m \e[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\e[0m"!
echo
 
UNIXgod said:
/etc/issue did you mean motd()?

I have a welcome message in my shell's rc file which is in color.

You can do colors with escaping. Here is an example:

Code:
echo -e "\e[1;37mWelcome to the\e[0m \e[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\e[0m"!
echo

Thanks!

But yes, I do mean /etc/issue. The one that's quoted by /etc/gettytab for the message before the login prompt, not after. And the escaping doesn't seem to work.
 
shuxuef said:
Thanks!

But yes, I do mean /etc/issue. The one that's quoted by /etc/gettytab for the message before the login prompt, not after. And the escaping doesn't seem to work.

I bet it works. What happens when you just copy and paste the line posted by UNIXGod into a terminal window (assuming your terminal is color capable)?

In order to insert the escape sequences into a file, you need to do something like this:
Code:
echo -e "\e[1;37mWelcome to the\e[0m \e[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\e[0m"! >>/path/to/file
...instead of editing the file in a text editor and pasting them in.

Hope this helps!

J.
 
UNIXgod said:
You can do colors with escaping. Here is an example:

Code:
echo -e "\e[1;37mWelcome to the\e[0m \e[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\e[0m"!
echo

FreeBSD's echo(1) does not understand most useful string escapes. Use printf(1), and use \033 for the escape character:
Code:
printf "\033[1;37mWelcome to the\033[0m \033[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\033[0m!"
 
ph0enix said:
I bet it works. What happens when you just copy and paste the line posted by UNIXGod into a terminal window (assuming your terminal is color capable)?

In order to insert the escape sequences into a file, you need to do something like this:
Code:
echo -e "\e[1;37mWelcome to the\e[0m \e[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\e[0m"! >>/path/to/file
...instead of editing the file in a text editor and pasting them in.

Hope this helps!

J.

Ah... I am using tcsh... no wonder it is not working! One can also edit the file using vim and ^+v+[ to enter escapes.

Thanks, it is working now.
 
Back
Top