ssh - zsh completion: Disable ssh username completion
问题描述
I am using the completion scripts that ship with ZSH (5.7.1) and I would like to turn off the autocompletion for usernames, but keep the completion for hostnames.
How can I do this?
Currently, there's an erroneous user that I can't figure out why it's being included (not in ~/.ssh/config, any identities, /etc/ssh, or any other location) and I figure it's probably easier to just disable username completion.
Example output is below; I want to remove the entire "login name" section rather than try and hunt down where unwanted-username is coming from.
$ ssh <tab>
-- login name --
unwanted-username
-- host --
example-host-1 example-host-1
I expect there is a zstyle
command which can disable it, but I'm not sure the correct incantation. I expect this is the relevant configuration that needs to be changed:
$ zstyle | grep completion | grep ssh
:completion:*:ssh:* users hosts-domain hosts-host users hosts-ipaddr
However, I can't seem to get the correct incantation to remove the login name
section.
解决方案
要禁用登录名的完成,在这种情况下,请尝试:
zstyle ':completion:*:ssh:argument-1:*' tag-order hosts
或仅仅隐藏它们,请尝试:
zstyle ':completion:*:ssh:*:users' hidden true
按Ctrl-X h
而不是tab
确定相关标签和上下文字符串的好方法。
您有一个错误的用户正在完成,这似乎很奇怪。检查正在设置的样式,可能没有在上下文中users-hosts
提及。ssh
在ignored-patterns
一般情况下,样式可能是另一种处理错误匹配的方法,例如:
zstyle ':completion:*:ssh:*:users' ignored-patterns erroneous-username
正如您可能从样式名称中看出的那样,这里的最后一个参数可以是带有 等的 shell*
模式?
。
推荐阅读
- java - 如何在不同的线程中处理 @KafkaListener 方法?
- py4j - 您如何通过 py4j 使用 scala.collection.mutable.ArrayBuffer
- c - 将变量强制转换为结构定义中定义的联合类型
- vulkan - 如何在 Vulkan 深度缓冲区中存储不受限制的深度范围
- java - 使用 EJB 客户端 jar 时出现 java.lang.NoClassDefFoundError
- python - 使用掩码在 Pandas DataFrame 中查找相等的列
- python - 我可以在命令提示符中定义路径但无法在脚本中定义文件路径?
- vue.js - Ag-Grid 20.1.0 + Vuetify 中的垂直滚动问题
- java - 无法覆盖 Junit 中的测试用例?
- python - 在烧瓶应用程序中注入配置后如何使用装饰器?