Skip to content

Valodim/zsh-capture-completion

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

zsh-capture-completion

This is a proof of concept script for capturing completion matches generated by the zshcompsys completion system. Because of the very complicated nature of zsh's completions, this can (to my knowledge) not be done in a straightforward way, and this script is accordingly hacky.

Method

Roughly, a pseudo-interactive zsh session is spawned using zpty, and a buffer string plus a tab character is sent so the complete-word widget is executed. To capture the hits, the compadd function is selectivly overridden in an inline-sourced file, capturing matches by injecting a parameter to the original compadd call and outputting matches to stdout.

Usage

Usage:

capture.zsh bufferstring

Examples:

capture.zsh 'vim -'
capture.zsh 'vim --'
capture.zsh 'vim --r'
capture.zsh 'echo *('
capture.zsh 'scp hostname:'

For an application of ths technique, check out vim-zsh-completion.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages