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 23rd October 2009, 08:47 PM
infernosoft Offline
Registered User
 
Join Date: Jan 2008
Age: 22
Posts: 367
linuxfedorafirefox
Changing terminal colors

I've noticed that certain bash applications are customized in a way that let's certain things, like the 'username@hostname' part be in a different color.

How is this done?



P.S. I hope this makes sense
Reply With Quote
  #2  
Old 23rd October 2009, 09:17 PM
Gödel's Avatar
Gödel Offline
Registered User
 
Join Date: Jul 2009
Location: London,England
Posts: 1,095
linuxfedorafirefox
You can use escape codes, eg blue text on grey background:

Code:
echo -e "\033[47m\033[34m" "hello" "\033[0m"
The code sequences after the first two "\033" are for background and foreground respectively, use the table generated by this script (from a bash tutorial site I've forgotten) to choose:

Code:
#!/bin/bash

# prints a color table of 8bg * 8fg * 2 states (regular/bold)
echo
echo Table for 16-color terminal escape sequences.
echo Replace ESC with \\033 in bash.
echo
echo "Background | Foreground colors"
echo "---------------------------------------------------------------------"
for((bg=40;bg<=48;bg++)); do
	for((bold=0;bold<=1;bold++)) do
		echo -en "\033[0m"" ESC[${bg}m   | "
		for((fg=30;fg<=37;fg++)); do
			if [ $bold == "0" ]; then
				echo -en "\033[${bg}m\033[${fg}m [${fg}m  "
			else
				echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m"
			fi
		done
		echo -e "\033[0m"
	done
	echo "--------------------------------------------------------------------- "
done

echo
echo
Attached Thumbnails
Click image for larger version

Name:	bashcolors.png
Views:	135
Size:	85.2 KB
ID:	18277  

Last edited by Gödel; 23rd October 2009 at 09:19 PM.
Reply With Quote
  #3  
Old 23rd October 2009, 09:41 PM
Min Offline
Registered User
 
Join Date: Jun 2009
Location: Melbourne
Posts: 246
linuxfedorafirefox
Edit -> Profile preferences -> color. For the one who doesn't like CLI
__________________
Macbook aluminum 5,1
Snow Leopard, Constantine, Seven
Reply With Quote
  #4  
Old 24th October 2009, 01:25 AM
RupertPupkin's Avatar
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 4,621
linuxfirefox
Quote:
Originally Posted by Min View Post
Edit -> Profile preferences -> color. For the one who doesn't like CLI
I don't see any "Edit" option in my mrxvt terminal.
Reply With Quote
  #5  
Old 24th October 2009, 04:14 AM
infernosoft Offline
Registered User
 
Join Date: Jan 2008
Age: 22
Posts: 367
linuxfedorafirefox
I think there is a misunderstanding as to what I'm asking. I wanted specific things colored in my terminal, like this (ie. the username is colored differently):

http://cache.gawker.com/assets/image...BackTrack1.png

Does that make better sense? Sorry.
Reply With Quote
  #6  
Old 24th October 2009, 04:35 AM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,108
linuxfedorafirefox
You do it this way:

PS1="\033[01;31m test \033[0m"

and put the username instead of "test". The PS1 environment variable is the primary prompt. There is also a
secondary and tertiary (PS2 and PS3) used for continuation lines of commands.

Check the man page on bash for some details. The first escape sequence sets the color, the second one resets.
Reply With Quote
  #7  
Old 24th October 2009, 05:05 AM
infernosoft Offline
Registered User
 
Join Date: Jan 2008
Age: 22
Posts: 367
linuxfedorafirefox
Quote:
Originally Posted by jpollard View Post
You do it this way:

PS1="\033[01;31m test \033[0m"

and put the username instead of "test". The PS1 environment variable is the primary prompt. There is also a
secondary and tertiary (PS2 and PS3) used for continuation lines of commands.

Check the man page on bash for some details. The first escape sequence sets the color, the second one resets.
Sweet. That works, now how can I set it so that it is like that when I open the terminal?
Reply With Quote
  #8  
Old 24th October 2009, 05:17 AM
Hlingler's Avatar
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,289
linuxopera
Everything you always wanted to know about CLI prompts (and more) but were afraid to ask: http://www.understudy.net/custom.html

V
Attached Thumbnails
Click image for larger version

Name:	custom-prompt.jpg
Views:	52
Size:	19.9 KB
ID:	18278  

Last edited by Hlingler; 24th October 2009 at 05:41 AM.
Reply With Quote
Reply

Tags
changing, colors, 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
Changing panel colors? Cassanova Using Fedora 0 14th August 2009 07:45 PM
How do you like your terminal colors? Tux_in_Redhat Wibble 9 27th January 2007 02:20 AM
Changing colors in terminal galahand Using Fedora 17 12th April 2006 11:06 AM
Changing Grub Colors weaved Using Fedora 4 2nd March 2005 05:31 AM
Colors in Terminal? carlwill Using Fedora 4 18th February 2005 04:18 AM


Current GMT-time: 03:26 (Saturday, 25-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