3

I have a command xssh that is a wrapper of the original ssh command. I need a Zsh completion for this command, and the completion rules are exactly the same as zsh. So what I add a the following to the _xssh file

#compdef xssh
compdef xssh=ssh

I can load the completion for the command, but the problem is that if it's the first time when I use the xssh command in a terminal and type <TAB>, I have to type <TAB> twice so that the completion can start to work. For example, I have to type xssh ho<TAB><TAB> to get xssh hostname. But after that, I only have to type xssh ho<TAB> to get xssh hostname (hostname is unique in my .ssh/config file). So do you have any idea how to fix this?

This situation will not happen if I write the completion from scratch as I did for my other commands

zijuexiansheng
  • 337
  • 3
  • 14
  • https://unix.stackexchange.com/questions/32075/zsh-takes-two-tabs-to-complete-filenames this helped me. – Gal Aug 16 '17 at 15:08
  • 1
    @Gal Thanks. But my issue is kind of different. For example, if I launch the terminal, and type `xssh ho`, it will complete the content I want. Within the same terminal, next time if I type `xssh ano`, it will complete the content, say `xssh another_host` for me immediately. To me, it seems that the `compdef xssh=ssh` will not really load the completion from ssh or assign it to the xssh command until it is really required to do so. My other customized Zsh completions works perfectly as I expected. – zijuexiansheng Aug 16 '17 at 15:52
  • @zijuexiansheng did you find a solution? I have the same issue – artfulrobot Nov 26 '19 at 09:59

1 Answers1

0

I had same issue.

I had a completion file called _gd in my fpath, which looked like this:

#compdef gd
function _gd {
   ... my code ...
   _describe gd list
}

First time I started a shell it needed 2 tab presses to work, then after that just a single one.

To fix it all I had to do was remove the function {} part, so it now looks just like

#compdef gd
...mycode...
_describe gd list
artfulrobot
  • 20,637
  • 11
  • 55
  • 81