Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felixoid/zsh-hoco
ZSH _hosts autocompletion extension
https://github.com/felixoid/zsh-hoco
autocomplete hosts zsh zsh-completion zsh-completions
Last synced: 2 months ago
JSON representation
ZSH _hosts autocompletion extension
- Host: GitHub
- URL: https://github.com/felixoid/zsh-hoco
- Owner: Felixoid
- License: apache-2.0
- Created: 2021-07-16T16:52:53.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T21:12:31.000Z (over 2 years ago)
- Last Synced: 2024-05-01T19:26:28.301Z (9 months ago)
- Topics: autocomplete, hosts, zsh, zsh-completion, zsh-completions
- Language: Shell
- Homepage:
- Size: 24.4 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
![Great curassow, image designed by rawpixel.com / Freepik](./docs/hoco.png)
# HOCO - zsh hosts completion
Small function to improve and extend original zsh `_hosts` completion function.## Objectives
The original zsh hosts completion is not extendable. And when you replace it with `zstyle -e ':completion:*:hosts' hosts 'reply=(...)'`, all original completions should be represented too.On the other hand, `_hosts` caches all hosts for autocompletion only once, and then uses it. And it's not so obvious how to reset it.
## Solution
The [hoco.zsh](./hoco.zsh) solves both `_hosts` flaws:- It updates the cache once per `$HOCO_CACHE_AGE` period, the default is 10 minutes
- It allows to update list of hosts dynamically. Each binary or function in `$HOCO_FUNCTIONS` array is executed asynchronously. The list of hosts for completion is updated on readiness.### Usage
The only thing you need to do is:
```
source hoco.zsh
some-function() {
echo host1 host2 # it does not matter if hosts are separated by spaces
echo host3 host4 # or by new lines (LF), or by tabs
}
HOCO_FUNCTIONS=(some-function)ssh
```