Support for 24-bit colors in the terminal in a bunch of ssh + tmux + neovim





On windows, I always used SecureCRT to work on ssh and did not know grief. But then it struck me that I had to try the 24-bit terminal and work on ssh using a beautiful theme for vim on a remote server.



Step 1. A 24-bit terminal program



Unfortunately, at the moment SecureCRT does not support a 24-bit screen, only a thread hangs on the forum , which will add support in the distant bright future.



So I went in search and found just such a git on this subject. There is a list of different terminals for Linux / Mac / Windows with True Color support. You can iterate over, watch what you like. I settled on MobaXterm for windows, it is somewhat similar to the usual SecureCRT for me, even the config from SecureCRT picks up. There is a portable version, you can download from here:



mobaxterm.mobatek.net



After starting, if you type the command:



lscolors
      
      





you will see a test plate as in the screenshot at the beginning of the article.



Step 2. NeoVim



Then I installed neovim on a remote machine, to which I was going to connect via ssh, using the terminal from MobaXterm.



Here is the neovim installation instructions:



github.com/neovim/neovim/wiki/Installing-Neovim



And put vim-plug:



github.com/junegunn/vim-plug



Step 3. The challenger_deep theme with True Color support











I chose the theme challenger_deep with True Color support, I personally liked it. But there are a lot of them, you can choose to your taste, you just have to look for True Color support.



And the most minimal configuration for neovim:



 call plug#begin('~/.local/share/nvim/plugged') Plug 'vim-airline/vim-airline' Plug 'itchyny/lightline.vim' Plug 'challenger-deep-theme/vim' call plug#end() syntax on filetype on filetype plugin on filetype plugin indent on set termguicolors colorscheme challenger_deep
      
      





The file ~ / .config / nvim / init.vim is an analogue of .vimrc for classic vim.



Farther:



 :PlugInstall
      
      





And, in fact, everything should become like a screenshot.



Step 4. Color support in tmux



By default, if you start a tmux session (analogue to screen), the colors will fade and return to their usual boring course. Here's how you can defeat it and return the color scheme.



Create the file ~ / xterm-24bit.terminfo with the following contents:



 xterm-24bit|xterm with 24-bit direct color mode, use=xterm-256color, sitm=\E[3m, ritm=\E[23m, setb24=\E[48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm, setf24=\E[38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
      
      





Make sure there is an empty line at the end of the file.



Run the command:



 tic -x -o ~/.terminfo xterm-24bit.terminfo
      
      





And further:



 export TERM=xterm-24bit
      
      





You can put it in .bashrc

In the .tmux.conf config, add:



 set -g default-terminal "xterm-24bit" set -g terminal-overrides ',xterm-24bit:Tc'
      
      





We start tmux and enjoy!



PS



I have not tried to do the same in classic vim and have not tried to do this in screen, instead of tmux. If someone works, write, plz.



All Articles