Zsh autocompletion: Difference between revisions

From wikinotes
Line 59: Line 59:
= Syntax =
= Syntax =
<blockquote>
<blockquote>
== Filesystem and Setup ==
<blockquote>
Each program has it's own autocompletion script. It is named after the program with a prefix of '_'.
The first line in the program should be '#compdef <programName>'
<source lang="bash">
touch ~/.zsh/completion/_hello
#### ~/.zsh/completion/_hello
#compdef hello
...
####
</source>
</blockquote><!-- filesystem and setup -->
== Actions ==
== Actions ==
<blockquote>
<blockquote>

Revision as of 22:57, 24 July 2021

Documentation

official docs http://zsh.sourceforge.net/Doc/Release/Completion-System.html

Tutorials

completion funcs https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
intro to autocomp https://askql.wordpress.com/2011/01/11/zsh-writing-own-completion/
intermediate autocomp http://www.linux-mag.com/id/1106/

Locations

/usr/share/zsh/functions/Completion/*/* completion scripts (see $fpath)

Notes

zsh completion configuration

Syntax

zsh completion basics
zsh completion testing
zsh completion examples
Completer Functions
zsh completion _arguments
zsh completion _describe
zsh completion _alternative

Syntax

Actions

_normal                --> A normal argument. Expects a word (this seems to be the default)
_files                 --> Complete filepaths
_net_interfaces        --> Net Interfaces
_users                 --> users
_groups                --> groups
_parameters            --> expect a word argument to follow (can be file, word... pretty much anything. Can be restricted.)