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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
03-10-2007, 08:04 AM
|
#1
|
Member
Registered: Feb 2006
Distribution: slackware 11
Posts: 110
Rep:
|
login shell, 'ls', and LS_COLORS
hello, im trying to change the default colors of certain file types in the login shell, using the dircolors program, and the 'LS_COLORS' environment variable, but im getting really confused
I ran 'dircolors --print-database > ~/.dir_colors', to create a configuration file in my home dir.
then i added these lines to my .bashrc file :
'LS_COLORS="dircolors -b $HOME/.dir_colors"
alias_ls='ls -hF --color=tty'
However, when i log out and back in agin, and i issue the 'ls' command, i get the error 'ls: unparsable value for LS_COLORS environment variable.'
additional information:
i have given ~/.dir_colors RWX permissions.
the login shell has access to the same commands as those in the .bashrc file, by use of the source command within ~/.bash_profile
Last edited by soldan; 03-10-2007 at 08:07 AM.
|
|
|
03-10-2007, 08:17 AM
|
#2
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
First you have to understand that some distributions do not follow the traditional log in sequence. I believe that Slackware is very traditional so you shouldn't have any problems.
You can create a file /etc/bash.bashrc.local and it should be run by all interactive login sessions that use the bash shell. You can put your specific login commands there.
Or, you can create a file $HOME/.bashrc in any user account home directory. That will be run after the files in /etc and after the file $HOME/.profile.
The environment variable LS_OPTIONS will control the default output format of the ls command. My LS_OPTIONS variable is set to this value.
Code:
LS_OPTIONS="-b --color=auto"
This will use the file /etc/DIR_COLORS to determine the colors to display. You can create a file $HOME/.dircolors to override the settings in /etc/DIR_COLORS. (I'm pretty sure that the "dir colors" file in $HOME is called .dircolors but I'm not sure. I haven't played with the dir colors for a long time.)
Last edited by stress_junkie; 03-10-2007 at 08:19 AM.
|
|
|
03-10-2007, 09:27 AM
|
#3
|
Member
Registered: Feb 2006
Distribution: slackware 11
Posts: 110
Original Poster
Rep:
|
stress junkie, i have replaced this line :
'LS_COLORS="dircolors -b $HOME/.dircolors"
with this line:
eval 'dircolors ~/.dir_colors'
this seems to work (at least partially), as when i change the folder color entry in the '~/.dir_colors' file, and then log out and log back in again, the folder color changes from blue to yellow (or whatever i want it to be), however, if i try to change the .mp3 extension color i cannot, it refuses to change from green
here is my ~/.dir_colors file:
Quote:
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cygwin
TERM dtterm
TERM putty
TERM xterm
TERM xterm-color
TERM xterm-debian
TERM rxvt
TERM screen
TERM screen-bce
TERM screen-w
TERM vt100
TERM Eterm
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
# image formats
.jpg 01;35
.jpeg 01;35
.gif 01;35
.bmp 01;35
.pbm 01;35
.pgm 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.tiff 01;35
.png 01;35
.mov 01;35
.mpg 01;35
.mpeg 01;35
.avi 01;35
.fli 01;35
.gl 01;35
.dl 01;35
.xcf 01;35
.xwd 01;35
# audio formats
.flac 01;35
.mp3 01;34
.mpc 01;35
.ogg 01;35
.wav 01;35
|
Last edited by soldan; 03-10-2007 at 09:29 AM.
|
|
|
03-10-2007, 10:30 AM
|
#4
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
Have you logged off and then on again after making the change?
I read the man page for dir_colors and it looks like you did that also. You should also read the first few lines in /etc/DIR_COLORS. Other than that I would just say to log off or at least open a new terminal window after you make a change.
|
|
|
03-11-2007, 08:12 AM
|
#5
|
Member
Registered: Feb 2006
Distribution: slackware 11
Posts: 110
Original Poster
Rep:
|
SJ i worked it out \o/ but im still drunk from last night, so i will post how i did it later, i dont know why im writng this post now 
|
|
|
03-21-2007, 06:36 PM
|
#6
|
LQ Newbie
Registered: Jun 2004
Location: Waterloo, ON
Distribution: Slackware, (Redhat)
Posts: 1
Rep:
|
quotes vs. backticks
What you did wrong was instead of this in your ~/.bashrc:
LS_COLORS="dircolors -b $HOME/.dir_colors"
you needed this:
LS_COLORS=`dircolors -b $HOME/.dir_colors`
UNIX shell strings can be enclosed by the apostrophe ('), the quote ("), or the backtick (`). The apostrophe uses the string verbatim, the quote substitutes any variables (i.e. $HOME) with their value, and the backtick executes the string as a command and returns the result.
I did it with the backticks and it worked fine.
|
|
|
All times are GMT -5. The time now is 12:02 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|