LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 03-30-2010, 03:33 PM   #1
harrisk2
LQ Newbie
 
Registered: Mar 2010
Location: Raleigh, NC
Distribution: Fedora
Posts: 2

Rep: Reputation: 0
Colors in gnome terminal??


I am using Fedora 8, gnome, a tcsh login shell, and I would like to have my directories and files color coded when I use ls. I have been searching the internet far and wide today looking for ways to do this. I have tried all the ways I could find: edit .bsrc file, edit DIR_COLORS, edit DIR_COLORS.xterm, create .dircolors, edit etc/profile, edit .cshrc file, alias ls --colors, and all combinations of this. I can't figure out what I am doing wrong.
I use su in my terminal I get the colors for ls. So there must be something up with my user profile? I have tried to edit my terminal profiles and my desktop themes... neither worked. Please help! I know this is a trivial issue, but now I am on a mission to figure this out. THANKS!
 
Old 03-30-2010, 04:52 PM   #2
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
alias ls='ls --color=auto'
 
Old 03-30-2010, 05:03 PM   #3
LouRobytes
Member
 
Registered: Mar 2010
Location: Nova Scotia, Canada
Distribution: Ubuntu & Fedora
Posts: 189

Rep: Reputation: 44
It is likely that your default shell for root is bash. When bash is invoked, a bunch of scripts in /etc/profile.d get run. This is where the alias that penguinator referred to is set. You need to make sure your ~/.tcshrc executes the same scripts.

Cheers, Lou

EDIT: Or you could just add the alias to your ~/.tcshrc file.

Last edited by LouRobytes; 03-30-2010 at 05:14 PM. Reason: Added extra line
 
Old 03-30-2010, 05:12 PM   #4
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Oh, yes... tcsh, not bash: alias ls 'ls --color=auto'
 
Old 04-01-2010, 12:24 PM   #5
harrisk2
LQ Newbie
 
Registered: Mar 2010
Location: Raleigh, NC
Distribution: Fedora
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you!
I put alias ls 'ls --color' in my .cshrc file.
I got it to work, but now the colors are so annoying I want to change them. Can I do this using etc/DIR_COLORS? Or since I'm not using bash do I need to do something different?
 
Old 04-01-2010, 12:41 PM   #6
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Have a look at the man page for the dircolors command.
 
Old 06-01-2010, 06:06 PM   #7
iPenguin
LQ Newbie
 
Registered: Sep 2008
Posts: 12

Rep: Reputation: 2
The follow describes ls colors settings methods.

To set the standard ls colors for various items see the file: /etc/DIR_COLORS
If the file does not exist, then issue { $ dircolors -p > /etc/DIR_COLORS }.

When you have edited DIR_COLORS to your specs, saved/exited file,
issue { $ dircolors -c } for csh or { $ dircolors -b } for bash,
then to copy/paste by mouse { L-click the top line, R-click the bot line },
then { shift-insert } to command line to execute the color codes and command.

To make a permanent solution you can add your color codes to { ~/.bashrc },
where you copy the same code and command, paste to the end of your .bashrc file,
save/exit file.

For ease, { $ alias l='ls -aFH --color' }, { $ alias ll='ls -laFH --color' }.

Mans: { $ man dircolors } and { $ man ls }.
 
1 members found this post helpful.
Old 06-01-2010, 06:24 PM   #8
iPenguin
LQ Newbie
 
Registered: Sep 2008
Posts: 12

Rep: Reputation: 2
I was really bored one day and made an interesting color code script.

A color reference script, you can use the color codes for colorized bash scripts. The numbers relate to the numbers used in the { /etc/DIR_COLORS } file.

The code page, fonts may affect the display of special symbols, but otherwise the color codes should display correctly.

You can copy codes directly from the less pager display for use in a file.

