1

my zsh completion file _cssh has this line, which completes hosts only from /etc/hosts:

'*:userhostport: _alternative hosts:host:_hosts usersathosts:userathost:_user_at_host'

how do I make it complete hosts defined in my ~/.ssh/config, same as ssh does ? the full _ssh file is here

I don't need to complete usernames. Just hostnames from /etc/hosts as well as hosts defined in ~/.ssh/config. Also, it is important that multiple hosts can be completed (cssh is cluster ssh and takes multiple hosts, unlike ssh)

1 Answer 1

0

Please, can you try to update the alternative from both /etc/hosts and ~/.ssh/config.

"*:userhostport: _alternative 'hosts from /etc/hosts:hosts:host:_hosts' 'hosts from ~/.ssh/config:hosts:host:_ssh_config_hosts' usersathosts:userathost:_user_at_host"

And adding the function below to the _cssh file, before the _cssh function definition.

_ssh_config_hosts() { local hosts hosts=("${(@f)${(ps:\n:)${(f)"$(<$HOME/.ssh/config)"}:#Host*}") _describe -t hosts 'hosts from ~/.ssh/config' hosts }

Then you should be Ok with /etc/hosts and ~/.ssh/config.

3
  • I have applied your changes, but it does not work and I get: _cssh:2: unmatched " error. Here is the complete _cssh file: ctxt.io/2/AABISTd9Fg Commented Mar 29 at 5:29
  • Can you try this. '*:userhostport: _alternative "hosts from /etc/hosts:hosts:host:_hosts" "hosts from ~/.ssh/config:hosts:host:_ssh_config_hosts" "usersathosts:userathost:_user_at_host"'
    – Fkiran
    Commented Mar 31 at 15:15
  • _cssh:2: unmatched " Commented Mar 31 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .