mobile-shell / mosh

Mobile Shell
https://mosh.org
GNU General Public License v3.0
12.56k stars 730 forks source link

Wrong colors in Vim #928

Open tB0nE opened 6 years ago

tB0nE commented 6 years ago

For some reason the colours in Vim are all messed up when I use mosh. When I use ssh its working fine. When I check the terminal using mosh however, it shows the colours as 256, which is correct. Also if I execute tmux over mosh, all the colours are then correct in Vim.

I tried mosh on mintty and blink which are 2 very different clients so I suspect that is is some sort of setup issue on the machine where the server is setup rather than the client.

I've had a look through previous issues posted, but haven't found anything that could help me, or on things that could have been related (with regards to .bashrc or .profile) the things to do were not very clear. Any ideas?

eminence commented 6 years ago

when using mosh (but without tmux) what's $TERM in your inner terminal on the server, and $TERM on the outer terminal on the client?

tB0nE commented 6 years ago

It is xterm-256color in both. Vim seems to suggest that it is supporting 256, but the colours are displayed close to black/white/high contrast.

eminence commented 6 years ago

also: what version of mosh (on both the client and the server) ?

tB0nE commented 6 years ago

For one client I am using the latest version of blink (https://github.com/blinksh/blink), so I'm not sure what version that is.

For cygwin (mintty) it is 1.3.0.

On the server it is 1.3.2

eminence commented 6 years ago

Using this script as a test (since I'm not sure the best way to visually see if vim is using all 256 colors), things seems to work fine for me with 1.3.0 (mintty) on the client and 1.3.0 on the server.

I'm curious if you can reproduce the color problem with that above test script

tB0nE commented 6 years ago

Used the script, color looks good. They are the same on ssh and mosh, its only when I go into vim that the colors get messed up (and are correct in vim). Is it possibly something to do with what dotfiles get loaded? which would make sense because going into a tmux session through mosh and running vim, the colors are correct.

rwuwon commented 6 years ago

Do you have set t_Co=256 as a separate line in your vimrc?

That's the extent of my settings - I don't apply any colour settings for mosh 1.3.0, tmux 2.7, nor my terminals (gnome-terminal/iTerm2/Terminal/JuiceSSH) as they all seem to handle colours fine by default provided t_Co is set with no other custom configurations elsewhere.

Themes that I use are Tomorrow-Night-Bright and PaperColor and as far as I can tell it's more or less identical between mosh and ssh.

boxofrox commented 6 years ago

I just tried mosh today and ran into some symptoms described by @tB0nE...

  1. Neovim colors are incorrect (high contrast) in mosh.
  2. TERM=xterm-256colors in mosh shell.
  3. The 256 color test script works fine in mosh shell.
  4. The 256 color test script fails with high contrast black and green when run inside a neovim embedded terminal (i.e. mosh -> shell -> neovim -> :terminal buffer).

mosh-1.3.2 was installed on both machines from ArchLinux package repository.

I then built mosh from the master branch with the Arch User Respository package mosh-git, and colors in neovim now work fine.

mosh 1.3.2 [build mosh-1.3.2-76-g944fd6c]
Copyright 2012 Keith Winstein <mosh-devel@mit.edu>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Looking at the mosh --version from the master branch build, it appears there's a commit in master that fixes this.

HarmtH commented 5 years ago

I had the same issue, and it was because my Vim was using true (24-bit) colours, which my Mosh version (1.3.2) did not support. Setting set notermguicolors and re-applying my colourscheme fixed the issue.

inadarei commented 4 years ago

Same as @HarmtH, the problem was that I had set termguicolors in my .vimrc. As soon as I commented that out - everything started working over Mosh.

It's strange that the same was not a problem over SSH, but oh well. At least the problem/solution seems to now be known.

jairovm commented 3 years ago

This worked for me https://github.com/mobile-shell/mosh/issues/945#issuecomment-346627355

brew uninstall mosh
brew install --HEAD mosh
chanw9 commented 3 years ago

This worked for me #945 (comment)

brew uninstall mosh
brew install --HEAD mosh

Funny behaviour, I happened to reinstall OS X Catalina, and when installing mosh forgot to use "--HEAD", but 256 colours were shown correctly anyway. I continued using it daily for weeks without noticing until I reboot my VPS, and the colours were all screwed up again (and tricked me into believing that I must have screwed up something on the server side...)

ghost commented 3 years ago

I found a solution to a similar problem with iTerm2, mosh, tmux, and vim that I couldn't reproduce in other mosh terminals. The "problem" is that I was using a dark terminal. vim can't detect a dark background with mosh or tmux, leading to yellows becoming dark or brown, cyan becoming a less pleasant cyan, and so on. Mosh didn't have issues reproducing colors at all, in my case, vim was just adjusting darker for visibility on a presumably light background.

To brighten up a mosh vim session: :set bg=dark Or if you always use dark terminals, you can add this to your hosts' ~/.vimrc: set bg=dark

Screen Shot 2021-09-02 at 5 16 14 PM Screen Shot 2021-09-02 at 5 17 07 PM

Voilà, all the bright colors.

reoring commented 2 years ago

This worked for me #945 (comment)

brew uninstall mosh
brew install --HEAD mosh

That same situation in arch linux.

This worked for me.

yay mosh-git
vext01 commented 2 years ago

I have the same!

Can you tell us which commit fixes this issue? I'd like to backport it to OpenBSD ports.

or perhaps mosh could make a release?

vext01 commented 2 years ago

A couple of candidates:

simonszu commented 2 years ago

I have the same problem on Debian servers with a true-color-scheme in tmux and vim. Both inside and outside tmux my $TERM report to xterm-256color. I use NeoSolarized color scheme in vim. If i do set termguicolors, vim shows some kind of white font on yellow background. If i do not set termguicolors, vim shows the ugly 16 color palette.

Same config over SSH is working fine. I tried the mosh package for Debian sid as well, but no improvement. Any ideas?

storopoli commented 2 years ago

Installing mosh-git from AUR fixes for me. Why not tagging a new release?

pmrt commented 2 years ago

Building from source worked for me (neovim)

$ git clone https://github.com/mobile-shell/mosh $ cd mosh $ ./autogen.sh $ ./configure $ make $ make install

Please, we need that release.

mar-muel commented 1 year ago

Hello! I'm still facing the same issue. When installing mosh using apt on Ubuntu 20.04 I get mosh version 1.3.2.

I then tried installing from source but ran into installation issues with protobuf.

Would it be possible to push a new release to be available through apt?

achernya commented 1 year ago

We unfortunately do not have a member on our team that can do stable release updates to LTS Ubuntu. Mosh is imported into Ubuntu via Debian.

owittek commented 1 year ago

Had the same issue on my Ubuntu 20.04 LTS, fixed it by building mosh from source. I found this documentation that describes all the possible issues and required software to build succesfully: https://gist.github.com/kuntau/37698a5159ceac40982b1f7ae96b7db8#file-mosh-md

BaksiLi commented 1 year ago

Had the same issue on my Ubuntu 20.04 LTS, fixed it by building mosh from source. I found this documentation that describes all the possible issues and required software to build succesfully: https://gist.github.com/kuntau/37698a5159ceac40982b1f7ae96b7db8#file-mosh-md

So your problem is solved by building it from source? I did what I can did but it does not work...

owittek commented 1 year ago

Are you sure that you're using your built version? Perhaps you've not uninstalled the old version and it's being prioritized in your $PATH?

tangledhelix commented 10 months ago

I have installed from the HEAD source (using the same process as in @pmrt's comment), but I am stil seeing the corrupted colors.

Symptoms:

eminence commented 10 months ago

Some fixes are only in 1.4.0, so we would really like you to be running 1.4.0 on both the client and server.

pshchelo commented 1 week ago

enabling termguicolors in neovim is what worked for me. My setup: server - Ubuntu 22.04 (x86_64) client - MacOS X Sonoma (arm M2) mosh 1.4.0 installed from brew on both client and server neovim 0.10.1 installed from brew Symptoms: colors in NeoVim were completely off, no syntax highlighting etc - but only when connecting over mosh and regardless under tmux or not, and everything is fine over ssh. Fix: add vim.o.termguicolors = true to init.lua for NeoVim