Links
- zstyle builtin (in zsh/util)
- Writing your own completion functions and a very high-level introduction into compsys.
- The chapter about compsys in "The Guide"
- 6.4: How the shell finds the right completions: context
- 6.6: Command widgets
_complete_help
,_most_recent_file
,_next_tags
_read_comp
: on-the-fly completion. it prompts for you to enter a type of completion; usually this will be the name of a completion function with the required arguments. Thus it's not much use unless you already have some fairly in-depth knowledge of how the system is set up. For example, try it, then enter_files -/
, which generates directories. There is a rudimentary completion for the function names built into it. The next time you start it up, it will produce the same type of completion. You need to give it a numeric prefix to tell it to prompt for a different sort._generic
- 6.7: Matching control and controlling where things are inserted
- The
matcher-list
style takes an array value.
- The
- 6.8: Tutorial: Writing autocompletion for Perforce/p4
- compinit
compinit
checks to ensure that the completion system only uses files and directories either owned by or writable only by root or the current user. If this isn't true, there is an interactive prompt. You can pass-u
to force it to use the files regardless,-i
to ignore the insecure files or-C
to skip this check.
- compctl (alt)
- compadd
- man zshcompsys
- man zshcompwid
- Completion built in commands.
- apress.com: From Bash to Z Shell Conquering the Command Line has the gentlest introduction into the subject.
- existing completion code
- e.g. like for "pine" for example.
- Completion functions for zsh commands
- tag-order
- Prediction
- zsh/predict-on
- zstyles for prediction: Predict-on and colored/higlighted predicted text
autoload -Uz predict-on ; zle -N predict-on ; zle -N predict-off ; bindkey '^X9' predict-on ; bindkey '^X0' predict-off
- Examples
Plugins / Examples (not necessarily for zsh)
- zsh-users/zsh-history-substring-search
- also available as an oh-my-zsh plugin.
- junegunn/fzf
- If you're on a TMUX session,
CTRL-T
will launch fzf in a new split-window. You may disable this tmux integration by settingFZF_TMUX
to 0.
- If you're on a TMUX session,
- garybernhardt/selecta
- tarruda/zsh-autosuggestions
- zsh-fuzzy-match/fuzzy-match
The Context
:<zsh_system:completion|zle>:<func>:<completer>:<command>:<argument>:<tag>
Here,
Part | Description |
---|---|
zsh_system | Always completion when looked up by the completion system. It's zle when used by zle widgets. |
func | Often empty. Holds the name of the invoking function. e.g. if you bound \C-xe to _expand_word , then this would be expand-word . It's complete-word for _correct_word |
completer | Such as complete , expand , correct , prefix , match , etc. |
command | The name of the command when completing a command, or a pseudo name such as -subscript- , -default- , -parameter- , -redirect- , etc. (These are keys of the _comps hash) |
argument | Most useful when command is a real command. It describes where in the arguments to that command we are. e.g. argument-rest , argument-1 , option-o-1 , etc. |
tag | TODO |
Snippets
compdef what=whence # The :r removes the suffix from the result, and the :t takes away the directory part. _ck_complete_vs() { compadd $VIMWS/*.vs(.:r:t) } compdef _ck_complete_vs vs # try this to learn some new cool things # _subscript handles completion for the "-subscript-" context # e.g. if you type "print ${_comps[" and press ^D which _subscript