问题描述
我在OS X Mountain Lion上,运行附带的ZSH shell(4.3.11),顶部安装了Oh-My-ZSH.
I'm on OS X Mountain Lion, running the included ZSH shell (4.3.11) with Oh-My-ZSH installed over the top.
当将制表符补全与自制程序等命令一起使用时,当ZSH列出可用命令时,它还会复制该命令.例如:
When using tab completion with commands such as homebrew, when ZSH lists the available commands, it is also duplicating the command. For example:
$ brew {tab}
将导致:
$ brew brew
[list of homebrew commands]
我不确定导致此错误的原因,因为当我调整终端窗口的大小时,命令名称的第一个实例消失了.
I'm unsure what is causing this error, as when I resize the terminal window, the first instance of the command name disappears.
如果在显示重复项时点击退格键,则只能删除命令的第二个实例,zsh不会再让我退格键.另外,如果我确实使用退格键删除了重复项,则zsh的作用就好像根本没有键入任何命令.
If I hit backspace when the duplicates are displayed, I can only delete the second instance of the command, zsh won't let me backspace any further. Also, if I do remove the duplicate with backspace, zsh then acts as if there is no command typed at all.
我的.zshrc以及我的所有其他.configuration文件可以在 https://github.com/daviesjamie中找到/dotfiles
My .zshrc along with all my other .configuration files can be found at https://github.com/daviesjamie/dotfiles
更新:我发现这篇文章关于某人在Ubuntu上也有同样的问题.但是,我不了解给定的解决方案,甚至不确定它是否适用于我的设置?
UPDATE: I found this post about someone having the same problem on Ubuntu. However, I don't understand the given solution, and I'm not even sure if it applies to my set up?
推荐答案
问题可能是由于放置%{
%}
括号的位置不正确而引起的,该括号告诉zsh里面的文本为零宽度.唯一应包含在其中的是转义序列,这些转义序列会更改文本的颜色或粗体.如果您使用的是新的zsh(> = 4.3.{unknown version}),我什至建议使用%F{color}...%f
,%K{color}...%k
,%B...%b
而不是%{${fg[green]}%}
或现有的版本.
The problem is likely to arise from misplaced %{
%}
brackets that tell zsh that text inside has zero width. The only things that should be enclosed in them are escape sequences that change color or boldness of the text. If you are using new zsh (>=4.3.{unknown version}) I would even suggest to use %F{color}...%f
, %K{color}...%k
, %B...%b
instead of %{${fg[green]}%}
or what you have there.
它们的问题是无法用类似嘿,我输出了一些文本"的问题来查询终端.光标现在在哪里?"而zsh必须自行计算其提示的长度.当您键入一些文本并要求zsh完成时,zsh会说终端将光标移至特定位置并在其中键入完成的cmdline.如果将%{%}
括号放错了位置,则此特定位置是错误的.
The problem with them is that there is no way to query the terminal with a question like "Hey, I outputted some text. Where is the cursor now?" and zsh has to compute the length of its prompt by itself. When you type some text and ask zsh to complete zsh will say terminal to move cursor to specific location and type completed cmdline there. With misplaced %{%}
brackets this specific location is wrong.
这篇关于Zsh制表符完成复制命令名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!