我曾看到多个帖子,其中没有启用“tgc”,包括:
if exists('+termguicolors')
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
" let &t_8f = "\<Esc>[38:2;%lu;%lu;%lum" ( I have tried both ':' and ';' )
" let &t_8b = "\<Esc>[48:2;%lu;%lu;%lum"
set t_Co=256
set termguicolors
" colorscheme gruvbox " color scheme
endif导致vim有奇怪的颜色输出-通常与tmux。
一开始我也在这方面取得了成功。直到一个晴朗的日子(认真的!)维姆开始表现得很奇怪,但以不同的方式。是单色的。
如果,我没有设置它,即se notgc,我实际上得到了正确的颜色方案。这在vim + tmux的使用中也是完全一样的。
但是,当我使用vim + tmux时,如果我杀死一个窗格,或者重新加载~/tmux.config,那么现有的vim会话就会再次变得奇怪!
这里就是这样的一个例子,左边是一个新打开的缓冲区,而右边一个设置相同,突然变得很奇怪。
我的设置:
$ cat /proc/version
Linux version 2.6.32-504.30.3.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Jul 15 10:13:09 UTC 2015vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 26 2019 22:56:22)
Included patches: 1
Compiled by bob@c6x64
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl +farsi +mouse_sgr -tag_any_white
+arabic +file_in_path -mouse_sysmouse -tcl
+autocmd +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
+balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
+browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +timers [25/126]
+byte_offset -hangul_input +num64 +title
+channel +iconv +packages +toolbar
+cindent +insert_expand +path_extra +user_commands
+clientserver +job -perl +vertsplit
+clipboard +jumplist +persistent_undo +virtualedit
+cmdline_compl +keymap +postscript +visual
+cmdline_hist +lambda +printer +visualextra
+cmdline_info +langmap +profile +viminfo
+comments +libcall -python +vreplace
+conceal +linebreak -python3 +wildignore
+cryptv +lispindent +quickfix +wildmenu
+cscope +listcmds +reltime +windows
+cursorbind +localmap +rightleft +writebackup
+cursorshape -lua -ruby +X11
+dialog_con_gui +menu +scrollbind -xfontset
+diff +mksession +signs +xim
+dnd +mouse +startuptime +xsmp_interact
-ebcdic +mouseshape +statusline +xterm_clipboard
+emacs_tags +mouse_dec -sun_workshop -xterm_save
+eval +mouse_gpm +syntax
+ex_extra -mouse_jsbterm +tag_binary
+extra_search +mouse_netterm +tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/tools/apps/local/vim/latest/share/vim"
Compilation: gcc -std=gnu99 -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freety
pe2 -I/usr/include/libpng12 -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -std=gnu99 -L/usr/local/lib -Wl,--as-needed -o vim -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixb
uf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -lti
nfo -lelf -lnsl -lselinux -lacl -lattr -lgpm默认的cshrc的术语显式地设置为vt100。如果我将其更改为xterm-256color或screen-256color,实际上在vim和:set term=$TERM中可以得到很好的着色方案,或者显式地将其转换为上述两者之一,同时也会出现相同的问题。
set -g default-terminal "screen/xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"-关于颜色支持:没有真正的颜色支持
awk 'BEGIN{
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum+1,1);
}
printf "\n";
}我应该放弃gnome终端,尝试其他模拟器(这比Konsole更快)吗?如果能在gnome终端本身找到解决方案,我会非常感激的。
我希望我已经给出了所有相关的细节,谢谢
发布于 2021-08-15 15:36:47
在大多数情况下,下列组合应该有效:
~/.vimrc:
" Inspect $TERM instad of t_Co as it works in neovim as well
if &term =~ '256color'
" Enable true (24-bit) colors instead of (8-bit) 256 colors.
" :h true-color
if has('termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
colorscheme <your favorite colorscheme goes here>
endif~/.tmux.conf:
# Set $TERM and force 256 colors.
# https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-a-256-colour-terminal
# https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour
if "[[ $TERM =~ 256color]]" "
set -g default-terminal 'tmux-256color';
set -ga terminal-overrides ',tmux-256color:Tc' "请注意,此不对vim中的任何颜色配置进行硬编码,这是一种干净的方法。您不应该强迫vim使用256个颜色。终端负责告诉vim是否支持256种颜色。
这种方法在tmux中也不会硬编码任何颜色配置。不过,在某些情况下强迫tmux使用256颜色可能是有意义的。如果您想这样做,只需删除if
~/.tmux.conf:
set -g default-terminal 'tmux-256color'
set -ga terminal-overrides ',tmux-256color:Tc'发布于 2020-05-29 00:03:44
我相信这在一定程度上是由于您的tmux配置。您需要在.tmux.conf中设置以下内容
set -g default-terminal screen-256color
set -ag terminal-overrides ",xterm-256color:Tc"请注意,不能在默认终端选项中使用斜杠,因为它必须是有效的终端类型。我假设您正在登录的所有系统都具有screen-256color终端类型,但是您可以通过运行infocmp screen-256color进行检查,它应该在成功时打印终端信息,并在出错时出现错误。您可能需要安装其他软件包来添加该终端类型。
就GNOME终端而言,2.31是非常古老的。GNOME 2中使用的VTE版本绝对不支持真实颜色。理想情况下,您将设置本地系统以使用现代终端仿真器,并在SSH上登录,而不是使用VNC,这样就可以了。
我将清楚地指出,由于您在这里使用的是CentOS或RHEL 6,实际上您试图使用的任何终端模拟器都可能会损坏。这个操作系统已经有十年的历史了,并将从11月起失去安全支持。如前所述,您最好的选择是在笔记本或台式机上使用更现代的环境,并在SSH上登录。
https://stackoverflow.com/questions/62071974
复制相似问题