Monday, January 7, 2008

Have Terminal show "ls" Colors by Default.

Working in Terminal is very tedious. And it doesn't help much when all of the files, folders, etc. are the same color. There is a simple way to make it so that when you invoke the "ls" command, it is always color-coded.

Adding this functionality is super simple, and is almost identical to the process I explained in the "show entire path of current directory" post. I was screwing around, trying to get this working at work on our Tiger machine and Dale gave me a few tips on using Vi. He actually suggested that I use Vim (Vi IMproved). Thankfully this is part of Tiger as well as Leopard so I gave it a shot.

In order to add the colors to ls we have to add another line to our .bash_profile file.

1.) Open Terminal

2.) It should start you off in your Home directory, just to make sure type "cd"

3.) Type the following line:

vim .bash_profile

4.) If this file has not been created yet, it will then display a blank screen, however if you've created this file before (maybe you did my post about showing the entire directory path!) then it will show you the previous lines that you have entered

5.) Press "i" to enter "Input mode"

6.) Now enter the following line:

alias ls="ls -G"

7.) Press the escape button. This will take you out of "Input mode"

8.) Type ":wq" and then press Enter (The colon prompts you to enter commands and the w and q commands stand for "Write," and "Quit")

9.) Finally, quit out of Terminal and re-open it. Now when you invoke the "ls" command, it should return the list of files and folders, but this time color-coded!



I got most of my information about this tip from this blog, however Leopard differs and does not seem to look at the ".profile" file. After a little bit of experimenting, I found out that instead Leopard seems to be looking at ".bash_profile". However if you are still running Tiger, the blog that I just posted works perfectly! Also see that blog for additional information on what all the color codes mean. Thanks again Dale for a lot of the hints!


Dale said...

another command to create a file like .profile is to use touch. So you can do a

touch .profile


vim .profile

Just a way that I do it instead of doing vim .profile...which is basically th esame thing, just in fewer commands. ...So, why am I telling you this, you ask? I'm not really sure, but now you know another command, right?!?!?!

Adelaide SEO said...

Yep, same as here:

Anonymous said...

black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines

afordable beach resorts in the philippineshomeopathy for big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here

night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds

best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsaircraft support equipmentsbest support equipments for aircraftsbed air informercialsbest informercials bed airmattress sized air beds

bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestThe causes of economic recessionwhat are the causes of economic recessionadjustable bed air foam The best bed air foam

hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds

migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas

vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations

bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5

washington new housenew house houstonnew house san antonionew house venturanew houston house houston house txstains removal dyestains removal clothesstains removalteeth whiteningteeth whiteningbright teeth

jennifer grey nosejennifer nose jobscalebrities nose jobsWomen with Big NosesWomen hairstylesBig Nose Women, hairstyles