Add a autocompletation plugin for forgejo-cli

Fix #13909
This commit is contained in:
codeDude 2026-07-30 15:59:12 -06:00
commit f9d07dc1a7
No known key found for this signature in database
GPG key ID: 1BC3BE799EEED59E
2 changed files with 37 additions and 0 deletions

23
plugins/fj/README.md Normal file
View file

@ -0,0 +1,23 @@
# Forgejo CLI plugin
This plugin adds completion for the [Forgejo CLI](https://codeberg.org/forgejo-contrib/forgejo-cli).
To use it, add `fj` to the plugins array in your zshrc file:
```zsh
plugins=(... fj)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated when the
plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH/plugins/fj/_fj` completions script
- `$ZSH_CACHE_DIR/fj_version` version of Forgejo CLI, used to invalidate
the cache.

14
plugins/fj/fj.plugin.zsh Normal file
View file

@ -0,0 +1,14 @@
# Autocompletion for the Forgejo CLI (fj).
if (( ! $+commands[fj] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `fj`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fj" ]]; then
typeset -g -A _comps
autoload -Uz _fj
_comps[fj]=_fj
fi
fj completion --shell zsh >| "$ZSH_CACHE_DIR/completions/_fj" &|