Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 4th August 2009, 10:33 AM
dariyoosh's Avatar
dariyoosh Offline
Registered User
 
Join Date: Jan 2008
Posts: 44
windows_xp_2003firefox
Question A question about background/foreground colors of the terminal

Dear all,


I'm working with a system without any graphic interface, nither GNOME nor KDE has been
installed, It is 100% text-based. I would like to ask whether there is a command to be typed in
the terminal allowing to change the background and foreground colors permanently?


Thanks in advance,

Dariyoosh
Reply With Quote
  #2  
Old 4th August 2009, 11:26 AM
RupertPupkin's Avatar
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 4,613
linuxfirefox
Use the setterm command:
Code:
setterm -background blue -foreground yellow
Read the man page (man setterm) for the available colors. You could put that command in /etc/profile or /etc/rc.d/rc.local to make it permanent for all users, or in your ~/.bash_profile if it's just for you.

I think the default console terminal type only provides 8 colors. If you use something like xterm-256color as your terminal type (export TERM=xterm-256color) you'll get more colors, though I'm not sure how setterm would use them. You can always see how many colors are available in your terminal by typing "tput colors". The colors will probably look better if you're using a console framebuffer.
Reply With Quote
  #3  
Old 4th August 2009, 12:35 PM
Gödel's Avatar
Gödel Offline
Registered User
 
Join Date: Jul 2009
Location: London,England
Posts: 1,095
linuxfedorafirefox
setterm colors may get reset as soon as you issue a command like ls or man. Another way to change colors is to directly issue ansi escape sequences, you can put the command in ~/.bash_profile when satisfied (after changing colours you can do ctrl-L to clear the screen)

standard white on black:
Code:
echo -en '\E[0;37;40m\E[8]'
bright/bold white on black:
Code:
echo -en '\E[1;37;40m\E[8]'
black on white:
Code:
echo -en '\E[0;30;47m\E[8]'
green on black:
Code:
echo -en '\E[0;32;40m\E[8]'

Basically, in \E[X;Y;Zm, X is the attribute (bold, reverse etc), Y is foreground, Z is background

there's a color table in the links below

http://linuxgazette.net/issue65/padala.html
http://en.wikipedia.org/wiki/ANSI_escape_code#Examples
Reply With Quote
  #4  
Old 4th August 2009, 01:01 PM
dariyoosh's Avatar
dariyoosh Offline
Registered User
 
Join Date: Jan 2008
Posts: 44
windows_xp_2003firefox
Dear RupertPupkin's and dear Gödel


Thank you very much both of you for your helpful answers
which solved my problem.

As RupertPupkin's indicated I typed

Code:
setterm -background white -foreground black

And I obtained the desired colors.


As Gödel indicated I added the following line to ~/.bash_profile
in order to have these colors permanently.

Code:
echo -en '\E[0;30;47m\E[8]'

Thank you very much for your help.


Kind Regards,
Dariyoosh
Reply With Quote
  #5  
Old 4th August 2009, 04:29 PM
Gödel's Avatar
Gödel Offline
Registered User
 
Join Date: Jul 2009
Location: London,England
Posts: 1,095
windows_xp_2003opera
The setterm command is easier to use, and from reading the man page I notice you can specify '-store' to make the colour combination the default.

That's also what the 'ESC [8]' sequence '\E[8]' does in the examples above, it's specific to linux consoles (see 'man console_codes')

Quote:
...
Linux Console Private CSI Sequences

The following sequences are neither ECMA-48 nor native VT102. They are native to the Linux console
driver. Colors are in SGR parameters: 0 = black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta,
6 = cyan, 7 = white.

ESC [ 1 ; n ] Set color n as the underline color
ESC [ 2 ; n ] Set color n as the dim color
ESC [ 8 ] Make the current color pair the default attributes.
ESC [ 9 ; n ] Set screen blank timeout to n minutes.
ESC [ 10 ; n ] Set bell frequency in Hz.
ESC [ 11 ; n ] Set bell duration in msec.
ESC [ 12 ; n ] Bring specified console to the front.
ESC [ 13 ] Unblank the screen.
ESC [ 14 ; n ] Set the VESA powerdown interval in minutes.

...
With seterm you can specify '-store' to get the same result

Code:
setterm -foreground green -background black -store
is the same as

Code:
setterm -foreground green -background black && echo -en '\E[8]'
Reply With Quote
Reply

Tags
background or foreground, colors, question, terminal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Background colors e16647 Using Fedora 4 18th September 2008 10:01 AM
Nautilus background colors jimgeorge Using Fedora 7 3rd January 2008 01:39 AM
F8: Background that changes colors? rweed Using Fedora 8 10th November 2007 06:14 PM
Foreground background no longer supported gnome terminal galahand Fedora Focus 12 10th March 2006 10:33 AM
How to print background colors from Epiphany? fjleal Using Fedora 0 27th March 2005 11:26 AM


Current GMT-time: 08:20 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat