Skip to content

#756 Complete multiple recipes in bash completion script #2764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

antirais
Copy link
Contributor

@antirais antirais commented Jun 4, 2025

No description provided.

@casey
Copy link
Owner

casey commented Jul 1, 2025

Can you explain what this does and how it works? I don't understand the bash completion scripts at all 😅

@antirais
Copy link
Contributor Author

antirais commented Jul 2, 2025

This MR changes the generated completion script to additionally complete other recipes, e.g.

# currently usage
just pwd test # test recipe is not in the completion list
# after change you can complete other recipies
just pwd test some-other-recipe

The generated completion script diff is the following:

$ diff <(just --completions bash) <(cat ~/.local/share/bash-completion/just)
--- /dev/fd/63  2025-07-02 14:42:08.281502293 +0300
+++ /dev/fd/62  2025-07-02 14:42:08.281502293 +0300
@@ -34,7 +34,7 @@
                 if [[ ${cur} == -* ]] ; then
                     COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                     return 0
-                elif [[ ${cword} -eq 1 ]]; then
+                else
                     local recipes=$(just --summary 2> /dev/null)

                     if echo "${cur}" | \grep -qF '/'; then

It removes the limitation where completion stops working after first argument is provided.

@casey
Copy link
Owner

casey commented Jul 2, 2025

Why was elif [[ ${cword} -eq 1 ]]; then there in the first place?

@antirais
Copy link
Contributor Author

antirais commented Jul 3, 2025

That I do not know.

@casey casey enabled auto-merge (squash) July 3, 2025 22:47
@casey
Copy link
Owner

casey commented Jul 3, 2025

T_T

Well, in any case it seems to work, so merging. Thank you!

@casey casey merged commit ec87c05 into casey:master Jul 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants