Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


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

Rep: Reputation: 0
Question Adding colors to a script


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
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289
Here's one example taken from slackupdate:


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
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
LQ Newbie
Registered: Oct 2008
Posts: 4

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Linux Forums > Linux - General

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

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