https://github.com/valodim/zsh-capture-completion
https://github.com/valodim/zsh-capture-completion
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/valodim/zsh-capture-completion
- Owner: Valodim
- License: mit
- Created: 2013-10-03T00:48:58.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T07:31:49.000Z (about 2 years ago)
- Last Synced: 2025-04-14T22:54:13.012Z (about 1 year ago)
- Language: Shell
- Size: 200 KB
- Stars: 90
- Watchers: 2
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/Valodim/vim-zsh-completion).