Terminal, color ls and ssh

After a bit of googling I found a way to add color to my ls commands when running the bash shell in Terminal. To ~/.bash_profile I added the the following lines:

export CLICOLOR=1
export TERM=xterm-color

Previously when I ssh'd in to my linux box any ls command returned results in color (which is why I started looking for a way to add color to my bash session in OS X in the first place). Now I have the color on the local OS X machine, but when I ssh to the linux box no color.

My googling on this topic has yielded inconclusive results. Any ideas?

G5 and Powerbook G4 Mac OS X (10.4.6)

Posted on Jun 6, 2006 12:22 PM

Reply
10 replies

Jun 6, 2006 1:13 PM in response to jscottyk

If I'm understanding your post correctly, you used to have color when ssh'ing to linux, but not locally on the Mac. And putting the two exports in your profile switched it around so the ssh to linux doesn't have color now, but locally on the Mac it does. Correct?

If that's the case, try aliasing ls to 'ls -G', that's what I've done on my Mac and I get color just fine. It also shouldn't interfere with ssh sessions or anything. Just put:

alias ls='ls -G'

in your .bash_profile and remove the two exports. Hopefully that will work for you!

Macbook Pro 2.0 GHz Mac OS X (10.4.5)

Jun 6, 2006 6:21 PM in response to Horrible Gelatinous Blob

Yes, my terminal type of the OS X machine was defaulted to vt100. I've now switched it to xterm-color.

As I dig into this I think the problem is on the linux box side of things. The terminal type there is xterm. If I have xterm on the OS X box and both sides match I get color while ssh'd in, but not local. There must be some kind of mismatch occuring.

The digging will continue.



G5, Powerbook G4 Mac OS X (10.4.6)

Jun 6, 2006 7:56 PM in response to jscottyk

Jscottyk,


after you've ssh'ed in to the linux box. what is the terminal type being used? if you don't know. 'echo $TERM'.

And does the system support that terminal type?

infocmp $TERM

should dump out the terminal type configuration information. does it have a
"colors" setting. If it doesn't, save the output from terminfo, run on the mac, for the the terminal type that supports colors to a file. move it to the linux
box, and run

tic <filename>

wherei <filename> is the file that you saved the output from infocmp from.
and if you lucking it will create it with out problem. the next step is to try logging in from another Terminal.app window, to see if that clears up the problem. you probably wont have to resort to this, as linux usually has quite
a few terminal types by default. but if you do have to, note where the file is written too, incase you have to manually delete it. this can be found from looking at the terminfo manpage.

see terminfo(5) under Color Handling

Andy

Message was edited by: Nils C. Anderson

Jun 7, 2006 5:50 PM in response to Mihalis Tsoukalos

Hi Mihalis,
I think that you must have installed GNU's "ls" utility. Apple's BSD version doesn't support the "--color=auto" switch.

Hi jscottyk,
Your Linux distro must be pretty brain-dead if it doesn't support xterm-color; mine does. Does it have a /usr/share/terminfo/x/xterm-color or some comparable terminfo file or termcap entry? Anyway, xterm should work so you can certainly use that if it does work.
--
Gary
~~~~
Humor in the Court:
Q. And lastly, Gary, all your responses must be oral.
O.K.? What school do you go to?
A. Oral.
Q. How old are you?
A. Oral.

Jun 8, 2006 4:46 AM in response to Mihalis Tsoukalos

Hi Mihalis,
Yeah, I've got Fink's coreutils too. I think it's a recent dependency of one of the packages I have installed. When, after five years, they finally got shellutils to compile on OS X, I think they felt some "need" to use it. I've always liked GNU utilities but some BSD utilities stand out and Apple has changed some in ways that make them indispensable. The new versions that respect resource forks are among those. Also, Apple's "ls" utility has a switch that causes it to list ACLs and Apple's chmod can edit ACLs so they're indispensable.
--
Gary
~~~~
If you think before you speak the other guy gets his joke
in first.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal, color ls and ssh

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.