From aca3ef46bbb942e5b7fab6ed1e839b7c21e3f72a Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 21 Nov 2026 22:05:45 +0000 Subject: 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. --- pkgs/claude-inbox.nix | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'pkgs') 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"; } '' -- cgit v1.3.1