NOTES:
The { \033 } is the escape character,
{ [ } begins the color code number sequence,
{ 31 } is code for a red foreground text color,
{ m } ends the color code,
{ Text } is any ascii text,
Then the remaining color code sequence { \033[0m } switches colors off.
{ \033[31m Text \033[0m }

You can also hard code the escape characters { \033 }, at least in vi,
by pressing ctrl-v, let go the keys, then press the escape key for its code, then escape key again to release the input, or continue with typing.

#!/bin/sh
#
# file: color1.sh
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# MAKE A TABLE SHOWING COLOR ENCODING OPTIONS AND CODE #
# #
# The code can be used in bash scripts for enhancement #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Requirements #
# #
# - bash to run the script #
# - md5sum to create a unique tmp file name #
# - /dev/null to create an empty tmp file #
# - cat to create the tmp file #
# - /tmp place for to create the tmp file #
# - echo to process data and create the tmp file #
# - less to display the tmp file #
# - rm to remove the tmp file after viewing #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


# make an empty tmp file and give it a funny (ahem, unique) name
hash=`date +%M%S | md5sum`
tfile="/tmp/tf${hash:0:8}"
cat /dev/null > "$tfile"


# make spaces and dashes
sp=" "
dsh="- "
for i in `seq 1 100`; do dsh="${dsh}- "; sp="${sp} "; done;


# cls for testing
# echo -ne "\033c"


# text heading for section 1
echo " | fg colors ${sp:0:11} | Inverse fg colors ${sp:0:4} | Bold text ${sp:0:14} |" >> "$tfile"
echo "${dsh:0:79}" >> "$tfile"

# for symbol strings
sym1=""
sym2=""
sym3=""
sym4=""
sym5=""
sym6=""
sym7=""
sym8=""
sym9=""

# make strings of special symbols
for i in `seq 1 8`
do

sym1="${sym1}\0215" # block
sym2="${sym2}\0225" # dot
sym3="${sym3}\0240" # blank
sym4="${sym4}\0260" # small degree
sym5="${sym5}\0267" # small dot
sym6="${sym6}\0200" # seahorse
sym7="${sym7}\0244" # mine
sym8="${sym8} " # space
sym9="${sym9}\0245" # martian

done



# # # # # # # # # # # # # # # # # # # # # # #
# CREATE THE TABLE OF COLOR ENCODING #
# #
# 5 SECTIONS EACH IN A OUTER LOOP SEQUENCE #
# # # # # # # # # # # # # # # # # # # # # # #


# # # # # # # # # # # # # # #
# BEGIN 2 LOOPS SECTION #
# # # # # # # # # # # # # # #

# outside loop
for n in `seq 1 6`
do

# inside loop
for i in `seq 0 8`
do


# COMMON PARTICIPLE
# - - - - - - - - - - - -

# no color
nc="\033[0m"


# LOOP 1 PARTICIPLES
# - - - - - - - - - - - -

# fg colors
fg="\033[3${i}m"

# inverted fg bg colors
f2="\033[3${i};7m"

# bold text
f3="\033[3${i};1m"


# LOOP 2 PARTICIPLES
# - - - - - - - - - - - -

# bolder text
f4="\033[3${i};5m"

# underline text
f5="\033[3${i};4m"


# LOOP 3 PARTICIPLES
# - - - - - - - - - - - -

# bg colors
bg="\033[4${i}m"

# inverse bg colors
b2="\033[4${i};7m"

# solid bg color
b3="\033[4${i};3${i}m"

# LOOP 4 PARTICIPLES
# - - - - - - - - - - - -

# combinations of fg and bg

# fg colors on blue bg
cm="\033[3${i};44m"

# inversed white fg with inv bg colors
c2="\033[37;4${i};7m"

# inversed grey fg with inv bg colors
c3="\033[38;4${i};7m"


# LOOP 5 PARTICIPLES
# - - - - - - - - - - - -

# more combinations of fg and bg

# inverse fg colors on white bg
d1="\033[3${i};47;7m"

# inverse fg colors on yellow bg and bold and underline
d2="\033[3${i};43;7;1;4m"

# inverse fg colors on yellow bg and bold (bold ghost print)
d3="\033[3${i};4${i};7;1m"


# LOOP 6 PARTICIPLES
# - - - - - - - - - - - -

# yet more combinations of fg and bg

# bold fg and bg
e1="\033[3${i};4${i};1m"

# bold fg and bg and underline spaces
e2="\033[3${i};4${i};1;4m"

# special symbols
e3="\033[38;47;7m"

# LOOP PASS 1
# - - - - - - - - - - - - - -
if [ "$n" -eq 1 ]
then
# display table row 1 contents (9 lines of examples)
echo -e "$((i+1)).\
$fg \\$fg Text \\$nc $nc \
$f2 \\$f2 Text \\$nc $nc \
$f3 \\$f3 Text \\$nc $nc \
" >> "$tfile"
# - - - - - - - - - - - - - -
fi


# LOOP PASS 2
# - - - - - - - - - - - - - -
if [ "$n" -eq 2 ]
then

# text heading for table row 2 contents
if [ "$i" -eq 0 ]
then
echo "${dsh:0:79}" >> "$tfile"
echo " | Underlined text | ${sp:0:23} | Bolder text ${sp:0:11} |" >> "$tfile"
echo "${dsh:0:79}" >> "$tfile"
fi


# display table row 2 contents (9 lines of examples)
echo -e "$((i+1)).\
$f5 \\$f5 Text \\$nc $nc \
${sp:0:24}\
$f4 \\$f4 Text \\$nc $nc \
" >> "$tfile"
# - - - - - - - - - - - - - -
fi

# LOOP PASS 3
# - - - - - - - - - - - - - -
if [ "$n" -eq 3 ]
then

# text heading for table row 3 contents
if [ "$i" -eq 0 ]
then
echo "${dsh:0:79}" >> "$tfile"
echo " | bg Colors ${sp:0:11} | Inverse bg colors | Solid bg colors ${sp:0:8} |" >> "$tfile"
echo "${dsh:0:79}" >> "$tfile"
fi


# was toggling of row 1 and 9 but decided is better to show all results
if [ "$i" -ge 0 ] && [ "$i" -le 8 ]
then

# display table row 3 contents (9 lines of examples)
echo -e "$((i+1)).\
$bg \\$bg Text \\$nc $nc \
$b2 \\$b2 Text \\$nc $nc \
$b3 \\$b3 Text \\$nc $nc \
" >> "$tfile"
fi
# - - - - - - - - - - - - - -
fi

# LOOP PASS 4
# - - - - - - - - - - - - - -
if [ "$n" -eq 4 ]
then

# text heading for table row 4 contents
if [ "$i" -eq 0 ]
then
echo "${dsh:0:88}" >> "$tfile"
echo " | fg on blue bg ${sp:0:9} | Inv white fg on bg colors | Inv grey fg on bg colors |" >> "$tfile"
echo "${dsh:0:88}" >> "$tfile"
fi


if [ "$i" -ge 0 ] && [ "$i" -le 8 ]
then

# display table row 4 contents (9 lines of examples)
echo -e "$((i+1)).\
$cm \\$cm Text \\$nc $nc \
$c2 \\$c2 Text \\$nc $nc \
$c3 \\$c3 Text \\$nc $nc \
" >> "$tfile"
fi
# - - - - - - - - - - - - - -
fi

# LOOP PASS 5
# - - - - - - - - - - - - - -
if [ "$n" -eq 5 ]
then

# text heading for table row 5 contents
if [ "$i" -eq 0 ]
then
echo "${dsh:0:96}" >> "$tfile"
echo " | Inv fg colors on white bg | Inv fg cols on yellow bg UL B | Inverted Bold Ghost ${sp:0:8} |" >> "$tfile"
echo "${dsh:0:96}" >> "$tfile"
fi


# control of displayed lines
if [ "$i" -ge 0 ] && [ "$i" -le 8 ]
then


# display table row 5 contents (9 lines of examples)
echo -e "$((i+1)).\
$d1 \\$d1 Text \\$nc $nc \
$d2 \\$d2 Text \\$nc $nc \
$d3 \\$d3 Text \\$nc $nc \
" >> "$tfile"
fi
# - - - - - - - - - - - - - -
fi

# LOOP PASS 6
# - - - - - - - - - - - - - -
if [ "$n" -eq 6 ]
then

# text heading for table row 6 contents
if [ "$i" -eq 0 ]
then
echo "${dsh:0:97}" >> "$tfile"
echo " | non-inverted Bold Ghost | Underlined Blocks of Spaces | Special Symbols on grey |" >> "$tfile"
echo "${dsh:0:97}" >> "$tfile"
fi


# control of displayed lines
if [ "$i" -ge 0 ] && [ "$i" -le 8 ]
then


tstr=""
case "$i" in
0) tstr="$sym1"; ;;
1) tstr="$sym2"; ;;
2) tstr="$sym3"; ;;
3) tstr="$sym4"; ;;
4) tstr="$sym5"; ;;
5) tstr="$sym6"; ;;
6) tstr="$sym7"; ;;
7) tstr="$sym8"; ;;
8) tstr="$sym9"; ;;
esac


