2025-03-14 21:59:59 -06:00
# complete
2025-12-16 10:20:31 -07:00
> Get and set argument autocompletion rules of shell commands in Bash.
> The specified completions will be invoked when `<Tab>` is pressed in Bash.
> See also: `compgen`, `compopt`.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-complete>.
2025-03-14 21:59:59 -06:00
2025-12-16 10:20:31 -07:00
- Set arguments of a command to autocomplete through a function (completion response is sent in `COMPREPLY` variable):
2025-03-14 21:59:59 -06:00
`complete -F {{function}} {{command}}`
2025-12-16 10:20:31 -07:00
- Set arguments of a command to autocomplete through another command (`$1` is the command, `$2` is the argument the cursor is on, and `$3` is the argument preceding the cursor):
2025-03-14 21:59:59 -06:00
`complete -C {{autocomplete_command}} {{command}}`
2025-12-16 10:20:31 -07:00
- Set arguments of a command to autocomplete to shell builtins:
`complete -b {{command}}`
2025-03-14 21:59:59 -06:00
- Apply autocompletion without appending a space to the completed word:
`complete -o nospace -F {{function}} {{command}}`
2025-12-16 10:20:31 -07:00
- List all loaded complete specifications:
`complete -p`
- List loaded complete specifications for a command:
`complete -p {{command}}`