Skip to content

dist/tools/zsh-completion: Add completion for DOCKER_IMAGE and OPENOCD_FTDI_ADAPTER#21860

Merged
maribu merged 3 commits intoRIOT-OS:masterfrom
maribu:dist/tools/zsh-completion
Nov 9, 2025
Merged

dist/tools/zsh-completion: Add completion for DOCKER_IMAGE and OPENOCD_FTDI_ADAPTER#21860
maribu merged 3 commits intoRIOT-OS:masterfrom
maribu:dist/tools/zsh-completion

Conversation

@maribu
Copy link
Copy Markdown
Member

@maribu maribu commented Nov 8, 2025

Contribution description

This extends the command completion for zsh for the variables DOCKER_IMAGE= and OPENOCD_FTDI_ADAPTER=. Both lists are collected at run time from what is actually available on the system, so that we don't need to keep on maintaining lists of facts here.

Testing procedure

  1. Install the completion as described in the readme
  2. Start a new zsh shell
  3. cd into a RIOT repo and type make OPENOCD_F and hit tab, it should complete to make OPENOCD_FTDI_ADAPTER=. Tab again should list available FTDI adapter configs in OpenOCD and complete them as usual
  4. type make DOCKER_I and hit tab. It should complete to make DOCKER_IMAGE=. Tab again should list docker images installed on the system and complete them as usual

Issues/PRs references

None

@maribu maribu requested a review from mguetschow November 8, 2025 10:09
@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 8, 2025
@github-actions github-actions bot added the Area: tools Area: Supplementary tools label Nov 8, 2025
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Nov 8, 2025

Note: I have not tested this on my other machine that uses podman instead of docker. That should probably be done prior to merging.

@riot-ci
Copy link
Copy Markdown

riot-ci commented Nov 8, 2025

Murdock results

✔️ PASSED

4710d56 dist/tools/zsh-completion: rename file .sh --> .zsh

Success Failures Total Runtime
1 0 1 01m:14s

Artifacts

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Nov 8, 2025

Shellcheck seems to be unhappy with the syntax of the for loop, and I don't quite understand why it works. From what I found, for loops in zsh also need to be for ... in ...; do ... done, but if I change it to that it doesn't seem to work anymore 😅

Unrelated, but perhaps you could also add this to the script?

#!/usr/bin/env zsh
# shellcheck shell=zsh

Although it does not stop shellcheck from checking (and complaining)...

@crasbe crasbe added the CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs label Nov 8, 2025
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Nov 8, 2025

Hmm, a shebang I would expect in a user facing script file. The zsh completion sciprt is not expected to ever be run directly by a user. I'd rather not keep it without the shebang to prevent users running the script directly.

shellcheck doesn't support zsh syntax and trips early on over the function definition syntax. It would be possible to change some parts to common POSIX syntax, but other parts require e.g. array variables as part of the completion API of zsh. There wouldn't also be a clear benefit in having this completion file more portable, as any other shell adapting the zsh completion API probably would also be compatible with the zsh syntax used here.

I could rename the file to .zsh; I think iur CI won't try to run shellcheck on .zsh files.

@maribu maribu requested a review from jia200x as a code owner November 8, 2025 14:18
@github-actions github-actions bot added the Area: doc Area: Documentation label Nov 8, 2025
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Nov 8, 2025

It does work just fine with podman 😄

Copy link
Copy Markdown
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash :)

@maribu maribu force-pushed the dist/tools/zsh-completion branch from 37d7933 to 4710d56 Compare November 9, 2025 07:06
@maribu maribu enabled auto-merge November 9, 2025 07:06
@maribu maribu added this pull request to the merge queue Nov 9, 2025
Merged via the queue into RIOT-OS:master with commit 7a0d5bd Nov 9, 2025
25 checks passed
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Nov 9, 2025

Thx ❤️

@maribu maribu deleted the dist/tools/zsh-completion branch November 9, 2025 08:10
@leandrolanzieri leandrolanzieri added this to the Release 2026.01 milestone Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: doc Area: Documentation Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants