How to provide data for zsh completion system

Is there a standard way to provide a list of software switches, so that zsh can identify possible improvements? Or should it be provided directly to zsh developers, and only they can add zsh add-ons?

+3
source share
4 answers

Your first stop should be man zshcompsys.

Then you can see an example, for example /usr/share/zsh/functions/Completion/Unix/_vim.

+2
source

Z-Shell does not automatically know which possible switches binary files work with. To my knowledge, there is no standard way for a shell.

ZSH , . , zsh ssh, cvs, git, ls ..

, . zsh, echo $fpath, function path, zsh . /usr/local/share/zsh/4.3.17/function ( /zsh ), , _ - _ssh, _cvs .. .

, , _ssh, 4.3.17 ( ):


# Completions currently based on OpenSSH 5.9 (released on 2011-09-06).
#
# TODO: update ssh-keygen (not based on 5.9)
# TODO: sshd, ssh-keyscan, ssh-keysign

Z-: fpath

, zsh . Z-Shell - fpath.

+2

, foobar, GNU , :

compdef _gnu_generic foobar

. IMO - _describe.

  • _foobar :
#compdef foobar

cmds=(
'--one:option one'
'--four:option four'
'no-slashes:options do not need to start with a slash'
)

_describe 'foobar' cmds
  • - $fpath
  • compdef _foobar foobar
+2

If you are using ruby ​​with the optparse package, there is a hidden flag --*-completion-zsh=NAMEthat will display everything you need to complete for this ruby ​​program. Save it in a file named _NAME somewhere in yours $fpathand it will work. NAME should be exactly what you call in your program / script.

I use the folder in mine $HOMEfor this and added the path to $fpath, but this required an extra line in .zshrc:

autoload -U ~/.completion/*(:t)
0
source

Source: https://habr.com/ru/post/1744767/


All Articles