Write your own oh-my-zsh plugin

I want to write a simple plugin to oh-my-zsh

complete only possible server arguments.

Example 1:

$ myserver st    # hits tab
start stop

      

Example 2:

$ myserver    # hits tab
start stop restart

      

According to the wiki I created a file named coffee plugin~/.oh-my-zsh/custom/plugins/myserver/myserver.plugin.zsh

sample content (I tried brew plugin ) but completion does not work (any of those described in the file). Also, the error is thrown:

_arguments:comparguments:312: can only be called from completion function

      

I checked similar issues and mine fpath

includes ~/.oh-my-zsh/custom/plugins/myserver

.

What am I missing? This should be pretty simple ... Thanks for the help

+3


source to share


1 answer


From your post, I would assume you named the file myserver.plugin.zsh

, however, if used to define a completion function, its name must start with an underscore. It seems common that the command name follows an underscore, i.e. In your case _myserver

.

However, without explicit code for you , I can't help you anymore. You might want to check this blog for further help.



I should note that it is completely optional to create the completion function as a plugin oh-my-zsh

; just create it as a separate piece of code.

+5


source







All Articles