From 432596e9918dd0fea65af8c1788a54130a4fca6e Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Thu, 1 Aug 2024 20:30:25 +0200 Subject: [PATCH] feat(arduino-cli): add completion plugin (#12522) --- plugins/arduino-cli/README.md | 8 ++++++++ plugins/arduino-cli/arduino-cli.plugin.zsh | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 plugins/arduino-cli/README.md create mode 100644 plugins/arduino-cli/arduino-cli.plugin.zsh diff --git a/plugins/arduino-cli/README.md b/plugins/arduino-cli/README.md new file mode 100644 index 000000000..91bda9067 --- /dev/null +++ b/plugins/arduino-cli/README.md @@ -0,0 +1,8 @@ +# Arduino CLI plugin + +This plugin adds completion for the [arduino-cli](https://github.com/arduino/arduino-cli) tool. +To use it, add `arduino-cli` to the plugins array in your zshrc file: + +```zsh +plugins=(... arduino-cli) +``` diff --git a/plugins/arduino-cli/arduino-cli.plugin.zsh b/plugins/arduino-cli/arduino-cli.plugin.zsh new file mode 100644 index 000000000..e4fdcf9fe --- /dev/null +++ b/plugins/arduino-cli/arduino-cli.plugin.zsh @@ -0,0 +1,14 @@ +if (( ! $+commands[arduino-cli] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `arduino-cli`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_arduino-cli" ]]; then + typeset -g -A _comps + autoload -Uz _arduino-cli + _comps[arduino-cli]=_arduino-cli +fi + +# Generate and load arduino-cli completion +arduino-cli completion zsh >! "$ZSH_CACHE_DIR/completions/_arduino-cli" &|