问题描述
Kali Linux自带的终端模拟器为QTerminal,默认使用的shell为zsh,并为zsh配置了zsh-autosuggestions插件和zsh-syntax-highlighting插件。zsh-autosuggestions可根据历史命令提供命令建议的功能,非常方便输入常用命令;zsh-syntax-highlighting提供语法高亮的功能,能够显著提高命令的可读性。两者结合使用能给用户带来极大方便,如下图所示。

然而,在最近一次滚动更新之后,我的终端模拟器在输入命令时,采纳了zsh-autosuggestions的命令,但是命令的语法高亮显示异常,命令按照zsh-autosuggestions提供的建议补全之后颜色应当是白色,然而却仍然显示原来的灰色,如下图所示。

原因分析:
研究了一下“~/.zshrc”目录下的配置文件,除了自定义了一下前景色(“fg=#999”)以外,并没有什么异常。这个前景色是按照RGB颜色设置的,也没什么问题。

通过查阅资料,发现了GitHub对这个bug已经有讨论:
Highlight style is not cleared on accept when manually set to a value <8
To follow up on this, I’ve done a bit more testing and it appears that the styling won’t reset after accepting a suggestion if either
fgorbgis<=7, regardless of other styling. As soon as either is below8then the styling persists.
解决方案:
下面这个帖子中,一位开发者提供了一个暂时的解决方法。
formatting no longer cleared after completion if fg=7
#698 seems to be the same issue. The current version of
zsh-autosuggestionsandzsh 5.9don’t go well together.
I had to setZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=250"to make clearing work.
照着修改之后,果然没什么问题了。这个设置是使用的256色来配置的,而不是RGB颜色。似乎是zsh 5.9更新带来的问题。
Linux用起来果然比较复杂,很多细节的地方如果设置不当可能会出现各种问题。

540

被折叠的 条评论
为什么被折叠?



