繁体   English   中英

使WIN10命令行传播WSL colors

[英]Make WIN10 command line propagate WSL colors

每当我打开命令提示符并使用命令序列时

wsl

ls

output 颜色很好。

但是,如果我在一个命令中执行相同的操作,

wsl ls

output 根本没有上色。

我缺少一些设置吗? 是否有可能让 output 继承 WSL colors?示范

使用 WSL2 和 Windows10 构建 19041.867

使用 cmd 控制台, ls将其检测为非 ANSI 彩色终端 output,因此默认禁用彩色 output。 在 Windows 10 上,cmd 控制台支持 ANSI 的颜色序列,因此在这种情况下,您可以强制ls为其 output 着色:

wsl ls --color=always

编辑:另一种方法可能是为 Windows 控制台添加一个 terminfo 条目,其中包括 VT 功能(请参阅tictoeterminfo )。 这需要一些研究,但这种方式将为 Windows 控制台下的每个 wsl 命令提供彩色 output。

WSL terminfo 数据库中有一个 Windows ANSI 控制台的现有条目:

$ toe -a | grep Windows
ansi-nt         Microsoft Windows NT console POSIX ANSI mode 
$ infocmp ansi-nt
#       Reconstructed via infocmp from file: /usr/share/terminfo/a/ansi-nt
ansi-nt|psx_ansi|Microsoft Windows NT console POSIX ANSI mode,
        am, bw, msgr,
        cols#80, it#8, lines#25,
        bel=^G, clear=\E[2J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J, el=\E[K,
        home=\E[H, ht=^I, ind=\E[S, kbs=^H, kcub1=\E[D, kcud1=\E[V,
        kcuf1=\E[C, kcuu1=\E[A, nel=\r\E[S, rc=\E[u, rev=\E[7m,
        ri=\E[T, rmso=\E[m, sc=\E[s, sgr0=\E[0m, smso=\E[7m,

看来我们只需要为 Windows 10 添加颜色#8。自从我上次使用tic这么多年以来,我必须通过测试和试验来 go 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM