# Colored pre-login text



## shuxuef (Jul 31, 2012)

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!


----------



## UNIXgod (Jul 31, 2012)

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:


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


----------



## shuxuef (Jul 31, 2012)

UNIXgod said:
			
		

> /etc/issue did you mean motd()?
> 
> I have a welcome message in my shell's rc file which is in color.
> 
> ...



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.


----------



## ph0enix (Aug 3, 2012)

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:

```
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.


----------



## wblock@ (Aug 3, 2012)

UNIXgod said:
			
		

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



FreeBSD's echo(1) does not understand most useful string escapes.  Use printf(1), and use \033 for the escape character:

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


----------



## shuxuef (Aug 3, 2012)

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:
> 
> ...



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.


----------



## UNIXgod (Aug 3, 2012)

wblock@ said:
			
		

> FreeBSD's echo(1) does not understand most useful string escapes.  Use printf(1), and use \033 for the escape character:
> 
> ```
> printf "\033[1;37mWelcome to the\033[0m \033[1;36m`hostname | tr '[a-z]' '[A-Z]'` UNIX SERVER\033[0m!"
> ```



Very cool!


----------

