无论 Zsh 中的上下文如何,都将密钥绑定到完整的文件名
有时我想要一个文件名,而不是 zsh 为我猜测的文件名。例如,我有一个 PNG 文件,没有正确的 .png
后缀,这使得 zsh 认为它不是图片,并且当我键入 Tab
时不会列出它display
的完整参数。
我想知道是否有一个关键序列可以在任何上下文中完成文件名,例如 ^XC
代表 _ Correct_filename
,或者如何配置 zsh 来完成该操作?
Sometimes I want a filename instead of what zsh guesses for me. For example, I have a PNG file without a proper .png
suffix, which makes zsh think it isn't a picture and won't list it when I type Tab
to complete arguments of display
.
I am wondering if there is a key sequence that completes for a filename wherever the context is, like ^XC
for _correct_filename
, or how to configure zsh to do the thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以添加键绑定来执行您想要的操作:
编辑:添加
$PREFIX
您可以将这些行添加到您的
~/.zshrc
文件中。这使得当您在每个步骤中按 Ctrl-x Tab 而不是 Tab 时,补全会列出所有文件。您可以选择其他适合您的击键组合。
或者要使 ImageMagick 补全始终包含所有文件,请尝试编辑(首先备份)文件
/usr/share/zsh/functions/Completion/Unix/_imagemagick
(或类似文件)并将其更改为注释删除以_files
开头的现有行并添加所示的新行:You can add a key binding to do what you want:
Edit: Added
$PREFIX
You can add those lines to your
~/.zshrc
file.That makes the completion list all files when you press Ctrl-x Tab at each step instead of Tab. You could choose another keystroke combination that suits you.
Or to make ImageMagick completions always include all files, try editing (make a backup first) the file
/usr/share/zsh/functions/Completion/Unix/_imagemagick
(or similar) and change this to comment out the existing line that begins with_files
and add the new one shown:丹尼斯的回答没有为我扩展波形符,所以当我尝试在 foo ~/ma 上调用它时,我会得到类似
complete-files: no matches find: ~/ma*
的内容。我确实在 zsh FAQ 中找到了一个替代方案,可以扩展它们:Dennis' answer didn't expand tilde for me, so I would get stuff like
complete-files: no matches found: ~/ma*
when I tried to invoke it onfoo ~/ma
. I did find an alternate in the zsh FAQ that will expand them, though: