suppose I have following entry in my /etc/hosts
192.168.1.10 server1.mydomain.com
and I have a directory SERVER-FILES in current dir. I want to scp the directory SERVER-FILES somewhere. I type SE and use autocompletion to complete the directory name:
$ scp -rp SE<TAB>
This completion should be totally unambiguous. But zsh autocomplletion tries to be too smart, and treats hostnames case-insensitive, and thus attempts to match SE to hostnames:
$ scp -rp SE<TAB>
SERVER-FILES/
server1.mydomain.com
How can I disable this annoying feature, where zsh is trying to match hostnames case-insensitive, and therefore completes SE<TAB> to server1.mydomain.com` ?
UPDATE:
Based on suggestions from @zeppelin, I have changed the following line in the ssh completion file Unix/_ssh:
- compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
+ compadd "$@" $config_hosts
but that did not help. It has absolutely no effect.
And I don't understand the answer from @Tomasz Pala. My zsh completion is not case-insensitive.
Please sopmebody just tell me what I need to change in /usr/share/zsh/functions/Completion/Unix/_foo to change this behaviour.
UPDATE 2
I have finally narrowed the problem down, and found out why the solution from @Tomasz Pala did work for him, but not for me:
When I change the Unix/_hosts file on a newly setup machine/user account, the solution works.
scp -r SE<TAB>
The above command ignores server1.mydomain.com in /etc/hosts, and only offers local directory SERVER-FILES for completion.
But this does not work for me on my existing user account, because I have
server.mydomain.com in my ~/.ssh/config. When I remove the entry, then everything works as desired.
But how can I make this hack work even with my current ~/.ssh/config ?
zstyle ':completion::complete:scp:*' hosts offscpcould complete either a filename or a hostname at that position, so matches both the directory and the hostname../SEto tell zsh that you mean a file..zshrc. Please see myUPDATE 2. I am not using any framework, just plain.zshrc. The.zshrcnow contains the added rules forsshandscp. Currently, when I typescp S<TAB>it completesserverfrom my hosts file. Same forssh S<TAB>where it also completesserver. I would like to change that, so thatscp -rp S<TAB>only completes local file matchingS*, or if no such file exists, does not complete anything.