# display table row 6 contents (9 lines of examples)
echo -e "$((i+1)).\
$e1 \\$e1 Text \\$nc $nc \
$e2 \\$e2 ${sp:0:6} \\$nc $nc \
$e3 \\$e3 $tstr \\$nc $nc \
" >> "$tfile"
fi
# - - - - - - - - - - - - - -
fi

done
done
# END OF ALL THE LOOPS -yay



# PRINT END DASHES AND NL
echo "${dsh:0:97}" >> "$tfile"
echo -e "\n" >> "$tfile"


# show the file in less so it is scrollable
cat "$tfile" | less -r


# exit # testing: to bypass file cleanup


# cleanup : show tmp file name : display contents of /tmp
if [ -f "$tfile" ]
then
rm "$tfile"
#echo "Done, cleared tmp file $tfile from /tmp"
#echo "Done, cleared tmp file $tfile from /tmp; Dir List of /tmp is:"
#ls /tmp
fi


# EOF #
 
Old 09-02-2010, 12:43 PM   #9
explainer
LQ Newbie
 
Registered: Dec 2007
Distribution: Ubuntu 10.4
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by penguiniator View Post
alias ls='ls --color=auto'
Is that an answer?
 
Old 09-02-2010, 07:15 PM   #10
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Yes, it is. ls does the coloring of its own output. If you put that alias in your shell's startup file, ls will color its output every time you use it. You won't have to tell it to do so; the alias will do it for you.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminal Colors carlosinfl Debian 7 02-22-2008 04:41 AM
Terminal Colors chakkerz Linux - General 2 11-22-2004 09:01 PM
Gnome terminal colors... hjles Slackware 1 11-26-2003 10:29 PM
gnome-terminal colors as su teacup Slackware 2 05-10-2003 12:31 AM
using gnome terminal colors with pine rwlyons Linux - Software 0 03-05-2003 10:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

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

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