1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-23 19:24:11 +02:00

complete, compgen, compopt: refresh pages (#17638)

Co-authored-by: Dylan <145150333+dmmqz@users.noreply.github.com>
This commit is contained in:
Managor 2025-08-16 10:51:18 +03:00 committed by GitHub
parent 1bd174c881
commit e9827040a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 14 deletions

View file

@ -1,15 +1,21 @@
# compgen # compgen
> A built-in command for auto-completion in Bash, which is called on pressing `<Tab>` key twice. > Bash built-in command for generating possible completion matches in Bash.
> Usually used within custom completion functions.
> See also: `complete`, `compopt`.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compgen>. > More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compgen>.
- List all commands that you could run: - List all shell built-ins, aliases, functions and executables that you could run:
`compgen -c` `compgen -c`
- List all commands that you could run that start with a specified string: - List all commands that you could run that start with a specified string and save results to `COMPREPLY`:
`compgen -c {{str}}` `compgen -V COMPREPLY -c {{str}}`
- Match against a wordlist:
`compgen -W "{{apple orange banana}}" {{a}}`
- List all aliases: - List all aliases:
@ -30,7 +36,3 @@
- List all users on the system: - List all users on the system:
`compgen -u` `compgen -u`
- Display help:
`compgen --help`

View file

@ -1,16 +1,30 @@
# complete # complete
> Get argument autocompletion to shell commands. > 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>. > More information: <https://www.gnu.org/software/bash/manual/bash.html#index-complete>.
- Apply a function that performs autocompletion to a command: - Set arguments of a command to autocomplete through a function (completion response is sent in `COMPREPLY` variable):
`complete -F {{function}} {{command}}` `complete -F {{function}} {{command}}`
- Apply a command that performs autocompletion to another command: - 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):
`complete -C {{autocomplete_command}} {{command}}` `complete -C {{autocomplete_command}} {{command}}`
- Set arguments of a command to autocomplete to shell builtins:
`complete -A builtin {{command}}`
- Apply autocompletion without appending a space to the completed word: - Apply autocompletion without appending a space to the completed word:
`complete -o nospace -F {{function}} {{command}}` `complete -o nospace -F {{function}} {{command}}`
- List all loaded complete specifications:
`complete -p`
- List loaded complete specifications for a command:
`complete -p {{command}}`

View file

@ -1,12 +1,22 @@
# compopt # compopt
> Print or change the completion options for a command. > Print or change the completion options for a command.
> More information: <https://manned.org/compopt>. > `-o` means enabled and `+o` means disabled.
> See also: `compgen`, `complete`.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compopt>.
- Print the completion options for given command:
`compopt {{command}}`
- Enable or disable a completion option of a command:
`compopt {{-o|+o}} {{option1}} {{-o|+o}} {{option2}} {{command}}`
- Print the options for the currently executing completion: - Print the options for the currently executing completion:
`compopt` `compopt`
- Print the completion options for given command: - Enable or disable a completion option of a command:
`compopt {{command}}` `compopt {{-o|+o}} {{option1}} {{-o|+o}} {{option2}}`