FedoraThis forum is for the discussion of the Fedora Project.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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
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?
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' }.
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
# 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
# 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
# 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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.