SSH – Standardize Colors When Using iTerm2 on Linux

colorslsmacintoshsshvim

Originally posted this on the apple stackexchange, but I suspect the solution may be Linux-ey, e.g. adding something to my .bashrc.

Currently, when I SSH onto a Linux machine, the ls output colors and syntax coloring in VIM are different from the colors on my local machine. The colors shown are not defined in my Profile…Colors…ANSI Colors, and include an ugly dark brown color for "yellow." How can I force the text from a remote session to match my ANSI colors, so the coloring is always consistent?

Here's an example of what I'm talking about: left is VIM session on my local computer, right is VIM session within an SSH session. Notice the hideous brown.

And here's an example of the ls problem — the colors are different.

enter image description here

Best Answer

Terminal vim uses colors that your terminal makes available (the ANSI colors you pick, presumably—unless your terminal offers 256 color mode or settable colors), but which of those colors it uses is controlled by the vim color scheme and if it believes the background is light or dark.

You can check if the background is set to light or dark by :set background?. You can change it the ordinary way (e.g., :set background=dark).

You can check the current color scheme by running :colorscheme and set it by running :colorscheme «NAME». At least here, vim will tab-complete name letting you see all the available ones.

Once you've found the settings you like, you can add them to your ~/.vimrc.

EDIT: ls colors (with GNU coreutils) are set by the LS_COLORS environment variable; see info dircolors or (if that doesn't work) man dircolors. Although this might be a little harder, as your Mac OS X ls and GNU coreutils ls (as typically used on Linux) are entirely separate implementations.

Related Question