I use the following zstyle commands to group completion items by their description:
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:ssh:*:users' users alice bob eve
zstyle ':completion:*:ssh:*:hosts' hosts lenovo hp asus
Which, for the ssh command, display something like this:
$ ssh <TAB>
-- remote host name --
asus hp lenovo
-- login name --
alice bob eve
My question: how can I change the descriptions for the tags users and hosts? That is, to replace "remote host name" by something like "hosts" and "login name" by "users".
I have tried the following, but it has no effect:
zstyle ':completion:*:ssh:*:hosts' group-name 'hosts'
zstyle ':completion:*:ssh:*:hosts' description 'hosts'
I'm still trying to grok
zstylemyself, so take what I'm saying with a bit of salt.First of all, this seems to work, but I don't think it's quite correct:
zstyleitself has helpful completion which you can use to figure out which field has which purpose. This is telling me:So with
zstyle ':completion:*:ssh:*:users', you're accidentally givingsshas completer,*as external command andhostsas argument. I can't quite figure out why it works nonetheless, but I believe this would be more correct, and still works for me:Further on, I don't think that these two do what you expect:
From what I can tell from
man zshcompsys,group-nameis used to group or ungroup several different tags (ie. if you wanted to configure whether users and hosts should be grouped together or not).descriptionisn't completed byzstyleand isn't documented in the manpage, so I guess you've made that up :)What I think you actually want, is, funnily enough...
format, which you've already set here globally:The
%dis replaced with the descriptions given by the tags. So to get your custom descriptions, simply set different formats for yourusers/hoststags, and replace%dwith the description you want:This works for me: