Skip to content

Commit e982704

Browse files
Managordmmqz
andauthored
complete, compgen, compopt: refresh pages (#17638)
Co-authored-by: Dylan <[email protected]>
1 parent 1bd174c commit e982704

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

pages/common/compgen.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# compgen
22

3-
> A built-in command for auto-completion in Bash, which is called on pressing `<Tab>` key twice.
3+
> Bash built-in command for generating possible completion matches in Bash.
4+
> Usually used within custom completion functions.
5+
> See also: `complete`, `compopt`.
46
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compgen>.
57
6-
- List all commands that you could run:
8+
- List all shell built-ins, aliases, functions and executables that you could run:
79

810
`compgen -c`
911

10-
- List all commands that you could run that start with a specified string:
12+
- List all commands that you could run that start with a specified string and save results to `COMPREPLY`:
1113

12-
`compgen -c {{str}}`
14+
`compgen -V COMPREPLY -c {{str}}`
15+
16+
- Match against a wordlist:
17+
18+
`compgen -W "{{apple orange banana}}" {{a}}`
1319

1420
- List all aliases:
1521

@@ -30,7 +36,3 @@
3036
- List all users on the system:
3137

3238
`compgen -u`
33-
34-
- Display help:
35-
36-
`compgen --help`

pages/common/complete.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
# complete
22

3-
> Get argument autocompletion to shell commands.
3+
> Get and set argument autocompletion rules of shell commands in Bash.
4+
> The specified completions will be invoked when `<Tab>` is pressed in Bash.
5+
> See also: `compgen`, `compopt`.
46
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-complete>.
57
6-
- Apply a function that performs autocompletion to a command:
8+
- Set arguments of a command to autocomplete through a function (completion response is sent in `COMPREPLY` variable):
79

810
`complete -F {{function}} {{command}}`
911

10-
- Apply a command that performs autocompletion to another command:
12+
- 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):
1113

1214
`complete -C {{autocomplete_command}} {{command}}`
1315

16+
- Set arguments of a command to autocomplete to shell builtins:
17+
18+
`complete -A builtin {{command}}`
19+
1420
- Apply autocompletion without appending a space to the completed word:
1521

1622
`complete -o nospace -F {{function}} {{command}}`
23+
24+
- List all loaded complete specifications:
25+
26+
`complete -p`
27+
28+
- List loaded complete specifications for a command:
29+
30+
`complete -p {{command}}`

pages/common/compopt.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# compopt
22

33
> Print or change the completion options for a command.
4-
> More information: <https://manned.org/compopt>.
4+
> `-o` means enabled and `+o` means disabled.
5+
> See also: `compgen`, `complete`.
6+
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compopt>.
7+
8+
- Print the completion options for given command:
9+
10+
`compopt {{command}}`
11+
12+
- Enable or disable a completion option of a command:
13+
14+
`compopt {{-o|+o}} {{option1}} {{-o|+o}} {{option2}} {{command}}`
515

616
- Print the options for the currently executing completion:
717

818
`compopt`
919

10-
- Print the completion options for given command:
20+
- Enable or disable a completion option of a command:
1121

12-
`compopt {{command}}`
22+
`compopt {{-o|+o}} {{option1}} {{-o|+o}} {{option2}}`

0 commit comments

Comments
 (0)