LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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

Reply
 
Search this Thread
Old 07-16-2007, 09:55 PM   #1
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
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.
 
Old 07-16-2007, 10:14 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,770

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
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.

Last edited by bigrigdriver; 07-16-2007 at 10:22 PM.
 
1 members found this post helpful.
Old 07-16-2007, 10:16 PM   #3
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
You could use alias to make `ls` always run `ls -color=always`
Code:
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:
Code:
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.
 
Old 07-16-2007, 10:18 PM   #4
marco18
Member
 
Registered: Jul 2007
Location: Argentina
Distribution: Ubuntu 13.04 , Debian Lenny 5.0.7
Posts: 223

Rep: Reputation: 21
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!
 
Old 07-16-2007, 11:00 PM   #5
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Original Poster
Rep: Reputation: 90
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.
 
  


Reply


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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 10:35 AM
So many errors when I typed the "make" and "make install" command Niceman2005 Linux - Software 23 07-22-2009 02:33 PM
C Drive "/dev/hda1" accidently used in dd command at "of=" switch M D Linux - Software 4 04-26-2007 08:56 AM
"NIM thread blocked" & "Deadman Switch (DMS) close to trigger" errors sosborne Linux - Networking 1 06-28-2006 02:07 PM


All times are GMT -5. The time now is 05:16 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration