summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 22:05:45 +0000
committertv <tv@krebsco.de>2026-11-21 22:05:45 +0000
commitaca3ef46bbb942e5b7fab6ed1e839b7c21e3f72a (patch)
tree9cf0fc0d56e036b2e0323cebdfc33ec7a274e4f3
parentcf03acae35276734638d293125052becc7158cd5 (diff)
pkgs/claude-inbox: completion: grouped by kind
The commands, the options, REPOs, BRANCHes, in that order (complete -o nosort, where bash has it, i.e. since 4.4), as bash can't color them; and a name that's both a REPO and a BRANCH only once.
-rw-r--r--pkgs/claude-inbox.nix19
1 files changed, 13 insertions, 6 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix
index 021d5ee..d17b454 100644
--- a/pkgs/claude-inbox.nix
+++ b/pkgs/claude-inbox.nix
@@ -385,10 +385,10 @@ let
COMPREPLY=($(compgen -W "$(git -C "$src/''${repo:-.}" for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)" -- "$cur"))
return
fi
- # what's left: the commands (until there's one), the options (a
- # command's, once it's there), REPO, BRANCH; but nothing that's
- # there already (nor what that excludes)
- local cmds= opts="-d --vm --no-fetch" o left= repolist= branchlist=
+ # what's left, in groups: the commands (until there's one), the
+ # options (a command's, once it's there), REPO, BRANCH; but nothing
+ # that's there already (nor what that excludes)
+ local cmds= opts="-d --vm --no-fetch" o left= repolist= branchlist= g c
case $cmd in
"") cmds="--list --show --take --push" ;;
list) opts="$opts --by-remote" ;;
@@ -406,9 +406,16 @@ let
*) branchlist=$(_claude_inbox_branches ''${repo:-$repos}) ;;
esac
fi
- COMPREPLY=($(compgen -W "$cmds $left $(printf '%s\n' $repolist $branchlist | sort -u)" -- "$cur"))
+ COMPREPLY=()
+ for g in "$cmds" "$left" "$repolist" "$branchlist"; do
+ for c in $(compgen -W "$g" -- "$cur"); do
+ case " ''${COMPREPLY[*]} " in *" $c "*) ;; *) COMPREPLY+=("$c") ;; esac
+ done
+ done
}
- complete -F _claude_inbox claude-inbox
+ # in that order (bash 4.4 and later)
+ complete -o nosort -F _claude_inbox claude-inbox 2>/dev/null ||
+ complete -F _claude_inbox claude-inbox
'';
in
runCommand "claude-inbox" { meta.mainProgram = "claude-inbox"; } ''