1

I'm using the sshrc package and its eponymous command to make the remote machine's shell source the contents of my local .sshrc file upon SSH login. However, I really like zsh's host autocompletion (based on the ~/.ssh/{config,authorized_keys} and /etc/hosts files).

Aliasing ssh to sshrc won't trick zsh (seems like it resolves the alias before loading completion configs). I have been trying to mess around with zsh's conf, e.g. copying /usr/share/zsh/5.3.1/functions/_ssh to _sshrc, editing said file and renaming its _ssh() function... no luck.

Would appreciate any pointers as I've got a few thousand hosts in my ssh config file.

1 Answer 1

3

This works for me using zsh 5.4.2

$ PS1='%% ' zsh -f
% rm ~/.zcompdump
% autoload -U compinit && compinit
% compdef sshrc=ssh
% sshrc ...

under the minimal configuration of zsh -f. This may be thwarted by your shell configuration; in that case you'll need to bisect your configuration to see what's screwing up what.

This trick was found by looking at the _ssh completion which shows for slogin an equality with ssh:

% grep compdef $fpath[-1]/_ssh
#compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp ssh-copy-id
% 
1
  • Works indeed, I will tailor your solution to my specific configuration. Thanks! Commented Dec 13, 2017 at 8:51

You must log in to answer this question.

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