From 4633d2a0374f79c3306e60b603377606664e8a24 Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Wed, 19 Nov 2025 02:50:12 +0100 Subject: [PATCH] tools/ci.sh: Add zsh and fish shell completion support. This commit adds custom command completion functions for both the zsh and fish shell. The behaviour for those new completions follow the existing completion for the bash shell, including the way to generate the completion alias (with appropriately named command line switches). Signed-off-by: Alessandro Gatti --- docs/develop/gettingstarted.rst | 10 +++++++++- tools/ci.sh | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/develop/gettingstarted.rst b/docs/develop/gettingstarted.rst index cb479458e1..a6afc5cad8 100644 --- a/docs/develop/gettingstarted.rst +++ b/docs/develop/gettingstarted.rst @@ -338,7 +338,15 @@ If you use the bash shell, you can add a ``ci`` command with tab completion: .. code-block:: bash - $ eval `tools/ci.sh --bash-completion` + $ eval $(tools/ci.sh --bash-completion) + +For the zsh shell, replace ``--bash-completion`` with ``--zsh-completion``. +For the fish shell, replace ``--bash-completion`` with ``--fish-completion``. + +Then, typing: + +.. code-block:: bash + $ ci unix_cov This will complete the ci step name to ``unix_coverage_``. diff --git a/tools/ci.sh b/tools/ci.sh index 63eed15bea..fa7a529b21 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -1049,6 +1049,14 @@ function _ci_bash_completion { echo "alias ci=\"$(readlink -f "$0")\"; complete -W '$(grep '^function ci_' $0 | awk '{print $2}' | sed 's/^ci_//')' ci" } +function _ci_zsh_completion { + echo "alias ci=\"$(readlink -f "$0"\"); _complete_mpy_ci_zsh() { compadd $(grep '^function ci_' $0 | awk '{sub(/^ci_/,"",$2); print $2}' | tr '\n' ' ') }; autoload -Uz compinit; compinit; compdef _complete_mpy_ci_zsh $(readlink -f "$0")" +} + +function _ci_fish_completion { + echo "alias ci=\"$(readlink -f "$0"\"); complete -c ci -p $(readlink -f "$0") -f -a '$(grep '^function ci_' $(readlink -f "$0") | awk '{sub(/^ci_/,"",$2); print $2}' | tr '\n' ' ')'" +} + function _ci_main { case "$1" in (-h|-?|--help) @@ -1057,6 +1065,12 @@ function _ci_main { (--bash-completion) _ci_bash_completion ;; + (--zsh-completion) + _ci_zsh_completion + ;; + (--fish-completion) + _ci_fish_completion + ;; (-*) echo "Unknown option: $1" 1>&2 exit 1