dotfiles/dot_config/zsh/files/sshcomp.zsh
2025-03-24 16:26:14 +01:00

21 lines
2.1 KiB
Bash

zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*' sort false
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*' group-name ''
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*' verbose yes
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
zstyle ':completion:*:(scp|sshfs|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:(ssh|mosh):*' group-order users hosts-domain hosts-host users hosts-ipaddr
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*:users' ignored-patterns '*'
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback localhost broadcasthost 'ip6-*'
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' '*.eeleater.org'
zstyle ':completion:*:(ssh|scp|sshfs|mosh|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.*' '255.255.255.255' '::1' 'fe80::*' 'ff02::*'
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r ~/.ssh/known_hosts_priv ] && _ssh_hosts_priv=(${${${${(f)"$(<$HOME/.ssh/known_hosts_priv)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts_priv=()
[ -r ~/.ssh/known_hosts_work_ojs ] && _ssh_hosts_ojs=(${${${${(f)"$(<$HOME/.ssh/known_hosts_work_ojs)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts_ojs=()
[ -r ~/.ssh/known_hosts_work_danrw ] && _ssh_hosts_work_danrw=(${${${${(f)"$(<$HOME/.ssh/known_hosts_work_danrw)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts_work_danrw=()
[ -r ~/.ssh/known_hosts_misc ] && _ssh_hosts_work_misc=(${${${${(f)"$(<$HOME/.ssh/known_hosts_misc)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts_work_misc=()
[ -r ~/.ssh/known_hosts_work_lzv ] && _ssh_hosts_work_lzv=(${${${${(f)"$(<$HOME/.ssh/known_hosts_work_lzv)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts_work_lzv=()
hosts=( "$_ssh_hosts[@]" "$_ssh_hosts_priv[@]" "$_ssh_hosts_work_ojs[@]" "$_ssh_hosts_work_danrw[@]" "$_ssh_hosts_misc[@]" "$_ssh_hosts_work_lzv[@]" )
zstyle ':completion:*:hosts' hosts $hosts