Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-30-2003, 10:50 PM   #1
Registered: Nov 2003
Location: Pouganis -- a planet not too far from over there.
Distribution: Vector
Posts: 31

Rep: Reputation: 15
ls colors in xterm/rxvt/aterm

How do I get ls to always show colors in one of the terminals without always passing the --color arguement? I've already gone through DIR_COLORS and made sure each terminal I wanted was listed in the TERM area, and that the alias for ls had --color=always appended to it, but the terminals don't seem to want to use the alias. Colors work automatically in the terminal outside of X, but xterm, rxvt, and aterm don't want to do it. I've gone through the list of options for each for the last couple hours trying out different combinations to no avail.

Thanks .
Old 12-01-2003, 12:20 AM   #2
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Rep: Reputation: 30
Put an alias in your /home/.bashrc file like this:

scruff@dabasement:~$ cat .bashrc
alias ls='ls --color -a'
alias mv='mv -i'
alias rm='rm -i'

If you don't have a .bashrc file there, just create one.

There's also a file you can add it to to make this happen system-wide for all users, but I can't remember it right now...

Last edited by Scruff; 12-01-2003 at 12:38 AM.
Old 12-01-2003, 03:30 AM   #3
Senior Member
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
You may find that aliasing ls to always use the -a switch to show all files, including system files (beginning with a dot) can be quite counter-productive. At least that's what I feel. When I list my home dir with the -a switch the output goes on for pages, while when I do a regular list I get my few neat folders.

I generally use alias ls='ls --color -F'. The -F switch enables extra visual features - directory names get a slash appended, executable files get an asterisk appended and symlinks get an @ character appended. It's quite usable, especially if you sometimes use terminal types that do not support color.

Old 12-01-2003, 04:32 AM   #4
LQ Newbie
Registered: Sep 2003
Distribution: RH9
Posts: 11

Rep: Reputation: 0
That 'ls --color -F' alias is very useful: just done it to my own system.
Old 12-01-2003, 07:44 AM   #5
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Rep: Reputation: 30
I like the -a switch 'cause I want to be aware of every file on my system. Also for security reasons.
Old 12-01-2003, 09:12 AM   #6
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 31
Well the problem with the -a script is, as has been said, you get quite a lot of output. For example, when you do that to your ~ dir, you see all sorts of files that right at that instance, you're not really interested in, such as .screenrc, .xinitrc, .vnc, .bashrc, .inputrc, ./, ../ and so on [of course, it does depend on what you've got installed and used]. Quite often, you have to pipe the ouput through less or some other useful program to actually see what you want. And, you can't un-a it, whereas if you need to, you can -a it.
Old 12-01-2003, 09:31 AM   #7
Registered: May 2003
Location: Dayton, Ohio
Distribution: Redhat/IRIX/Windows
Posts: 35

Rep: Reputation: 15

I'm not sure if this will help, but there is a "system" default .bashrc located in the /etc/.profile directory. In there they setup default aliases for ls depending on which shell you invoke. This is executed after your local .bashrc file, so it will overwrite any setting you have in there.

Good Luck,
Old 12-01-2003, 11:13 AM   #8
Registered: Nov 2003
Location: Pouganis -- a planet not too far from over there.
Distribution: Vector
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks everyone. With you guy's help I finally figured it out. I've been trying to add the alias to etc/profile (which should work from everything I've read), but it didn't. Everything I've read says you have either .bashrc or profile, and I had profile. But when I created .bashrc and added the alais there it worked. So, what's the difference between profile and .bashrc? The normal terminal took the alias in profile just fine, but xterm and rxvt would only take it from .bashrc. Weird. Thanks again everyone...YAY! COLORS!
Old 12-01-2003, 11:24 AM   #9
Senior Member
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 48
you just have to do an "export" to tell bash where to read from:

export /etc/profile
export ~/.bashrc


you can even direct root to one version, and users to another version (or other versions) to get different effects depending on which user you are, or if you are root. i think that works as ~/.bashrc and /etc/profile, or what i do is just put a separate .bashrc in /root for root (and then "export /root/.bashrc" as root, of course).


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
xterm, rxvt, aterm, eterm, profiles? colors? gplacek Linux - Software 4 10-24-2004 09:01 PM
Making colors not so bold in rxvt? TheVrolok Linux - Newbie 1 10-14-2004 06:55 AM
How can I configure aterm/rxvt kaon Linux - Software 0 09-19-2004 09:33 AM
rxvt/xterm colors macondo Debian 2 04-20-2004 07:10 PM
Linking a TTY to an Xterm? (rxvt) miaviator278 Slackware 0 12-30-2003 05:12 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:23 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration