geekvenue.net

Welcome to Chucktips HELP WITH DEAD OS Hardware Installing FreeBSD Miscellaneous
 faq
 search
 add article
 cool-stuff
 how-to
 main
 tips


TIP: Colorize your directories
Documentation Posted by Understudy on Sunday August 08, @05:17PM
from the They gives those nice bright colors, they give us the dreams of summer dept.
Want to know what is a file and what is a directory when you run ls (list command). Here is a little bit of an idea, color your directories.

The standard output from ls or ls -a is just to give them to you in the same color as whatever your CLI (command line interface) is currently running at. Jason responded to an article a while back on a quick way to do this. I am going to give a more elaborate version.
Normal output:
[bhorne@Slacker:bhorne, 07:57 PM, Sun Aug 08]>ls
--webpage    GNUstep    gcc    sounds
C702.wav    My_Documents    plugin131.trace    uname
Desktop    My_Downloads    shelf

Shiny new output:
[bhorne@Slacker:bhorne, 07:57 PM, Sun Aug 08]>ls
--webpage    GNUstep    gcc    sounds
C702.wav    My_Documents    plugin131.trace    uname
Desktop    My_Downloads    shelf

See some of the output is blue. Those are directories if they are green they are executables. The standard color output items are files.
So how can you also have this wonderful setup on your box. Easy, each user has a shell rc file in their home directory. You need to to know which shell you are using. At the command prompt type :
echo $SHELL
/bin/sh : This is the Bourne shell.
/bin/ksh93 : This is the Korn shell.
/bin/bash : This is the Bash shell.
/bin/zsh : This is the Z shell.
/bin/csh : This is the C Shell.
/bin/tcsh : This is the TC Shell.

So you will be looking for a .shrc, .kshrc, .bashrc or .bash_profile, .zshrc, .tcshrc, .cshrc or .profile. The .profile is generally in each users home directory. However depending on the shell it is not always read. So you may have mixed results working in .profile . Now you will need to edit the *rc file. Those *rc files are also located in your home directory. At the command prompt:
ee .bashrc
then scroll to the bottom of the file and add these lines:
alias ls="ls -G"
CLICOLOR="YES";    export CLICOLOR
LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
Basically what happens is alias tells the command ls to use colors, however we reinforce it with the CLICOLOR and LSCOLORS lines and yes the case is important. Save your changes and exit your editor (ee uses the Esc key). You will need to log out and back in to see the changes take place. But the next time you run ls at the prompt, you will have a few pretty colors to go with it. Unless everything is a file in that particular directory you are in.

I want to thank a few resources I grab all this stuff from.
HEMI who had some of the CLICOLOR info.
http://dmr.ath.cx/notes/putty-freebsd.html which is where I added the alias part of it.
Jason who hasn't banned my ip yet. So I can still post articles.

Add Reply

Name
Email
Notify Notify me via email of responses to this message
Title
Comment
(Check those URLs! Don't forget the http://!)
Encoding
If none of the above mean anything to you, select 'Plain'!
Attachment
(You can attach a file to your reply which can then be retrieved by other readers.
Try to keep the file sizes below 500Kb in order to conserve network and server resources.)
Allowed HTML <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <HR> <STRONG> <BLOCKQUOTE> <DIV .*> <DIV> <P .*>
Important Stuff:
  • Note: Fields with bold titles are required.
  • Please try to keep posts on topic.
  • Try to reply to other people comments instead of starting new threads,
  • Read other people's messages before posting your own to avoid simply duplicating what has already been said.
  • Use a clear subject that describes what your message is about.
  • Please do not post offtopic, inflammatory, inappropriate, illegal, or offensive comments. Repeat offenders will be sanctioned.
  • "You never know how many friends you have until you own a Condo on the beach." -- Jason's Postulate

    Powered by Zope  Powered by Apache  Squishdot Powered
    All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest ©2001 Jason Neumann.
    [ main | post article | search ]