LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Make console text green (https://www.linuxquestions.org/questions/linux-newbie-8/make-console-text-green-4175417662/)

Dornith 07-19-2012 03:19 PM

Make console text green
 
I wanted to make the console text green on my Slackware machine. I found the command "setterm -foreground green", but I can't find any way to make it come up any sooner that the log-in, and after I do something like dir, it switches back. Is there any way to make the console green from the start and stay that way?

Kustom42 07-19-2012 03:21 PM

PS1 prompt I think is what you are looking for.

Heres some stuff on arch linux but it should translate to slackware without any modifications:

https://wiki.archlinux.org/index.php/Color_Bash_Prompt

Dornith 07-19-2012 03:49 PM

I don't know if that did anything or not since I already have it green partly so it might have been redundant, but it didn't fix either of my two problems. It's still white when loading and after I use dir.

Kustom42 07-19-2012 04:05 PM

I'm not sure I follow you..

Your PS1 prompt is specific to each user and is an environment variable associated with that shell. You would have to log out and log back in our source your .bashrc file for the changes to take effect.


Can you give us some example of where the colors are not displaying properly? You say when you use dir? What does that mean.

Dornith 07-19-2012 04:09 PM

It's while when it's loading all the information and up until the log in. Then, once I log in, it's green. But after I do a command, such as dir, the the text color switches back to white.

Kustom42 07-19-2012 04:20 PM

dir colors are set by another variable, LS_COLORS. See the dircolors man page for more info on that.

The boot information will be in the default prompt and will not be what you set for your users .bashrc PS1 prompt.

Dornith 07-19-2012 04:24 PM

I don't want to change the dir colors, I want it to not change after dir.

And I know that what I set for the users will not apply to the boot. That's why I'm posting this question asking what does.

Kustom42 07-19-2012 04:33 PM

The command dir uses its own variable to determine your colors. The LS_COLORS variable, it is not changing your PS1 prompt simply referencing a different variable.

I don't think you can modify the boot text color..

Dornith 07-19-2012 04:35 PM

Yes, it is. I'll have a green prompt, I type "dir" and press enter, it shows the directory, and from there on I have a white prompt.

TobiSGD 07-19-2012 04:48 PM

To get the kernel messages at boot in a different color you have to change a file in the kernel and recompile it. Search for the file vc.c in the kernel source tree. In that file, somewhere around the line 2865 you will find this line:
Code:

vc->vc_def_color      = 0x07;  /* white */
Change the 7 to 2 and recompile the kernel. If you boot this kernel you should get the kernel messages in green.
After the init-scripts take over, this will most likely revert this change, so you have to edit the init-scripts to get green output.

I don't know how to change the behavior for the change after commands, like ls, that change the colors themselves.

Dornith 07-19-2012 05:16 PM

Quote:

Originally Posted by TobiSGD (Post 4733131)
To get the kernel messages at boot in a different color you have to change a file in the kernel and recompile it. Search for the file vc.c in the kernel source tree. In that file, somewhere around the line 2865 you will find this line:
Code:

vc->vc_def_color      = 0x07;  /* white */
Change the 7 to 2 and recompile the kernel. If you boot this kernel you should get the kernel messages in green.
After the init-scripts take over, this will most likely revert this change, so you have to edit the init-scripts to get green output.

I don't know how to change the behavior for the change after commands, like ls, that change the colors themselves.

That is exactly what I was looking for. I can't find the vc.c file though (there's a lot of files here), do you know where I can find it?

Edit: Never mind. I figured out why my file search couldn't find it. It was set to only look in the home directory.

whizje 07-19-2012 05:21 PM

seems The wrong architecture :-(
Code:

bash-4.2$ slocate "/vc.c"
/usr/src/linux-3.4/arch/arm/mach-omap2/vc.c
/usr/src/linux-3.2.13/arch/arm/mach-omap2/vc.c


nixblog 07-19-2012 05:25 PM

The following has worked for Debian in the past by adding the following to /etc/rc.local,

Code:

echo -en "\\033[32m\\033[8]" > /dev/tty1
This will give you green text in tty1 at login - repeat for other ttys if necessary. You will need a restart for it to take effect if I remember rightly.

whizje 07-19-2012 05:31 PM

Found it.
Quote:

Originally Posted by TobiSGD (Post 4506712)
I found out that it is rather simple to change the color of the kernel messages (if you know how to compile a kernel). In your kernel source tree open the file drivers/tty/vt.c with a text editor and search for the function vc_init. inside it you will find the line
Code:

vc->vc_def_color      = 0x07;  /* white */
Change that to 0x02 instead, recompile the kernel and if you boot that kernel you will get green messages.
No I have to look if those colors can be customized, I want amber or at least something similar looking.


Dornith 07-19-2012 07:41 PM

Okay, I did a search of the folder where the Linux source files were and found no such vc.c.


All times are GMT -5. The time now is 11:05 AM.