需要一些关于 tmux 的说明
Need some clarification on tmux
我今天刚安装了 tmux,使用起来有些困难。
在终端 window(我使用的是 iTerm2)的最底部,它表示如下:[13] 0:zsh*
13 是什么意思?我知道有 13 件事被保存了下来。我不知道它们是 windows、窗格还是会话。我不知道;我想把它们全部清除,也就是说,我想让它说 [0] 0:zsh*
此外,vim 在 tmux 中看起来真的很糟糕。我看到您需要 运行 命令:set -g default-terminal "screen-256color"
但它不起作用。 vim-航空公司看起来也很糟糕。然而,如果没有 tmux 运行ning,vim 看起来还不错。如果有人能帮我回答这个问题,那就太好了:)
更新:
我尝试使用 tmux -2
命令,但也没有用。 vim 看起来仍然很糟糕,输入 echo $TERM
后,我得到 screen
而不是 screen-256-color
当我遇到这个问题时,是因为我的 vim colorscheme 使用的是真彩色(24 位)而 tmux 只支持 8 位(256 色)。
检查颜色支持的方法如下:
首先,确保您的默认终端和 tmux 支持 256 色 python 脚本:
#!/usr/bin/env python
# Copyright (C) 2006 by Johannes Zellner, <johannes@zellner.org>
# modified by mac@calmar.ws to fit my output needs
# modified by crncosta@carloscosta.org to fit my output needs
import sys
import os
def echo(msg):
os.system('echo -n "' + str(msg) + '"')
def out(n):
os.system("tput setab " + str(n) + "; echo -n " + ("\"% 4d\"" % n))
os.system("tput setab 0")
# normal colors 1 - 16
os.system("tput setaf 16")
for n in range(8):
out(n)
echo("\n")
for n in range(8, 16):
out(n)
echo("\n")
echo("\n")
y=16
while y < 231:
for z in range(0,6):
out(y)
y += 1
echo("\n")
echo("\n")
for n in range(232, 256):
out(n)
if n == 237 or n == 243 or n == 249:
echo("\n")
echo("\n")
os.system("tput setaf 7")
os.system("tput setab 0")
预期的输出是每行颜色不同,最多有 1 条白线。如果黑底白字的行比较多,说明你没有开启256色。
接下来,使用此 bash 脚本检查您的 terminal/tmux 是否支持真彩色:
#!/bin/bash
# Based on: https://gist.github.com/XVilka/8346728
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
s="/\";
for (colnum = 0; colnum<term_cols; colnum++) {
r = 255-(colnum*255/term_cols);
g = (colnum*510/term_cols);
b = (colnum*255/term_cols);
if (g>255) g = 510-g;
printf "3[48;2;%d;%d;%dm", r,g,b;
printf "3[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s3[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'
这一个的预期输出如下所示:
预期的行为是 tmux 将支持 256 色但不支持真彩色,并且您的终端将同时支持这两种颜色。如果这是真的,并且你的 vim 配色方案看起来仍然很糟糕,很可能你使用的是真彩色配色方案,而 tmux 不支持它。您可以切换到 256 色版本,也可以为此感到难过。抱歉没有好消息。
我今天刚安装了 tmux,使用起来有些困难。
在终端 window(我使用的是 iTerm2)的最底部,它表示如下:[13] 0:zsh*
13 是什么意思?我知道有 13 件事被保存了下来。我不知道它们是 windows、窗格还是会话。我不知道;我想把它们全部清除,也就是说,我想让它说 [0] 0:zsh*
此外,vim 在 tmux 中看起来真的很糟糕。我看到您需要 运行 命令:set -g default-terminal "screen-256color"
但它不起作用。 vim-航空公司看起来也很糟糕。然而,如果没有 tmux 运行ning,vim 看起来还不错。如果有人能帮我回答这个问题,那就太好了:)
更新:
我尝试使用 tmux -2
命令,但也没有用。 vim 看起来仍然很糟糕,输入 echo $TERM
后,我得到 screen
而不是 screen-256-color
当我遇到这个问题时,是因为我的 vim colorscheme 使用的是真彩色(24 位)而 tmux 只支持 8 位(256 色)。
检查颜色支持的方法如下:
首先,确保您的默认终端和 tmux 支持 256 色 python 脚本:
#!/usr/bin/env python
# Copyright (C) 2006 by Johannes Zellner, <johannes@zellner.org>
# modified by mac@calmar.ws to fit my output needs
# modified by crncosta@carloscosta.org to fit my output needs
import sys
import os
def echo(msg):
os.system('echo -n "' + str(msg) + '"')
def out(n):
os.system("tput setab " + str(n) + "; echo -n " + ("\"% 4d\"" % n))
os.system("tput setab 0")
# normal colors 1 - 16
os.system("tput setaf 16")
for n in range(8):
out(n)
echo("\n")
for n in range(8, 16):
out(n)
echo("\n")
echo("\n")
y=16
while y < 231:
for z in range(0,6):
out(y)
y += 1
echo("\n")
echo("\n")
for n in range(232, 256):
out(n)
if n == 237 or n == 243 or n == 249:
echo("\n")
echo("\n")
os.system("tput setaf 7")
os.system("tput setab 0")
预期的输出是每行颜色不同,最多有 1 条白线。如果黑底白字的行比较多,说明你没有开启256色。
接下来,使用此 bash 脚本检查您的 terminal/tmux 是否支持真彩色:
#!/bin/bash
# Based on: https://gist.github.com/XVilka/8346728
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
s="/\";
for (colnum = 0; colnum<term_cols; colnum++) {
r = 255-(colnum*255/term_cols);
g = (colnum*510/term_cols);
b = (colnum*255/term_cols);
if (g>255) g = 510-g;
printf "3[48;2;%d;%d;%dm", r,g,b;
printf "3[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s3[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'
这一个的预期输出如下所示:
预期的行为是 tmux 将支持 256 色但不支持真彩色,并且您的终端将同时支持这两种颜色。如果这是真的,并且你的 vim 配色方案看起来仍然很糟糕,很可能你使用的是真彩色配色方案,而 tmux 不支持它。您可以切换到 256 色版本,也可以为此感到难过。抱歉没有好消息。