summaryrefslogtreecommitdiffstats
path: root/pkgs/claude-inbox.nix
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
commitcf03acae35276734638d293125052becc7158cd5 (patch)
treee1966257160bfb53e7dbc687227569fb830cf872 /pkgs/claude-inbox.nix
parenta2de267ba5819d1664c4dd4995b81c70b3ebace8 (diff)
pkgs/claude-inbox: completion: the command's options only, and not again
Without a command, it offers the commands, but none of their options; with one, its options, and no other command; and no option that's there already, nor --pick with -f, --force, or the other way round.
Diffstat (limited to 'pkgs/claude-inbox.nix')
-rw-r--r--pkgs/claude-inbox.nix27
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
'';