Bash 自动补全:
- 在
~/.bashrc中添加以下内容:1
complete -W "$(grep '^Host ' ~/.ssh/config | awk '{print $2}')" ssh
- 在
Zsh 自动补全:
- 在
~/.zshrc中添加以下内容:1
2
3
4
5
6compdef _ssh_hosts ssh
_ssh_hosts() {
local hosts
hosts=("${(@f)$(<~/.ssh/config awk '/^Host / {print $2}')}")
_values 'hosts' $hosts
}
- 在
原文作者:Momo
原文链接:https://mo.xmomo521.top/2024/11/14/ssh补全设置/
发表日期:November 14th 2024, 3:40:51 pm
更新日期:November 14th 2024, 3:42:49 pm
版权声明:本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可
-
Next Postkube-proxy 源码分析
-
Previous Post排查consul拿不到锁引出常用的nfs参数