View previous topic :: View next topic |
Author |
Message |
Daemon n00b
Joined: 18 Apr 2002 Posts: 65
|
Posted: Wed Apr 24, 2002 2:16 pm Post subject: colored console |
|
|
hi... how do i get ls to list directories and links with colors?
(i really searched hard b4 posting... it's not answered anywhere else ) |
|
Back to top |
|
|
dice Guru
Joined: 21 Apr 2002 Posts: 577
|
|
Back to top |
|
|
Daemon n00b
Joined: 18 Apr 2002 Posts: 65
|
Posted: Wed Apr 24, 2002 3:57 pm Post subject: |
|
|
doh! |
|
Back to top |
|
|
Malakin Veteran
Joined: 14 Apr 2002 Posts: 1692 Location: Victoria BC Canada
|
Posted: Thu Apr 25, 2002 2:04 am Post subject: |
|
|
Everyone seems to like this, maybe it can be made a Gentoo default?
One of the first things I did after installing Gentoo was setup the aliases so I had colors and directories identified, just seems logical to me. |
|
Back to top |
|
|
dArkMaGE Apprentice
Joined: 20 Apr 2002 Posts: 152
|
Posted: Thu Apr 25, 2002 2:30 am Post subject: |
|
|
shouldnt colors be set up for non-root users anyways? |
|
Back to top |
|
|
snutte Apprentice
Joined: 24 Apr 2002 Posts: 181 Location: Sweden, Malmö
|
Posted: Thu Apr 25, 2002 9:35 am Post subject: |
|
|
I have to agree. Colors should be default. |
|
Back to top |
|
|
dshepard@wvu.edu Guest
|
Posted: Fri Apr 26, 2002 1:09 am Post subject: If you really want this to work... |
|
|
Add the following to your /etc/profile.env:
alias ls='ls --color=always -F -b -T 0'
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;
35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;
31:*.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:*.jpg=01;
35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;
35:*.tif=01;35:*.png=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;
35:*.dl=01;35::'
This does the job nicely. Adding those lines to ~/.bashrc causes the changes not to take effect at the shell prompt, unless you log into another bash shell inside the login shell. This will fix this problem. I'm not sure if this is the best place to do this. If anyone else has a better place to put such a thing, please let me know. |
|
Back to top |
|
|
dshepard@wvu.edu Guest
|
Posted: Fri Apr 26, 2002 1:10 am Post subject: Sorry... |
|
|
If my last post made your browser window scroll left/right. I didn't realize the text wouldn't wrap... |
|
Back to top |
|
|
dshepard@wvu.edu Guest
|
Posted: Fri Apr 26, 2002 1:15 am Post subject: As you were... |
|
|
Apparently this info is needed in two locations for consistency: .bashrc for Konsole and /etc/profile.env for the real console. Doesn't hurt to have it in two places I suppose. I couldn't get dircolors to work right on my gentoo system. |
|
Back to top |
|
|
Dunska n00b
Joined: 27 Apr 2002 Posts: 15 Location: Brisbane, Australia
|
Posted: Sat Apr 27, 2002 10:28 am Post subject: profile.env |
|
|
I modified my /etc/profile.env but it always returns to a default state
(i.e. my mods gone) when I reboot.... is there some other file I need to
modify or some other way to make profile.env chnages stay? |
|
Back to top |
|
|
sven Apprentice
Joined: 19 Apr 2002 Posts: 274
|
Posted: Sat Apr 27, 2002 10:33 am Post subject: |
|
|
I figured long before I found out how to also add colors to konsole, the KDE terminal program.
My alias settings (for ls) are stored in ~/.bash_profile but konsole never wanted to load this file ...
Well, you have to add the "--ls" option to konsole and it will load the files and --voila-- colors in konsole |
|
Back to top |
|
|
sven Apprentice
Joined: 19 Apr 2002 Posts: 274
|
Posted: Sat Apr 27, 2002 10:36 am Post subject: |
|
|
@Dunksa Hmmm, this is strange! Better add your modifications to .bash_profile in your users home directory.
This is is a better (and cleaner) way of adding own aliases and settings.... but this is just my humble opinion |
|
Back to top |
|
|
Dunska n00b
Joined: 27 Apr 2002 Posts: 15 Location: Brisbane, Australia
|
Posted: Sat Apr 27, 2002 11:39 am Post subject: |
|
|
I'll give it a shot - thanks. |
|
Back to top |
|
|
ElCondor Guru
Joined: 10 Apr 2002 Posts: 520 Location: Vienna, Austria, Europe
|
Posted: Sat Apr 27, 2002 11:42 am Post subject: |
|
|
I did it with just two things, worked pretty fine:
1st generate a file /etc/DIR_COLORS
2nd add the following to your /etc/profile (for bash at least):
Code: |
alias ls="ls --color"
eval `dircolors /etc/DIR_COLORS`
|
i defined every terminal (gnome-terminal, xterm, etc) as login-shell by default, so it sources /etc/profile.
email me for a structured and very colorfull dir-listing
hth
ElCondor |
|
Back to top |
|
|
chadh Moderator
Joined: 21 Apr 2002 Posts: 137 Location: Atlanta, GA
|
Posted: Sat Apr 27, 2002 6:31 pm Post subject: Re: profile.env |
|
|
Dunska wrote: | I modified my /etc/profile.env but it always returns to a default state
(i.e. my mods gone) when I reboot.... is there some other file I need to
modify or some other way to make profile.env chnages stay? |
Don't edit /etc/profile.env. It is automatically generated based on the contents of /etc/env.d . Either put system-wide settings there, or put them in your /etc/profile. _________________ Chad |
|
Back to top |
|
|
daveman1010220 n00b
Joined: 26 Apr 2002 Posts: 3 Location: Pennsylvania
|
Posted: Sun Apr 28, 2002 1:57 am Post subject: hmmm... |
|
|
Didn't know the trick about launching konsole with -ls, however, it seems that konsole will read .bashrc all by itself. This is really unfortunate because bash (at the real console) reads .bash_profile all by itself. So as it ends up, you have to put settings in both files because konsole wants to be different. I personally don't see why Bash has a .bash_profile as well as a .bashrc, since both reside in the user's home directory. Oh well, have however you want it. By the way, if I have a setting I like, I generally make it system-wide, as other people will probably like them as well, but never actually take the time to set some decent defaults.(or even learn how...) |
|
Back to top |
|
|
chadh Moderator
Joined: 21 Apr 2002 Posts: 137 Location: Atlanta, GA
|
Posted: Sun Apr 28, 2002 3:15 am Post subject: |
|
|
The reason that konsole by default doesn't read your .bash_profile is because it does not start a login shell. Traditionally there had to be separate login and non-login modes b/c automated remote logins (things like rsh) did not handle output in the login process. I am used to having a login shell source both the profile and the rc file, so I normally just add "source ~/.bashrc" at the end of my .bash_profile. _________________ Chad |
|
Back to top |
|
|
sven Apprentice
Joined: 19 Apr 2002 Posts: 274
|
Posted: Sun Apr 28, 2002 11:19 am Post subject: |
|
|
Just noticed that .bash_profile points to a file named /etc/DIR_COLORS ...
Well, I must have accidently deleted this file or it was never installed because I don't have this file.
Which package contains this file? |
|
Back to top |
|
|
Jeevz Bodhisattva
Joined: 15 Apr 2002 Posts: 195 Location: Boston, MA
|
Posted: Sun Apr 28, 2002 12:41 pm Post subject: |
|
|
You create it yourself. Check out the man page for dircolors. |
|
Back to top |
|
|
roTor n00b
Joined: 21 Apr 2002 Posts: 55 Location: Atlanta, GA
|
Posted: Sun Apr 28, 2002 2:38 pm Post subject: |
|
|
OK, just to add to my confusion how do I get the colors to work when I use "less" to see a long dir listing? |
|
Back to top |
|
|
Nossie Apprentice
Joined: 19 Apr 2002 Posts: 181
|
Posted: Fri May 10, 2002 4:44 pm Post subject: |
|
|
DIR_COLORS is part of the fileutils package.
You can find the file here :
Code: | /usr/portage/sys-apps/fileutils/files/DIR_COLORS |
greets,
Nossie
P.S. The -ls switch also works for aterm |
|
Back to top |
|
|
leaf n00b
Joined: 06 May 2002 Posts: 10 Location: England
|
Posted: Fri May 10, 2002 6:49 pm Post subject: |
|
|
roTor wrote: | OK, just to add to my confusion how do I get the colors to work when I use "less" to see a long dir listing? |
I'd like to know the answer to that too. |
|
Back to top |
|
|
arkane l33t
Joined: 30 Apr 2002 Posts: 918 Location: Phoenix, AZ
|
Posted: Fri May 10, 2002 7:32 pm Post subject: |
|
|
roTor wrote: | OK, just to add to my confusion how do I get the colors to work when I use "less" to see a long dir listing? |
less has a -R command that will take ansi escape sequences.
so if your ls is colored (you can also use the --color for ls if it isn't) then you can use less -R to show color.
HTH |
|
Back to top |
|
|
mooteel n00b
Joined: 18 Apr 2002 Posts: 8 Location: Montreal, QC
|
Posted: Fri May 10, 2002 7:33 pm Post subject: |
|
|
Maybe this will help a bit...
I personally add 'alias='ls -F --color' to my own user's .bashrc
Then I add the same thing to /etc/skel/.bashrc so that any newly created users get this change also by default. It won't change any existing users though. It would have to be done manually or with a script.
Of course, making those changes in /etc/profile or /etc/profile.env (not sure) would also work for a system wide use.
Good luck! |
|
Back to top |
|
|
cwsaylor Guest
|
Posted: Thu May 23, 2002 6:03 pm Post subject: |
|
|
I know I'm a little late to this game but I thought I would throw this out for anybody searching on this topic.
All of the settings you need are found in /etc/skel. It contains a .bash_profile and .bashrc. These are not put into the /root folder by default but they are put into any new user's folder. Just copy them over to /root and you're done.
If you want these files to load from the gnome terminal panel icon, choose settings, preferences, Use --login by default.
I have a few aliases for emerge that are useful.
esearch="emerge search"
epretend="emerge --pretend"
eget="emerge --fetchonly"
I prefer to see what's going to be installed first, then get all of the files, then comile.
Enjoy
Chris |
|
Back to top |
|
|
|