fix(completion): accept instance-qualified hosts for a bare name in zsh
With several NetBox instances, netssh offers "prod/fsn1-bx1…" for the typed text "fsn1". compadd discarded these matches because they do not start with the typed word, so <Tab> found nothing. The matcher 'l:|=*' lets zsh accept text before the typed word; netssh has already filtered the candidates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f00d69b6f
commit
6243514def
2 files changed
+7
-6
No files matched your search
@@ -58,12 +58,13 @@ _netssh() {
|
||||
_describe -t commands 'netssh command' items $nospace && ret=0
|
||||
fi
|
||||
if (( $#plain )); then
|
||||
# netssh already filtered the hosts, also by the name after an instance
|
||||
# prefix: "fsn1" offers "prod/fsn1-…". 'l:|=*' lets zsh accept text
|
||||
# before the typed word instead of discarding these matches.
|
||||
local -a group=(-J hosts)
|
||||
# Directive 32: keep the order supplied by netssh.
|
||||
if (( directive & 32 )); then
|
||||
compadd -V hosts -X '%Bhosts%b' $nospace -- $plain && ret=0
|
||||
else
|
||||
compadd -J hosts -X '%Bhosts%b' $nospace -- $plain && ret=0
|
||||
fi
|
||||
(( directive & 32 )) && group=(-V hosts)
|
||||
compadd $group -X '%Bhosts%b' -M 'l:|=*' $nospace -- $plain && ret=0
|
||||
fi
|
||||
# Directive 4: no file completion as a fallback.
|
||||
if (( ! $#lines && ! (directive & 4) )); then
|
||||
|
||||
Reference in new issue
Block a user