所以是的,~/.oh-my-zsh 是罪魁祸首。进入 ~/.oh-my-zsh/lib/termsupport.zsh
#Appears at the beginning of (and during) of command execution
function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
local LINE="${2:gs/$/\\$}"
LINE="${LINE:gs/%/%%}"
title "$CMD" "%100>...>$LINE%<<"
}
我们看到它试图将标题设置为整个命令,包括命令之后的内容,去掉 sudo 之类的前缀,并对 $ 和 % 之类的字符进行一些转义。但是由于某种原因,当你做一只猫时,它会抛出一些换行符。为了快速解决问题,我只是将标题设置为 $CMD 有点笨拙,如下所示:
#Appears at the beginning of (and during) of command execution
function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
## Removing command argument parsing because of cat bug
#local LINE="${2:gs/$/\\$}"
#LINE="${LINE:gs/%/%%}"
#title "$CMD" "%100>...>$LINE%<<"
title "$CMD"
}
我已经在 oh-my-zsh 的 github 上回顾了这个文件的最新历史,但似乎这个错误已经存在了一段时间。“正确”的答案可能是围绕 $LINE 进行一些嵌套扩展,以删除空白和换行符并向 oh-my-zsh 发出拉取请求。但是我的 zsh foo 仍然太弱了。