5

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

2

The VIM part of this question was answered here.

Turns out my local session had background set to dark in VIM, and my remote session had background set to light. I just added the line set background=dark in my .vimrc and the colors now look identical.

  • I have set background=dark in .vimrc, but before colorscheme, now switching the order fixed this issue. – georgexsh Apr 23 at 7:08
2

I found the answer to the "ls colors are different" problem. You just need to make sure ls coloring is enabled on both machines, then use this page to make the colors encoded in the local (Mac) LSCOLORS variable identical to the colors encoded in the remote (Linux) LS_COLORS variable.

For Linux ls coloring matching the macOS defaults: put this in your .bashrc on your Mac:

alias ls="ls -G"
export LSCOLORS="exfxcxdxbxegedabagacad"

And put this in your .bashrc on the Linux machine:

alias ls="ls --color=always"
export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"

Edit: Alternatively (this is what I now do), you can just download "coreutils" with homebrew via brew install coreutils, then place alias ls=gls in your .bashrc. gls is the GNU version. Now, you can control ls colors with LS_COLORS, just like on Linux.

Also, if you want to get even more fancy: since you are now using the GNU ls, you can control the colors of various file extensions/types/permission levels by creating a ~/.dircolors.ansi file and running gdircolors ~/.dircolors.ansi. This repo has some dircolors templates to get you started.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .