diff options
Diffstat (limited to 'pkgs/claude-inbox.nix')
| -rw-r--r-- | pkgs/claude-inbox.nix | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix index 74a665f..021d5ee 100644 --- a/pkgs/claude-inbox.nix +++ b/pkgs/claude-inbox.nix @@ -338,12 +338,17 @@ let completion = writeText "claude-inbox-completion" '' _claude_inbox() { local cur=''${COMP_WORDS[COMP_CWORD]} prev=''${COMP_WORDS[COMP_CWORD-1]} - local src=''${CLAUDE_INBOX_SRC:-$HOME/sync/src} i w cmd= words=() - # what's there so far: -d DIR, the command, and the words (bash - # splits --diff=WHAT into --diff, =, WHAT) + local src=''${CLAUDE_INBOX_SRC:-$HOME/sync/src} i w cmd= words=() used=" " + # what's there so far: -d DIR, the command, the options used (and + # what they exclude), and the words (bash splits --diff=WHAT into + # --diff, =, WHAT) for ((i = 1; i < COMP_CWORD; i++)); do w=''${COMP_WORDS[i]} case $w in + -f | --force | --pick) used="$used-f --force --pick " ;; + -*) used="$used$w " ;; + esac + case $w in -d) src=''${COMP_WORDS[i+1]}; i=$((i + 1)) ;; --vm) i=$((i + 1)) ;; --list | --show | --take | --push) cmd=''${w#--} ;; @@ -380,22 +385,28 @@ let COMPREPLY=($(compgen -W "$(git -C "$src/''${repo:-.}" for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)" -- "$cur")) return fi - local opts="-d --vm --no-fetch" more= + # 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= case $cmd in - "") opts="$opts --list --show --take --push --by-remote --diff -f --force --pick" ;; + "") cmds="--list --show --take --push" ;; list) opts="$opts --by-remote" ;; show) opts="$opts --diff" ;; take) opts="$opts -f --force --pick" ;; push) opts="$opts -f --force" ;; esac - [ -n "$repo" ] || more=$repos + for o in $opts; do + case $used in *" $o "*) ;; *) left="$left $o" ;; esac + done + [ -n "$repo" ] || repolist=$repos if [ -z "$branch" ]; then case $cmd in list | push) ;; - *) more="$more $(_claude_inbox_branches ''${repo:-$repos})" ;; + *) branchlist=$(_claude_inbox_branches ''${repo:-$repos}) ;; esac fi - COMPREPLY=($(compgen -W "$opts $(printf '%s\n' $more | sort -u)" -- "$cur")) + COMPREPLY=($(compgen -W "$cmds $left $(printf '%s\n' $repolist $branchlist | sort -u)" -- "$cur")) } complete -F _claude_inbox claude-inbox ''; |
