LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 11-30-2003, 10:50 PM   #1
Pougan
Member
 
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
Scruff
Member
 
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
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

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

Håkan
 
Old 12-01-2003, 04:32 AM   #4
raceprouk
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
Scruff
Member
 
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
andrewlkho
Member
 
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 30
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
Merlin53
Member
 
Registered: May 2003
Location: Dayton, Ohio
Distribution: Redhat/IRIX/Windows
Posts: 35

Rep: Reputation: 15
Hello,

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,
Merlin53
 
Old 12-01-2003, 11:13 AM   #8
Pougan
Member
 
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
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

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

export /etc/profile
export ~/.bashrc

etc.

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).
 
  


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 08:51 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