Skip to content

Conversation

@spkane
Copy link

@spkane spkane commented Dec 22, 2025

I have only tested the Bash version of this change, but I used Claude Code to update the rest of them to match the general logic.

@spkane
Copy link
Author

spkane commented Dec 22, 2025

Fixes: #2394

@spkane
Copy link
Author

spkane commented Dec 22, 2025

Related to: #3017, #3012, #2686, and maybe others...

@hposca
Copy link

hposca commented Jan 5, 2026

This is the diff, which worked on my machine (running zsh 5.9 (x86_64-pc-linux-gnu) just 1.46.0 on Linux 6.12.63-1-lts), using your completions/just.zsh as base:

diff --git a/completions/just.zsh b/completions/just.zsh
index a69f7c4d..69e40ef4 100644
--- a/completions/just.zsh
+++ b/completions/just.zsh
@@ -44,6 +44,7 @@ _just() {
 '--request=[Execute <REQUEST>. For internal testing purposes only. May be changed or removed at any time.]: :_default' \
 '-s+[Show recipe at <PATH>]: :(_just_commands)' \
 '--show=[Show recipe at <PATH>]: :(_just_commands)' \
+'()--usage=[Print recipe usage information]:PATH:_default' \
 '--check[Run \`--fmt\` in '\''check'\'' mode. Exits with 0 if justfile is formatted correctly. Exits with 1 and prints a diff if formatting is required.]' \
 '--clear-shell-args[Clear shell arguments]' \
 '(-q --quiet)-n[Print what just would do without doing it]' \
@@ -101,7 +102,7 @@ _just() {
 
             # Check if --global-justfile or -g flag is present
             local use_global=""
-            for word in ${words[@]}; do
+            for word in "${words[@]}"; do
                 if [[ "$word" == "-g" || "$word" == "--global-justfile" ]]; then
                     use_global="--global-justfile"
                     break
@@ -128,7 +129,7 @@ _just() {
                 _message "value"
             elif [[ $recipe ]]; then
                 # Show usage message
-                _message "`just --show $recipe`"
+                _message "`just $use_global --show $recipe`"
                 # Or complete with other commands
                 #_arguments -s -S $common '*:: :_just_commands'
             else
@@ -148,29 +149,24 @@ _just_commands() {
 
     # Check if --global-justfile or -g flag is present
     local use_global=""
-    for word in ${words[@]}; do
+    for word in "${words[@]}"; do
         if [[ "$word" == "-g" || "$word" == "--global-justfile" ]]; then
             use_global="--global-justfile"
             break
         fi
     done
 
-    local variables; variables=(
-        ${(s: :)$(_call_program commands just $use_global --variables)}
-    )
-    local commands; commands=(
-        ${${${(M)"${(f)$(_call_program commands just $use_global --list)}":#    *}/ ##/}/ ##/:Args: }
-    )
+    # Get recipes from --summary (includes full module::recipe paths)
+    local summary_output=$(_call_program commands just $use_global --summary)
 
-    if compset -P '*='; then
-        case "${${words[-1]%=*}#*=}" in
-            *) _message 'value' && ret=0 ;;
-        esac
-    else
-        _describe -t variables 'variables' variables -qS "=" && ret=0
-        _describe -t commands 'just commands' commands "$@"
-    fi
+    # Split into array properly
+    local -a recipes
+    recipes=("${(@s: :)summary_output}")
 
+    # Add recipes directly to completion
+    compadd -a recipes
+
+    return 0
 }
 
 if [ "$funcstack[1]" = "_just" ]; then
@@ -178,16 +174,14 @@ if [ "$funcstack[1]" = "_just" ]; then
 _just_variables() {
     [[ $PREFIX = -* ]] && return 1
     integer ret=1
-
     # Check if --global-justfile or -g flag is present
     local use_global=""
-    for word in ${words[@]}; do
+    for word in "${words[@]}"; do
         if [[ "$word" == "-g" || "$word" == "--global-justfile" ]]; then
             use_global="--global-justfile"
             break
         fi
     done
-
     local variables; variables=(
         ${(s: :)$(_call_program commands just $use_global --variables)}
     )

hposca and others added 3 commits January 6, 2026 08:22
With the help of ClaudeAI (and lots of patience)

Now `just -g <TAB>` is working as expected including for modules, so one
can run `just -g mod<TAB>` and it will be autocompleted to `just -g
module::` and you can then `just -g module::<TAB>` to see all the
available recipes.
@spkane
Copy link
Author

spkane commented Jan 8, 2026

@casey It is likely this PR needs some confirmation for the non-bash/ZSH shells, but is there anything I can do to help get this merged as it would be really helpful.

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