72 lines
2.5 KiB
Text
72 lines
2.5 KiB
Text
|
|
# shellcheck shell=bash
|
||
|
|
# shellcheck disable=SC2207 # Standard pattern for bash completions
|
||
|
|
# Bash completion for Claude Code CLI
|
||
|
|
|
||
|
|
command -v claude &>/dev/null || return
|
||
|
|
|
||
|
|
_claude_completions() {
|
||
|
|
local cur prev opts commands
|
||
|
|
COMPREPLY=()
|
||
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||
|
|
|
||
|
|
# Subcommands
|
||
|
|
commands="doctor install mcp plugin setup-token update"
|
||
|
|
|
||
|
|
# All options
|
||
|
|
opts="-c -d -h -p -r -v
|
||
|
|
--add-dir --agent --agents --allow-dangerously-skip-permissions
|
||
|
|
--allowed-tools --append-system-prompt --betas --chrome --continue
|
||
|
|
--dangerously-skip-permissions --debug --debug-file --disable-slash-commands
|
||
|
|
--disallowed-tools --fallback-model --file --fork-session --help --ide
|
||
|
|
--include-partial-messages --input-format --json-schema --max-budget-usd
|
||
|
|
--mcp-config --model --no-chrome --no-session-persistence --output-format
|
||
|
|
--permission-mode --plugin-dir --print --replay-user-messages --resume
|
||
|
|
--session-id --setting-sources --settings --strict-mcp-config
|
||
|
|
--system-prompt --tools --verbose --version"
|
||
|
|
|
||
|
|
# Handle option arguments
|
||
|
|
case "${prev}" in
|
||
|
|
--model|--fallback-model)
|
||
|
|
COMPREPLY=( $(compgen -W "sonnet opus haiku" -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
--permission-mode)
|
||
|
|
COMPREPLY=( $(compgen -W "acceptEdits bypassPermissions default delegate dontAsk plan" -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
--input-format)
|
||
|
|
COMPREPLY=( $(compgen -W "text stream-json" -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
--output-format)
|
||
|
|
COMPREPLY=( $(compgen -W "text json stream-json" -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
--add-dir|--plugin-dir|--debug-file)
|
||
|
|
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
--settings|--mcp-config)
|
||
|
|
COMPREPLY=( $(compgen -f -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
install)
|
||
|
|
COMPREPLY=( $(compgen -W "stable latest" -- "${cur}") )
|
||
|
|
return 0
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
# Complete subcommands or options
|
||
|
|
if [[ ${cur} == -* ]]; then
|
||
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||
|
|
elif [[ ${COMP_CWORD} -eq 1 ]]; then
|
||
|
|
COMPREPLY=( $(compgen -W "${commands} ${opts}" -- "${cur}") )
|
||
|
|
else
|
||
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||
|
|
fi
|
||
|
|
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
|
||
|
|
complete -F _claude_completions claude
|