Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Just as the title says, when I ssh to my work Fedora server with iTerm2 I don't get color ls output. When I ssh to the same server with OS X's default Terminal app, ls color output works just fine.

EDIT: All other ls output is colorized properly. Both iTerm2 and Terminal display ls locally as colored, and Terminal works properly when SSH'd over to the work machine.

The only time I'm not getting colorized ls output is when I use iTerm2 to SSH to my work machine. Terminal produces colorized ls output when SSH'd to my work machine and so does PuTTY on Windows.

When SSH'd into my work machine from iTerm2 'ls -G' also makes no difference. Still no coloration on ls output.

Also, when SSH'd to my work machine from iTerm2, the only thing I'm not seeing color on is the output of ls. My prompt is colorized, vim works with color, and if I echo $TERM I see xterm-256color.

Any ideas?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

ls output with colors (ls -G) is not the default option. Run the following command in your terminal to enable ls colors by default:

echo "alias ls='ls -G'" >> ~/.bashrc
source ~/.bashrc

This and all future terminal sessions will now display colors correctly.


If you're still not seeing colors on your remote (or local) session follow these steps:

In iTerm verify that you're sending a terminal type that supports colors. Open the preferences window -> Profiles -> Default -> Terminal. I'd recommend putting xterm-256color as the Terminal Type.

Terminal Preferences

While connected to the remote machine, run ls -G and open the iTerm preferences again: preferences window -> profiles -> Default -> Colors. Adjust the ANSI Colors, and turn the minimum contrast down until the colors in the terminal window start to show color.

Terminal Colors

If the remote system supports ls --color=always, remove any existing aliases in ~/.profile or ~/.bashrc and update as follows:

echo "alias ls='ls --color=always'" >> ~/.bashrc
share|improve this answer
    
Sorry, I should have been more specific. I've edited my post accordingly. –  Pumpinglemma May 14 '12 at 15:30
    
Yes, I am currently reporting xterm-256color as my terminal. I'm updating my original question again with further info. –  Pumpinglemma May 14 '12 at 15:35
    
See my latest updates, concerning ANSI colors and the minimum contrast settings. I had to do something similar, IIRC I adjusted the "Bright" ANSI colors to match "Normal"... or maybe the other way around. Give it a shot and let me know if that fixes it. –  Aaron Lake May 14 '12 at 15:41
    
Minimum contrast is already at lowest setting, what do you mean by adjusting the ANSI colors? Should I just try moving them around until I see some colored output? –  Pumpinglemma May 14 '12 at 15:43
    
That's what I would recommend, again, I think I had to do the same thing when connecting to an Ubuntu machine running under screen. If that works I'll update the answer with how you fixed it. –  Aaron Lake May 14 '12 at 15:44

I had the same problem. I found that the color theme I used in iTerm (solarized) redefined the colors ls used on the ssh host making them impossible to tell apart.

You can try the following to check whether it's not the case for you:

LS_COLORS="di=07;31" ls    # this will list directories as black on red 

If this does show colors, you might need to redefine colors on the linux machine. The following command defines (some) ls colors to be similar to the OS-X defaults:

LS_COLORS="di=00;34:ln=00;35:so=00;32:pi=01;33:ex=00;31:bd=00;34" ls

To edit the colors on linux, see the dircolors man page. You can also read the following on how to set colors from .bashrc: https://github.com/seebi/dircolors-solarized#installation

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.