LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-22-2008, 02:49 PM   #1
questsal
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Rep: Reputation: 0
Question Adding colors to a script


Hi,

I am trying to change foreground and background for my script in BASH.
But for some reason it's not working from the script.
Here is the code I am using and it works from the command line:
$( export PS1="\e[44;37m\w> \e[0m")
I have tried the following, still no luck!!
echo -e "\e[32;40m\w> \e[0m"

Your help will be appreciated!!
 
Old 10-23-2008, 08:18 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Here's one example taken from slackupdate:
http://darklinux.net/slackupdate/

Code:
    C_Warning="\\033[1;33m"
    C_Error="\\033[1;31m"
    C_Ok="\\033[1;32m"
    C_End="\\033[0;00m"
    C_Info="\\033[36;40m"

echo -e -n " [${C_Ok}Downloading${C_End}]"
echo -e -n " [${C_Warning}Already Downloaded${C_End}]"
echo -e -n " [${C_Error}MD5 Mismatch${C_End}] [${C_Error}Deleting${C_End}]"
 
Old 10-24-2008, 11:17 AM   #3
grumpf
Member
 
Registered: Dec 2005
Distribution: just replace windows with linux
Posts: 38

Rep: Reputation: 15
yeek, better to use "tput" that will make sure that you can use it even with some wild terminals
and it is better to read
 
Old 10-24-2008, 04:22 PM   #4
questsal
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks mate! it works!!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
Script for adding users BlueStag Linux - General 3 03-14-2006 09:40 PM
problem changing X terminal colors with script shadowsnipes Slackware 5 10-10-2005 11:15 PM
ls -lsh script with colors not working Finlay Red Hat 2 08-13-2004 01:34 PM
Adding colors to your motd? herc Linux - Software 5 05-04-2004 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration