-   Linux - General (
-   -   Make "ls" command show colors without "--color=always" switch (

SharpyWarpy 07-16-2007 10:55 PM

Make "ls" command show colors without "--color=always" switch
I've been playing around with ls's --color=always option, it's very handy to sort files on the command line this way, but I don't like having to type it every time. So I thought I'd do LS="--color=always" to put it in the environment, but it doesn't work that way, even with
export LS="--color=always"
so how can I get this to do what I want? Thanks.

bigrigdriver 07-16-2007 11:14 PM

Edit the user .bashrc file (~/.bashrc) to add an alias: alias lc="ls --color=always". Then give the command: source .bashrc. That will reload .bashrc.

Lc is just an example. Make it whatever you want.

cs-cam 07-16-2007 11:16 PM

You could use alias to make `ls` always run `ls -color=always`

alias ls="ls --color=always"
.. or do you have either /etc/DIR_COLORS or ~/.dir_colors? Not sure if it's a distro thing or not but I have /etc/DIR_COLORS which is referenced in my ~/.bashrc file like so:

eval $(dircolors -b /etc/DIR_COLORS)
The dircolors app uses the file contents to create a shell variable and export it so ls always uses the color.

marco18 07-16-2007 11:18 PM

To do so try this:
- in your .bashrc file (located in /home/USER/ if it is not there, create it) add the following line

alias ls="ls --color=always"

- save the file
- maybe restart (i don't remember if that was necessary)

That should make it... Good luck!

SharpyWarpy 07-17-2007 12:00 AM

Okay, thanks guys for the replies. I've used alias lots, don't know why I didn't think of that. Just goes to show you two heads are better than one. Thanks again.

All times are GMT -5. The time now is 12:26 PM.