Quantcast

Forums | MacLife

You are not logged in.

#1 2002-12-25 12:20 am

ike6116
Member
From: Plymouth Ma USA
Registered: 2000-08-08
Posts: 718

Save your sanity! (color ls in OS X)

Most of us here (hopefully) have used Linux and have become accustomed to a color output from the ls command.  I would get frustated after SSH-ing into my friends redHat box and then not having the same convienience.  You in the same boat?  Here's the cure to what ails ya!

Use fink to get the GNU file utilities (pkg name 'fileutils') or just go get the color-ls (search Google you lazy bum).  Replace the existing /bin/ls with the new one (or if you aren't so adventerous, just put dir the new ls is in before /bin in your PATH, but I'd recomend going the former way)

ok so now ls --color gives you what you want but thats a pain in the ass to type, what to do? cd to your home dir, pico .tschrc  and add the line:

alias ls 'ls --color'


bamb!


--
"But even though i disagreed with almost everything he said, I kind of liked him."  -Linus Torvalds reffering to Steve Jobs

Offline

 

#2 2002-12-25 3:13 am

Fracai
Evacipate
From: St. Elsewhere
Registered: 2000-05-25
Posts: 2837

Re: Save your sanity! (color ls in OS X)

for even more fun, get dircolors and add more color assignments.
here's what my, unparsed, dircolors file looks like:

Code:

# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.

# Modifications:  J. Van Stonecypher, Jan 07, 1995

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR all

# Extra command line options for ls go here.
# Basically these ones are:
#  -F = show '/' for dirs, '*' for executables, etc.
#  -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM xterm
TERM xterm_color
TERM vt100

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes: 
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00       # global default, although everything should be something.
FILE 00         # normal file
DIR 01;34       # directory
LINK 01;36      # symbolic link
FIFO 33         # pipe
SOCK 01;35      # socket
BLK 01;33       # block device driver
CHR 01;33       # character device driver

# This is for files with execute permission:
EXEC 01;32 

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')

.c   36 # c source
.cc  36 # c++ source
.h   33 # headers

.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.app 01;32

.tar 00;31 # archives or compressed (bright red)
.tgz 00;31
.arj 00;31
.taz 00;31
.lzh 00;31
.zip 00;31
.z   00;31
.Z   00;31
.gz  00;31
.sit 00;31
.sitX 00;31
.zip 00;31
.bin 00;31
.hqx 00;31

.jpg 00;35 # image formats
.jpeg 00;35
.gif 00;35
.bmp 00;35
.xbm 00;35
.xpm 00;35
.tif 00;35
.tiff 00;35
.pdf 00;35

.avi 00;35 # motion formats
.mov 00;35
.mpg 00;35
.mpeg 00;35
.asf 00;35
.wmv 00;35
.rm  00;35
.swf 00;35

.mp3 00;35 # music formats
.aiff 00;35
.aif 00;35
.snd 00;35
.wav 00;35

if you don't want to go for the dircolors route, you could also just add this to your .*rc file:

Code:

LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=01;33:cd=01;33:
ex=01;32:*.c=36:*.cc=36:*.h=33:*.cmd=01;32:*.exe=01;32:*.com=01;32:
*.btm=01;32:*.bat=01;32:*.app=01;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:
*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:
*.sit=00;31:*.sitX=00;31:*.zip=00;31:*.bin=00;31:*.hqx=00;31:*.jpg=00;35:
*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:
*.tiff=00;35:*.pdf=00;35:*.avi=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:
*.asf=00;35:*.wmv=00;35:*.rm=00;35:*.swf=00;35:*.mp3=00;35:*.aiff=00;35:
*.aif=00;35:*.snd=00;35:*.wav=00;35:';
export LS_COLORS

it should be somewhat easy to make the jump that dircolors would and create your own LS_COLORS listing to export

goodLuck


   i am jack's amusing sig file
        http://alum.wpi.edu/~arno/i/s.png
Satellite Lot :: Second Summer

Offline

 

#3 2002-12-25 2:42 pm

Buzzword
Member
From: college, ny
Registered: 1999-03-21
Posts: 7255

Re: Save your sanity! (color ls in OS X)

My only suggestion would be to replace "pico" with "gvim".

::dons asbestos suit::

wink


Just another CitiBank hacker...

Offline

 

#4 2002-12-26 9:57 am

~Coxy
Member
From: Perth, Western Australia
Registered: 2000-04-05
Posts: 8477
Website

Re: Save your sanity! (color ls in OS X)

My only suggestion would be to replace "pico" with "gvim".

Has anyone even ported gvim to Mac OS X proper, yet? Otherwise, BBEdit works for me. big_smile

Offline

 

#5 2002-12-26 10:25 am

skymt0
Member
From: Sector ZZ9 Plural Z Alpha
Registered: 2002-10-23
Posts: 1195

Re: Save your sanity! (color ls in OS X)

My only suggestion would be to replace "pico" with "gvim".

::dons asbestos suit::

wink

Nano's just like Pico only better, so I use it.

Offline

 

#6 2002-12-26 1:23 pm

reh
shroom goon
Registered: 2002-04-19
Posts: 2311
Website

Re: Save your sanity! (color ls in OS X)

Has anyone even ported gvim to Mac OS X proper, yet? Otherwise, BBEdit works for me. big_smile

http://macvim.swdev.org/OSX/

Offline

 

#7 2002-12-26 11:17 pm

thekingalrock
Please tell me what the hell is going on
From: MA
Registered: 2001-04-01
Posts: 5072

Re: Save your sanity! (color ls in OS X)

Has anyone even ported gvim to Mac OS X proper, yet? Otherwise, BBEdit works for me. big_smile

http://macvim.swdev.org/OSX/

In the words of the critic, "It stinks!" gvim on Linux is nice, but not on OS X. I'll stick to plain 'ol vim on OS X.


It places the lotion in the basket

Offline

 

#8 2002-12-27 12:09 am

reh
shroom goon
Registered: 2002-04-19
Posts: 2311
Website

Re: Save your sanity! (color ls in OS X)

In the words of the critic, "It stinks!" gvim on Linux is nice, but not on OS X. I'll stick to plain 'ol vim on OS X.

I agree, sorta. I think gvim sucks on any system. Long live vim! big_smile

Offline

 

#9 2002-12-27 3:15 am

Buzzword
Member
From: college, ny
Registered: 1999-03-21
Posts: 7255

Re: Save your sanity! (color ls in OS X)

I use vim on my system for small stuff, but for bigger things, I find gvim more convenient.  I'm a big neat freak on my desktop, though.

(Oh, and Linux here, btw, not OS X)


Just another CitiBank hacker...

Offline

 

#10 2002-12-27 3:46 pm

[MA] Flying_Meat
Member
From: Frisco?
Registered: 2001-03-31
Posts: 8542

Re: Save your sanity! (color ls in OS X)

Most of us here (hopefully) have used Linux and have become accustomed to a color output from the ls command. 

I had never used Linux before applying color listings to my OSX install.
I have used Linux since though. Does that count? wink

cd to your home dir, pico .tschrc  and add the line:

alias ls 'ls --color'

The color listings also work under bash.

bamb!

ow!  smile


...and watch out for the flying meat!

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson