| 1 |
### Meta commands |
| 2 |
|
| 3 |
| Command | Description | |
| 4 |
| ----------------------------------- | ------------------------------------------------------- | |
| 5 |
| [combine](#combine) | Combine multiple completers | |
| 6 |
| [key\_value\_list](#key_value_list) | Complete comma-separated lists of key=value pairs | |
| 7 |
| [key\_value\_pair](#key_value_pair) | Complete single key=value pairs | |
| 8 |
| [list](#list) | Complete comma-separated lists using a completer | |
| 9 |
| [none](#none) | No completion, but specify that an argument is required | |
| 10 |
| [prefix](#prefix) | Prefix completions with a string | |
| 11 |
|
| 12 |
--- |
| 13 |
|
| 14 |
### Built-in commands |
| 15 |
|
| 16 |
| Command | Description | |
| 17 |
| ------------------------------------------ | --------------------------------------------- | |
| 18 |
| [choices](#choices) | Complete from a predefined set of values | |
| 19 |
| [command](#command) | Complete command names | |
| 20 |
| [command\_arg](#command_arg) | Complete command arguments | |
| 21 |
| [commandline\_string](#commandline_string) | Complete command lines as strings | |
| 22 |
| [date](#date) | Complete date strings | |
| 23 |
| [date\_format](#date_format) | Complete date format strings | |
| 24 |
| [directory](#directory) | Complete directory names | |
| 25 |
| [directory\_list](#directory_list) | Complete comma-separated lists of directories | |
| 26 |
| [environment](#environment) | Complete environment variable names | |
| 27 |
| [file](#file) | Complete file names | |
| 28 |
| [file\_list](#file_list) | Complete comma-separated lists of files | |
| 29 |
| [filesystem\_type](#filesystem_type) | Complete filesystem types | |
| 30 |
| [float](#float) | Complete floating-point values | |
| 31 |
| [gid](#gid) | Complete group IDs | |
| 32 |
| [group](#group) | Complete group names | |
| 33 |
| [history](#history) | Complete based on a shell's history | |
| 34 |
| [hostname](#hostname) | Complete hostnames | |
| 35 |
| [integer](#integer) | Complete integer values | |
| 36 |
| [ip\_address](#ip_address) | Complete local IP addresses | |
| 37 |
| [mime\_file](#mime_file) | Complete files by MIME type | |
| 38 |
| [pid](#pid) | Complete process IDs | |
| 39 |
| [process](#process) | Complete process names | |
| 40 |
| [range](#range) | Complete sequences of integers | |
| 41 |
| [service](#service) | Complete systemd service names | |
| 42 |
| [signal](#signal) | Complete signal names | |
| 43 |
| [uid](#uid) | Complete user IDs | |
| 44 |
| [user](#user) | Complete user names | |
| 45 |
| [value\_list](#value_list) | Complete comma-separated lists of values | |
| 46 |
| [variable](#variable) | Complete shell variable names | |
| 47 |
|
| 48 |
--- |
| 49 |
|
| 50 |
### User-defined commands |
| 51 |
|
| 52 |
| Command | Description | |
| 53 |
| ---------------------------------------------- | -------------------------------------------------------------------------- | |
| 54 |
| [exec](#exec) | Complete values from the output of a command or function | |
| 55 |
| [exec\_fast](#exec_fast) | Complete values from the output of a command or function (fast and unsafe) | |
| 56 |
| [exec\_internal](#exec_internal) | Use the shell's internal completion mechanisms | |
| 57 |
| [key\_value\_list\_exec](#key_value_list_exec) | Complete dynamically generated comma-separted lists of key=value pairs | |
| 58 |
| [key\_value\_pair\_exec](#key_value_pair_exec) | Complete dynamically generated a key=value pairs | |
| 59 |
|
| 60 |
--- |
| 61 |
|
| 62 |
### Bonus commands |
| 63 |
|
| 64 |
| Command | Description | |
| 65 |
| -------------------------------- | --------------------------- | |
| 66 |
| [alsa\_card](#alsa_card) | Complete ALSA cards | |
| 67 |
| [alsa\_device](#alsa_device) | Complete ALSA devices | |
| 68 |
| [charset](#charset) | Complete character sets | |
| 69 |
| [locale](#locale) | Complete locales | |
| 70 |
| [login\_shell](#login_shell) | Complete login shells | |
| 71 |
| [mountpoint](#mountpoint) | Complete mount points | |
| 72 |
| [net\_interface](#net_interface) | Complete network interfaces | |
| 73 |
| [timezone](#timezone) | Complete timezones | |
| 74 |
|
| 75 |
--- |
| 76 |
|
| 77 |
### alsa\_card |
| 78 |
|
| 79 |
> Complete ALSA cards |
| 80 |
|
| 81 |
**SYNOPSIS** |
| 82 |
|
| 83 |
```yaml |
| 84 |
['alsa_card'] |
| 85 |
``` |
| 86 |
|
| 87 |
**EXAMPLE** |
| 88 |
|
| 89 |
```yaml |
| 90 |
prog: 'example' |
| 91 |
options: |
| 92 |
- option_strings: ['--alsa-card'] |
| 93 |
complete: ['alsa_card'] |
| 94 |
``` |
| 95 |
|
| 96 |
``` |
| 97 |
~ > example --alsa-card=<TAB> |
| 98 |
0 1 |
| 99 |
``` |
| 100 |
|
| 101 |
**SEE ALSO** |
| 102 |
|
| 103 |
- [alsa\_device](#alsa_device): For completing ALSA devices |
| 104 |
|
| 105 |
--- |
| 106 |
|
| 107 |
### alsa\_device |
| 108 |
|
| 109 |
> Complete ALSA devices |
| 110 |
|
| 111 |
**SYNOPSIS** |
| 112 |
|
| 113 |
```yaml |
| 114 |
['alsa_device'] |
| 115 |
``` |
| 116 |
|
| 117 |
**EXAMPLE** |
| 118 |
|
| 119 |
```yaml |
| 120 |
prog: 'example' |
| 121 |
options: |
| 122 |
- option_strings: ['--alsa-device'] |
| 123 |
complete: ['alsa_device'] |
| 124 |
``` |
| 125 |
|
| 126 |
``` |
| 127 |
~ > example --alsa-device=<TAB> |
| 128 |
hw:0 hw:1 |
| 129 |
``` |
| 130 |
|
| 131 |
**SEE ALSO** |
| 132 |
|
| 133 |
- [alsa\_card](#alsa_card): For completing ALSA cards |
| 134 |
|
| 135 |
--- |
| 136 |
|
| 137 |
### charset |
| 138 |
|
| 139 |
> Complete character sets |
| 140 |
|
| 141 |
**SYNOPSIS** |
| 142 |
|
| 143 |
```yaml |
| 144 |
['charset'] |
| 145 |
``` |
| 146 |
|
| 147 |
**EXAMPLE** |
| 148 |
|
| 149 |
```yaml |
| 150 |
prog: 'example' |
| 151 |
options: |
| 152 |
- option_strings: ['--charset'] |
| 153 |
complete: ['charset'] |
| 154 |
``` |
| 155 |
|
| 156 |
``` |
| 157 |
~ > example --charset=A<TAB> |
| 158 |
ANSI_X3.110-1983 ANSI_X3.4-1968 ARMSCII-8 ASMO_449 |
| 159 |
``` |
| 160 |
|
| 161 |
--- |
| 162 |
|
| 163 |
### locale |
| 164 |
|
| 165 |
> Complete locales |
| 166 |
|
| 167 |
**SYNOPSIS** |
| 168 |
|
| 169 |
```yaml |
| 170 |
['locale'] |
| 171 |
``` |
| 172 |
|
| 173 |
**EXAMPLE** |
| 174 |
|
| 175 |
```yaml |
| 176 |
prog: 'example' |
| 177 |
options: |
| 178 |
- option_strings: ['--locale'] |
| 179 |
complete: ['locale'] |
| 180 |
``` |
| 181 |
|
| 182 |
``` |
| 183 |
~ > example --locale=<TAB> |
| 184 |
C C.UTF-8 de_DE de_DE@euro de_DE.iso88591 de_DE.iso885915@euro |
| 185 |
de_DE.UTF-8 deutsch en_US en_US.iso88591 en_US.UTF-8 german POSIX |
| 186 |
``` |
| 187 |
|
| 188 |
--- |
| 189 |
|
| 190 |
### login\_shell |
| 191 |
|
| 192 |
> Complete login shells |
| 193 |
|
| 194 |
**SYNOPSIS** |
| 195 |
|
| 196 |
```yaml |
| 197 |
['login_shell'] |
| 198 |
``` |
| 199 |
|
| 200 |
**EXAMPLE** |
| 201 |
|
| 202 |
```yaml |
| 203 |
prog: 'example' |
| 204 |
options: |
| 205 |
- option_strings: ['--login-shell'] |
| 206 |
complete: ['login_shell'] |
| 207 |
``` |
| 208 |
|
| 209 |
``` |
| 210 |
~ > example --login-shell=<TAB> |
| 211 |
/bin/bash /bin/sh /usr/bin/fish /usr/bin/sh |
| 212 |
[...] |
| 213 |
``` |
| 214 |
|
| 215 |
--- |
| 216 |
|
| 217 |
### mountpoint |
| 218 |
|
| 219 |
> Complete mount points |
| 220 |
|
| 221 |
**SYNOPSIS** |
| 222 |
|
| 223 |
```yaml |
| 224 |
['mountpoint'] |
| 225 |
``` |
| 226 |
|
| 227 |
**EXAMPLE** |
| 228 |
|
| 229 |
```yaml |
| 230 |
prog: 'example' |
| 231 |
options: |
| 232 |
- option_strings: ['--mountpoint'] |
| 233 |
complete: ['mountpoint'] |
| 234 |
``` |
| 235 |
|
| 236 |
``` |
| 237 |
~ > example --mountpoint=<TAB> |
| 238 |
/ /boot /home /proc /run /sys /tmp |
| 239 |
[...] |
| 240 |
``` |
| 241 |
|
| 242 |
--- |
| 243 |
|
| 244 |
### net\_interface |
| 245 |
|
| 246 |
> Complete network interfaces |
| 247 |
|
| 248 |
**SYNOPSIS** |
| 249 |
|
| 250 |
```yaml |
| 251 |
['net_interface'] |
| 252 |
``` |
| 253 |
|
| 254 |
**EXAMPLE** |
| 255 |
|
| 256 |
```yaml |
| 257 |
prog: 'example' |
| 258 |
options: |
| 259 |
- option_strings: ['--net-interface'] |
| 260 |
complete: ['net_interface'] |
| 261 |
``` |
| 262 |
|
| 263 |
``` |
| 264 |
~ > example --net-interface=<TAB> |
| 265 |
eno1 enp1s0 lo wlo1 wlp2s0 |
| 266 |
[...] |
| 267 |
``` |
| 268 |
|
| 269 |
**SEE ALSO** |
| 270 |
|
| 271 |
- [ip\_address](#ip_address): For completing IP addresses |
| 272 |
|
| 273 |
--- |
| 274 |
|
| 275 |
### timezone |
| 276 |
|
| 277 |
> Complete timezones |
| 278 |
|
| 279 |
**SYNOPSIS** |
| 280 |
|
| 281 |
```yaml |
| 282 |
['timezone'] |
| 283 |
``` |
| 284 |
|
| 285 |
**EXAMPLE** |
| 286 |
|
| 287 |
```yaml |
| 288 |
prog: 'example' |
| 289 |
options: |
| 290 |
- option_strings: ['--timezone'] |
| 291 |
complete: ['timezone'] |
| 292 |
``` |
| 293 |
|
| 294 |
``` |
| 295 |
~ > example --timezone=Europe/B<TAB> |
| 296 |
Belfast Belgrade Berlin Bratislava |
| 297 |
Brussels Bucharest Budapest Busingen |
| 298 |
``` |
| 299 |
|
| 300 |
--- |
| 301 |
|
| 302 |
### choices |
| 303 |
|
| 304 |
> Complete from a predefined set of values |
| 305 |
|
| 306 |
**SYNOPSIS** |
| 307 |
|
| 308 |
```yaml |
| 309 |
['choices', <ITEMS>] |
| 310 |
``` |
| 311 |
|
| 312 |
**PARAMETERS** |
| 313 |
|
| 314 |
`ITEMS`: |
| 315 |
A list or dictionary containing the values to offer for completion. |
| 316 |
|
| 317 |
If a list is supplied, all items are offered without descriptions. |
| 318 |
|
| 319 |
If a dictionary is supplied, the keys are used as completion values and the |
| 320 |
values are used as descriptions. |
| 321 |
|
| 322 |
|
| 323 |
**NOTES** |
| 324 |
|
| 325 |
- If the completion suggestions should appear in their original order, set `nosort` to `true` |
| 326 |
|
| 327 |
**EXAMPLE** |
| 328 |
|
| 329 |
```yaml |
| 330 |
prog: 'example' |
| 331 |
options: |
| 332 |
- option_strings: ['--choices-1'] |
| 333 |
complete: ['choices', ['Item 1', 'Item 2']] |
| 334 |
|
| 335 |
- option_strings: ['--choices-2'] |
| 336 |
complete: ['choices', {'Item 1': 'Description 1', 'Item 2': 'Description 2'}] |
| 337 |
|
| 338 |
- option_strings: ['--choices-keep-order'] |
| 339 |
complete: ['choices', ['zebra', 'cat', 'monkey']] |
| 340 |
nosort: true |
| 341 |
``` |
| 342 |
|
| 343 |
``` |
| 344 |
~ > example --choices-2=<TAB> |
| 345 |
Item 1 (Description 1) Item 2 (Description 2) |
| 346 |
|
| 347 |
~ > example --choices-keep-order=<TAB> |
| 348 |
zebra cat monkey |
| 349 |
``` |
| 350 |
|
| 351 |
--- |
| 352 |
|
| 353 |
### command |
| 354 |
|
| 355 |
> Complete command names |
| 356 |
|
| 357 |
**SYNOPSIS** |
| 358 |
|
| 359 |
```yaml |
| 360 |
['command'] |
| 361 |
|
| 362 |
['command', <OPTIONS>] |
| 363 |
``` |
| 364 |
|
| 365 |
**PARAMETERS** |
| 366 |
|
| 367 |
This completer provides completion suggestions for executable commands available in the system's `$PATH`. |
| 368 |
|
| 369 |
`OPTIONS`: |
| 370 |
A dictionary containing additional options for configuring the completion. |
| 371 |
|
| 372 |
- `path`: |
| 373 |
Override the default `$PATH` used for searching executables. |
| 374 |
|
| 375 |
- `path_append`: |
| 376 |
Append directories to the default `$PATH`. |
| 377 |
|
| 378 |
- `path_prepend`: |
| 379 |
Prepend directories to the default `$PATH`. |
| 380 |
|
| 381 |
|
| 382 |
**NOTES** |
| 383 |
|
| 384 |
- `path_append` and `path_prepend` can be used together, but both are mutually exclusive with `path`. |
| 385 |
|
| 386 |
**EXAMPLE** |
| 387 |
|
| 388 |
```yaml |
| 389 |
prog: 'example' |
| 390 |
options: |
| 391 |
- option_strings: ['--command'] |
| 392 |
complete: ['command'] |
| 393 |
|
| 394 |
- option_strings: ['--command-sbin'] |
| 395 |
complete: ['command', {'path_append': '/sbin:/usr/sbin'}] |
| 396 |
``` |
| 397 |
|
| 398 |
``` |
| 399 |
~ > example --command=bas<TAB> |
| 400 |
base32 base64 basename basenc bash bashbug |
| 401 |
``` |
| 402 |
|
| 403 |
**SEE ALSO** |
| 404 |
|
| 405 |
- [command\_arg](#command_arg): For completing arguments of a command |
| 406 |
|
| 407 |
- [commandline\_string](#commandline_string): For completing command lines as strings |
| 408 |
|
| 409 |
--- |
| 410 |
|
| 411 |
### command\_arg |
| 412 |
|
| 413 |
> Complete command arguments |
| 414 |
|
| 415 |
**SYNOPSIS** |
| 416 |
|
| 417 |
```yaml |
| 418 |
['command_arg'] |
| 419 |
``` |
| 420 |
|
| 421 |
**NOTES** |
| 422 |
|
| 423 |
- This completer can only be used in combination with a previously defined `command` completer. |
| 424 |
|
| 425 |
- This completer requires `repeatable: true`. |
| 426 |
|
| 427 |
**EXAMPLE** |
| 428 |
|
| 429 |
```yaml |
| 430 |
prog: 'example' |
| 431 |
positionals: |
| 432 |
- number: 1 |
| 433 |
complete: ['command'] |
| 434 |
|
| 435 |
- number: 2 |
| 436 |
complete: ['command_arg'] |
| 437 |
repeatable: true |
| 438 |
``` |
| 439 |
|
| 440 |
``` |
| 441 |
~ > example sudo bas<TAB> |
| 442 |
base32 base64 basename basenc bash bashbug |
| 443 |
``` |
| 444 |
|
| 445 |
**SEE ALSO** |
| 446 |
|
| 447 |
- [command](#command): For completing command names |
| 448 |
|
| 449 |
- [commandline\_string](#commandline_string): For completing command lines as strings |
| 450 |
|
| 451 |
--- |
| 452 |
|
| 453 |
### commandline\_string |
| 454 |
|
| 455 |
> Complete command lines as strings |
| 456 |
|
| 457 |
**SYNOPSIS** |
| 458 |
|
| 459 |
```yaml |
| 460 |
['commandline_string'] |
| 461 |
``` |
| 462 |
|
| 463 |
**EXAMPLE** |
| 464 |
|
| 465 |
```yaml |
| 466 |
prog: 'example' |
| 467 |
options: |
| 468 |
- option_strings: ['--commandline'] |
| 469 |
complete: ['commandline_string'] |
| 470 |
``` |
| 471 |
|
| 472 |
``` |
| 473 |
~ > example --commandline='sudo ba<TAB> |
| 474 |
base32 base64 basename basenc bash bashbug |
| 475 |
``` |
| 476 |
|
| 477 |
**SEE ALSO** |
| 478 |
|
| 479 |
- [command](#command): For completing command names |
| 480 |
|
| 481 |
- [command\_arg](#command_arg): For completing command arguments |
| 482 |
|
| 483 |
--- |
| 484 |
|
| 485 |
### date |
| 486 |
|
| 487 |
> Complete date strings |
| 488 |
|
| 489 |
**SYNOPSIS** |
| 490 |
|
| 491 |
```yaml |
| 492 |
['date', <FORMAT>] |
| 493 |
``` |
| 494 |
|
| 495 |
**PARAMETERS** |
| 496 |
|
| 497 |
`FORMAT`: |
| 498 |
The date format as described in `strftime(3)`. |
| 499 |
|
| 500 |
|
| 501 |
**NOTES** |
| 502 |
|
| 503 |
- This completer is currently only implemented in **Zsh**. |
| 504 |
|
| 505 |
**EXAMPLE** |
| 506 |
|
| 507 |
```yaml |
| 508 |
prog: 'example' |
| 509 |
options: |
| 510 |
- option_strings: ['--date'] |
| 511 |
complete: ['date', '%Y-%m-%d'] |
| 512 |
``` |
| 513 |
|
| 514 |
``` |
| 515 |
~ > example --date=<TAB> |
| 516 |
|
| 517 |
November |
| 518 |
Mo Tu We Th Fr Sa Su |
| 519 |
1 2 3 4 5 6 |
| 520 |
7 8 9 10 11 12 13 |
| 521 |
14 15 16 17 18 19 20 |
| 522 |
21 22 23 24 25 26 27 |
| 523 |
28 29 30 |
| 524 |
``` |
| 525 |
|
| 526 |
**SEE ALSO** |
| 527 |
|
| 528 |
- [date\_format](#date_format): For completing date format strings |
| 529 |
|
| 530 |
--- |
| 531 |
|
| 532 |
### date\_format |
| 533 |
|
| 534 |
> Complete date format strings |
| 535 |
|
| 536 |
**SYNOPSIS** |
| 537 |
|
| 538 |
```yaml |
| 539 |
['date_format'] |
| 540 |
``` |
| 541 |
|
| 542 |
**NOTES** |
| 543 |
|
| 544 |
- This completer is currently only implemented in **Fish** and **Zsh**. |
| 545 |
|
| 546 |
**EXAMPLE** |
| 547 |
|
| 548 |
```yaml |
| 549 |
prog: 'example' |
| 550 |
options: |
| 551 |
- option_strings: ['--date-format'] |
| 552 |
complete: ['date_format'] |
| 553 |
``` |
| 554 |
|
| 555 |
``` |
| 556 |
~ > example --date-format '%<TAB> |
| 557 |
a -- abbreviated day name |
| 558 |
A -- full day name |
| 559 |
B -- full month name |
| 560 |
c -- preferred locale date and time |
| 561 |
C -- 2-digit century |
| 562 |
d -- day of month (01-31) |
| 563 |
D -- American format month/day/year (%m/%d/%y) |
| 564 |
e -- day of month ( 1-31) |
| 565 |
[...] |
| 566 |
``` |
| 567 |
|
| 568 |
**SEE ALSO** |
| 569 |
|
| 570 |
- [date](#date): For completing dates |
| 571 |
|
| 572 |
--- |
| 573 |
|
| 574 |
### directory |
| 575 |
|
| 576 |
> Complete directory names |
| 577 |
|
| 578 |
**SYNOPSIS** |
| 579 |
|
| 580 |
```yaml |
| 581 |
['directory'] |
| 582 |
|
| 583 |
['directory', <OPTIONS>] |
| 584 |
``` |
| 585 |
|
| 586 |
**PARAMETERS** |
| 587 |
|
| 588 |
`OPTIONS`: |
| 589 |
A dictionary containing additional options for configuring the completion. |
| 590 |
|
| 591 |
- `directory`: Restrict completion to directories inside the specified directory. |
| 592 |
|
| 593 |
|
| 594 |
**EXAMPLE** |
| 595 |
|
| 596 |
```yaml |
| 597 |
prog: 'example' |
| 598 |
options: |
| 599 |
- option_strings: ['--directory'] |
| 600 |
complete: ['directory'] |
| 601 |
|
| 602 |
- option_strings: ['--directory-tmp'] |
| 603 |
complete: ['directory', {'directory': '/tmp'}] |
| 604 |
``` |
| 605 |
|
| 606 |
``` |
| 607 |
~ > example --directory=<TAB> |
| 608 |
dir1/ dir2/ |
| 609 |
``` |
| 610 |
|
| 611 |
**SEE ALSO** |
| 612 |
|
| 613 |
- [directory\_list](#directory_list): For completing comma-separated lists of directories |
| 614 |
|
| 615 |
--- |
| 616 |
|
| 617 |
### directory\_list |
| 618 |
|
| 619 |
> Complete comma-separated lists of directories |
| 620 |
|
| 621 |
**SYNOPSIS** |
| 622 |
|
| 623 |
```yaml |
| 624 |
['directory_list'] |
| 625 |
|
| 626 |
['directory_list', <OPTIONS>] |
| 627 |
``` |
| 628 |
|
| 629 |
**PARAMETERS** |
| 630 |
|
| 631 |
This is an alias for `['list', ['directory']]`. |
| 632 |
|
| 633 |
`OPTIONS`: |
| 634 |
A dictionary containing additional options for configuring the completion. |
| 635 |
|
| 636 |
- `directory`: |
| 637 |
Restrict completion to directories inside the specified directory. |
| 638 |
|
| 639 |
- `duplicates`: |
| 640 |
Allow duplicate values to be offered for completion. Defaults to `false`. |
| 641 |
|
| 642 |
- `separator`: |
| 643 |
The separator used between list elements. Defaults to `,`. |
| 644 |
|
| 645 |
|
| 646 |
**EXAMPLE** |
| 647 |
|
| 648 |
```yaml |
| 649 |
prog: 'example' |
| 650 |
options: |
| 651 |
- option_strings: ['--directory-list'] |
| 652 |
complete: ['directory_list'] |
| 653 |
``` |
| 654 |
|
| 655 |
``` |
| 656 |
~ > example --directory-list=directory1,directory2,<TAB> |
| 657 |
directory3 directory4 |
| 658 |
``` |
| 659 |
|
| 660 |
**SEE ALSO** |
| 661 |
|
| 662 |
- [list](#list): For completion comma-separated lists using a completer |
| 663 |
|
| 664 |
- [directory](#directory): For completing directory names |
| 665 |
|
| 666 |
- [file\_list](#file_list): For completing comma-separated lists of files |
| 667 |
|
| 668 |
--- |
| 669 |
|
| 670 |
### environment |
| 671 |
|
| 672 |
> Complete environment variable names |
| 673 |
|
| 674 |
**SYNOPSIS** |
| 675 |
|
| 676 |
```yaml |
| 677 |
['environment'] |
| 678 |
``` |
| 679 |
|
| 680 |
**EXAMPLE** |
| 681 |
|
| 682 |
```yaml |
| 683 |
prog: 'example' |
| 684 |
options: |
| 685 |
- option_strings: ['--environment'] |
| 686 |
complete: ['environment'] |
| 687 |
``` |
| 688 |
|
| 689 |
``` |
| 690 |
~ > example --environment=X<TAB> |
| 691 |
XDG_RUNTIME_DIR XDG_SEAT XDG_SESSION_CLASS XDG_SESSION_ID |
| 692 |
XDG_SESSION_TYPE XDG_VTNR |
| 693 |
``` |
| 694 |
|
| 695 |
**SEE ALSO** |
| 696 |
|
| 697 |
- [variable](#variable): For completing shell variable names |
| 698 |
|
| 699 |
--- |
| 700 |
|
| 701 |
### file |
| 702 |
|
| 703 |
> Complete file names |
| 704 |
|
| 705 |
**SYNOPSIS** |
| 706 |
|
| 707 |
```yaml |
| 708 |
['file'] |
| 709 |
|
| 710 |
['file', <OPTIONS>] |
| 711 |
``` |
| 712 |
|
| 713 |
**PARAMETERS** |
| 714 |
|
| 715 |
`OPTIONS`: |
| 716 |
A dictionary containing additional options for configuring the completion. |
| 717 |
|
| 718 |
- `directory`: Restrict completion to files inside the specified directory. |
| 719 |
|
| 720 |
- `extensions`: A list of file extensions to offer for completion. |
| 721 |
|
| 722 |
- `fuzzy`: |
| 723 |
Enable fuzzy extension matching. |
| 724 |
By default, files must end with one of the specified extensions. |
| 725 |
With fuzzy matching enabled, files with additional suffixes are also matched, for example `foo.txt.1`. |
| 726 |
|
| 727 |
- `ignore_globs`: |
| 728 |
A list of Bash globs for files that should not be offered for completion. |
| 729 |
|
| 730 |
**NOTE:** Restricting completion to specific file extensions only makes sense |
| 731 |
if the program being completed actually expects files of those types. On |
| 732 |
Unix-like systems, file extensions generally have no inherent meaning and are |
| 733 |
only conventions. |
| 734 |
|
| 735 |
|
| 736 |
**EXAMPLE** |
| 737 |
|
| 738 |
```yaml |
| 739 |
prog: 'example' |
| 740 |
options: |
| 741 |
- option_strings: ['--file'] |
| 742 |
complete: ['file'] |
| 743 |
|
| 744 |
- option_strings: ['--file-tmp'] |
| 745 |
complete: ['file', {'directory': '/tmp'}] |
| 746 |
|
| 747 |
- option_strings: ['--file-ext'] |
| 748 |
complete: ['file', {'extensions': ['c', 'cpp']}] |
| 749 |
|
| 750 |
- option_strings: ['--file-ignore'] |
| 751 |
complete: ['file', {'ignore_globs': ['*.[tT][xX][tT]', '*.c++']}] |
| 752 |
``` |
| 753 |
|
| 754 |
``` |
| 755 |
~ > example --file=<TAB> |
| 756 |
dir1/ dir2/ file1 file2 |
| 757 |
|
| 758 |
~ > example --file-ext=<TAB> |
| 759 |
dir1/ dir2/ file.c file.cpp |
| 760 |
``` |
| 761 |
|
| 762 |
**SEE ALSO** |
| 763 |
|
| 764 |
- [file\_list](#file_list): For completing comma-separated lists of files |
| 765 |
|
| 766 |
- [mime\_file](#mime_file): For completing files by MIME type |
| 767 |
|
| 768 |
--- |
| 769 |
|
| 770 |
### file\_list |
| 771 |
|
| 772 |
> Complete comma-separated lists of files |
| 773 |
|
| 774 |
**SYNOPSIS** |
| 775 |
|
| 776 |
```yaml |
| 777 |
['file_list'] |
| 778 |
|
| 779 |
['file_list', <OPTIONS>] |
| 780 |
``` |
| 781 |
|
| 782 |
**PARAMETERS** |
| 783 |
|
| 784 |
This is an alias for `['list', ['file']]`. |
| 785 |
|
| 786 |
`OPTIONS`: |
| 787 |
A dictionary containing additional options for configuring the completion. |
| 788 |
|
| 789 |
- `directory`: |
| 790 |
Restrict completion to files inside the specified directory. |
| 791 |
|
| 792 |
- `extensions`: |
| 793 |
A list of file extensions to offer for completion. |
| 794 |
|
| 795 |
- `fuzzy`: |
| 796 |
Enable fuzzy extension matching. By default, files must end with one of |
| 797 |
the specified extensions. With fuzzy matching enabled, files with |
| 798 |
additional suffixes are also matched, for example `foo.txt.1`. |
| 799 |
|
| 800 |
- `ignore_globs`: |
| 801 |
A list of Bash globs for files that should not be offered for completion. |
| 802 |
|
| 803 |
- `duplicates`: |
| 804 |
Allow duplicate values to be offered for completion. Defaults to `false`. |
| 805 |
|
| 806 |
- `separator`: |
| 807 |
The separator used between list elements. Defaults to `,`. |
| 808 |
|
| 809 |
|
| 810 |
**EXAMPLE** |
| 811 |
|
| 812 |
```yaml |
| 813 |
prog: 'example' |
| 814 |
options: |
| 815 |
- option_strings: ['--file-list'] |
| 816 |
complete: ['file_list'] |
| 817 |
``` |
| 818 |
|
| 819 |
``` |
| 820 |
~ > example --file-list=file1,file2,<TAB> |
| 821 |
file3 file4 |
| 822 |
``` |
| 823 |
|
| 824 |
**SEE ALSO** |
| 825 |
|
| 826 |
- [list](#list): For completing comma-separted lists using a completer |
| 827 |
|
| 828 |
- [file](#file): For completing file names |
| 829 |
|
| 830 |
- [directory\_list](#directory_list): For completing comma-separated lists of directories |
| 831 |
|
| 832 |
--- |
| 833 |
|
| 834 |
### filesystem\_type |
| 835 |
|
| 836 |
> Complete filesystem types |
| 837 |
|
| 838 |
**SYNOPSIS** |
| 839 |
|
| 840 |
```yaml |
| 841 |
['filesystem_type'] |
| 842 |
``` |
| 843 |
|
| 844 |
**EXAMPLE** |
| 845 |
|
| 846 |
```yaml |
| 847 |
prog: 'example' |
| 848 |
options: |
| 849 |
- option_strings: ['--filesystem-type'] |
| 850 |
complete: ['filesystem_type'] |
| 851 |
``` |
| 852 |
|
| 853 |
``` |
| 854 |
~ > example --filesystem-type=<TAB> |
| 855 |
adfs autofs bdev bfs binder binfmt_misc bpf |
| 856 |
cgroup cgroup2 configfs cramfs debugfs devpts devtmpfs |
| 857 |
[...] |
| 858 |
``` |
| 859 |
|
| 860 |
--- |
| 861 |
|
| 862 |
### float |
| 863 |
|
| 864 |
> Complete floating-point values |
| 865 |
|
| 866 |
**SYNOPSIS** |
| 867 |
|
| 868 |
```yaml |
| 869 |
['float'] |
| 870 |
|
| 871 |
['float', <OPTIONS>] |
| 872 |
``` |
| 873 |
|
| 874 |
**PARAMETERS** |
| 875 |
|
| 876 |
`OPTIONS`: |
| 877 |
A dictionary containing additional options for configuring the completion. |
| 878 |
|
| 879 |
- `min`: The minimum allowed value. |
| 880 |
|
| 881 |
- `max`: The maximum allowed value. |
| 882 |
|
| 883 |
- `suffixes`: A dictionary of suffixes and their descriptions. The suffix is appended to the completed value. |
| 884 |
|
| 885 |
- `help`: The help text shown during completion. If not specified, the `help` attribute of the option is used. |
| 886 |
|
| 887 |
|
| 888 |
**EXAMPLE** |
| 889 |
|
| 890 |
```yaml |
| 891 |
prog: 'example' |
| 892 |
options: |
| 893 |
- option_strings: ['--time'] |
| 894 |
complete: ['float', {'suffixes': {'s': 'seconds', 'm': 'minutes', 'h': 'hours'}}] |
| 895 |
``` |
| 896 |
|
| 897 |
``` |
| 898 |
~ > example --time=3.0<TAB> |
| 899 |
s -- seconds m -- minutes h -- hours |
| 900 |
``` |
| 901 |
|
| 902 |
**SEE ALSO** |
| 903 |
|
| 904 |
- [integer](#integer): For completing integer values |
| 905 |
|
| 906 |
--- |
| 907 |
|
| 908 |
### gid |
| 909 |
|
| 910 |
> Complete group IDs |
| 911 |
|
| 912 |
**SYNOPSIS** |
| 913 |
|
| 914 |
```yaml |
| 915 |
['gid'] |
| 916 |
``` |
| 917 |
|
| 918 |
**EXAMPLE** |
| 919 |
|
| 920 |
```yaml |
| 921 |
prog: 'example' |
| 922 |
options: |
| 923 |
- option_strings: ['--gid'] |
| 924 |
complete: ['gid'] |
| 925 |
``` |
| 926 |
|
| 927 |
``` |
| 928 |
~ > example --gid=<TAB> |
| 929 |
0 -- root |
| 930 |
1000 -- braph |
| 931 |
102 -- polkitd |
| 932 |
108 -- vboxusers |
| 933 |
11 -- ftp |
| 934 |
12 -- mail |
| 935 |
133 -- rtkit |
| 936 |
19 -- log |
| 937 |
[...] |
| 938 |
``` |
| 939 |
|
| 940 |
**SEE ALSO** |
| 941 |
|
| 942 |
- [group](#group): For completing group names |
| 943 |
|
| 944 |
--- |
| 945 |
|
| 946 |
### group |
| 947 |
|
| 948 |
> Complete group names |
| 949 |
|
| 950 |
**SYNOPSIS** |
| 951 |
|
| 952 |
```yaml |
| 953 |
['group'] |
| 954 |
``` |
| 955 |
|
| 956 |
**EXAMPLE** |
| 957 |
|
| 958 |
```yaml |
| 959 |
prog: 'example' |
| 960 |
options: |
| 961 |
- option_strings: ['--group'] |
| 962 |
complete: ['group'] |
| 963 |
``` |
| 964 |
|
| 965 |
``` |
| 966 |
~ > example --group=<TAB> |
| 967 |
adm audio avahi |
| 968 |
bin braph colord |
| 969 |
daemon dbus dhcpcd |
| 970 |
disk floppy ftp |
| 971 |
games git groups |
| 972 |
[...] |
| 973 |
``` |
| 974 |
|
| 975 |
**SEE ALSO** |
| 976 |
|
| 977 |
- [gid](#gid): For completing group IDs |
| 978 |
|
| 979 |
--- |
| 980 |
|
| 981 |
### history |
| 982 |
|
| 983 |
> Complete based on a shell's history |
| 984 |
|
| 985 |
**SYNOPSIS** |
| 986 |
|
| 987 |
```yaml |
| 988 |
['history', <REGEX>] |
| 989 |
``` |
| 990 |
|
| 991 |
**PARAMETERS** |
| 992 |
|
| 993 |
`REGEX`: |
| 994 |
An extended regular expression used to filter history entries. |
| 995 |
The regular expression is passed to `grep -E`. |
| 996 |
|
| 997 |
|
| 998 |
**EXAMPLE** |
| 999 |
|
| 1000 |
```yaml |
| 1001 |
prog: 'example' |
| 1002 |
options: |
| 1003 |
- option_strings: ['--history'] |
| 1004 |
complete: ['history', '[a-zA-Z0-9]+@[a-zA-Z0-9]+'] |
| 1005 |
``` |
| 1006 |
|
| 1007 |
``` |
| 1008 |
~ > example --history=<TAB> |
| 1009 |
foo@bar mymail@myprovider |
| 1010 |
``` |
| 1011 |
|
| 1012 |
--- |
| 1013 |
|
| 1014 |
### hostname |
| 1015 |
|
| 1016 |
> Complete hostnames |
| 1017 |
|
| 1018 |
**SYNOPSIS** |
| 1019 |
|
| 1020 |
```yaml |
| 1021 |
['hostname'] |
| 1022 |
``` |
| 1023 |
|
| 1024 |
**EXAMPLE** |
| 1025 |
|
| 1026 |
```yaml |
| 1027 |
prog: 'example' |
| 1028 |
options: |
| 1029 |
- option_strings: ['--hostname'] |
| 1030 |
complete: ['hostname'] |
| 1031 |
``` |
| 1032 |
|
| 1033 |
``` |
| 1034 |
~ > example --hostname=<TAB> |
| 1035 |
localhost |
| 1036 |
``` |
| 1037 |
|
| 1038 |
**SEE ALSO** |
| 1039 |
|
| 1040 |
- [ip\_address](#ip_address): For completing local IP addresses |
| 1041 |
|
| 1042 |
--- |
| 1043 |
|
| 1044 |
### integer |
| 1045 |
|
| 1046 |
> Complete integer values |
| 1047 |
|
| 1048 |
**SYNOPSIS** |
| 1049 |
|
| 1050 |
```yaml |
| 1051 |
['integer'] |
| 1052 |
|
| 1053 |
['integer', <OPTIONS>] |
| 1054 |
``` |
| 1055 |
|
| 1056 |
**PARAMETERS** |
| 1057 |
|
| 1058 |
`OPTIONS`: |
| 1059 |
A dictionary containing additional options for configuring the completion. |
| 1060 |
|
| 1061 |
- `min`: The minimum allowed value. |
| 1062 |
|
| 1063 |
- `max`: The maximum allowed value. |
| 1064 |
|
| 1065 |
- `suffixes`: A dictionary of suffixes and their descriptions. The suffix is appended to the completed value. |
| 1066 |
|
| 1067 |
- `help`: The help text shown during completion. If not specified, the `help` attribute of the option is used. |
| 1068 |
|
| 1069 |
|
| 1070 |
**EXAMPLE** |
| 1071 |
|
| 1072 |
```yaml |
| 1073 |
prog: 'example' |
| 1074 |
options: |
| 1075 |
- option_strings: ['--time'] |
| 1076 |
complete: ['integer', {'suffixes': {'s': 'seconds', 'm': 'minutes', 'h': 'hours'}}] |
| 1077 |
``` |
| 1078 |
|
| 1079 |
``` |
| 1080 |
~ > example --integer=3<TAB> |
| 1081 |
s -- seconds m -- minutes h -- hours |
| 1082 |
``` |
| 1083 |
|
| 1084 |
**SEE ALSO** |
| 1085 |
|
| 1086 |
- [float](#float): For completing floating-point values |
| 1087 |
|
| 1088 |
- [range](#range): For completing sequences of integers |
| 1089 |
|
| 1090 |
--- |
| 1091 |
|
| 1092 |
### ip\_address |
| 1093 |
|
| 1094 |
> Complete local IP addresses |
| 1095 |
|
| 1096 |
**SYNOPSIS** |
| 1097 |
|
| 1098 |
```yaml |
| 1099 |
['ip_address', <TYPE>] |
| 1100 |
``` |
| 1101 |
|
| 1102 |
**PARAMETERS** |
| 1103 |
|
| 1104 |
`TYPE`: |
| 1105 |
The type of ip addresses to complete: |
| 1106 |
|
| 1107 |
- `ipv4`: IPv4 addresses |
| 1108 |
- `ipv6`: IPv6 addresses |
| 1109 |
- `all`: Both IPv4 and IPv6 addresses |
| 1110 |
|
| 1111 |
Append `+` to include the unspecified address of the selected family: |
| 1112 |
|
| 1113 |
- `ipv4+`: Includes `0.0.0.0` |
| 1114 |
- `ipv6+`: Includes `::` |
| 1115 |
- `all+`: Includes both 0.0.0.0 and `::` |
| 1116 |
|
| 1117 |
|
| 1118 |
**EXAMPLE** |
| 1119 |
|
| 1120 |
```yaml |
| 1121 |
prog: 'example' |
| 1122 |
options: |
| 1123 |
- option_strings: ['--ip-address'] |
| 1124 |
complete: ['ip_address'] |
| 1125 |
|
| 1126 |
- option_strings: ['--ip-address-v4'] |
| 1127 |
complete: ['ip_address', 'ipv4'] |
| 1128 |
|
| 1129 |
- option_strings: ['--ip-address-v6'] |
| 1130 |
complete: ['ip_address', 'ipv6'] |
| 1131 |
``` |
| 1132 |
|
| 1133 |
``` |
| 1134 |
~ > example --ip-address=<TAB> |
| 1135 |
::1 10.0.0.71 127.0.0.1 fe80::f567:7a1a:3c98:808d |
| 1136 |
|
| 1137 |
~ > example --ip-address-v4=<TAB> |
| 1138 |
10.0.0.71 127.0.0.1 |
| 1139 |
|
| 1140 |
~ > example --ip-address-v6=<TAB> |
| 1141 |
::1 fe80::f567:7a1a:3c98:808d |
| 1142 |
``` |
| 1143 |
|
| 1144 |
**SEE ALSO** |
| 1145 |
|
| 1146 |
- [net\_interface](#net_interface): For completing network interfaces |
| 1147 |
|
| 1148 |
- [hostname](#hostname): For completing hostnames |
| 1149 |
|
| 1150 |
--- |
| 1151 |
|
| 1152 |
### mime\_file |
| 1153 |
|
| 1154 |
> Complete files by MIME type |
| 1155 |
|
| 1156 |
**SYNOPSIS** |
| 1157 |
|
| 1158 |
```yaml |
| 1159 |
['mime_file', <MIME_REGEX>] |
| 1160 |
``` |
| 1161 |
|
| 1162 |
**PARAMETERS** |
| 1163 |
|
| 1164 |
`MIME_REGEX`: |
| 1165 |
An extended regular expression used to match MIME types. |
| 1166 |
The expression is passed to `grep -E` to filter the results. |
| 1167 |
|
| 1168 |
|
| 1169 |
**EXAMPLE** |
| 1170 |
|
| 1171 |
```yaml |
| 1172 |
prog: 'example' |
| 1173 |
options: |
| 1174 |
- option_strings: ['--image'] |
| 1175 |
complete: ['mime_file', 'image/'] |
| 1176 |
``` |
| 1177 |
|
| 1178 |
``` |
| 1179 |
~ > example --image=<TAB> |
| 1180 |
dir1/ dir2/ img.png img.jpg |
| 1181 |
``` |
| 1182 |
|
| 1183 |
--- |
| 1184 |
|
| 1185 |
### pid |
| 1186 |
|
| 1187 |
> Complete process IDs |
| 1188 |
|
| 1189 |
**SYNOPSIS** |
| 1190 |
|
| 1191 |
```yaml |
| 1192 |
['pid'] |
| 1193 |
``` |
| 1194 |
|
| 1195 |
**EXAMPLE** |
| 1196 |
|
| 1197 |
```yaml |
| 1198 |
prog: 'example' |
| 1199 |
options: |
| 1200 |
- option_strings: ['--pid'] |
| 1201 |
complete: ['pid'] |
| 1202 |
``` |
| 1203 |
|
| 1204 |
``` |
| 1205 |
~ > example --pid=<TAB> |
| 1206 |
1 13 166 19 254 31 45 |
| 1207 |
1006 133315 166441 19042 26 32 46 |
| 1208 |
10150 1392 166442 195962 27 33 4609 |
| 1209 |
``` |
| 1210 |
|
| 1211 |
**SEE ALSO** |
| 1212 |
|
| 1213 |
- [process](#process): For completing process names |
| 1214 |
|
| 1215 |
--- |
| 1216 |
|
| 1217 |
### process |
| 1218 |
|
| 1219 |
> Complete process names |
| 1220 |
|
| 1221 |
**SYNOPSIS** |
| 1222 |
|
| 1223 |
```yaml |
| 1224 |
['process'] |
| 1225 |
``` |
| 1226 |
|
| 1227 |
**EXAMPLE** |
| 1228 |
|
| 1229 |
```yaml |
| 1230 |
prog: 'example' |
| 1231 |
options: |
| 1232 |
- option_strings: ['--process'] |
| 1233 |
complete: ['process'] |
| 1234 |
``` |
| 1235 |
|
| 1236 |
``` |
| 1237 |
~ > example --process=s<TAB> |
| 1238 |
scsi_eh_0 scsi_eh_1 scsi_eh_2 scsi_eh_3 scsi_eh_4 |
| 1239 |
scsi_eh_5 sh sudo syndaemon systemd |
| 1240 |
systemd-journald systemd-logind systemd-udevd |
| 1241 |
``` |
| 1242 |
|
| 1243 |
**SEE ALSO** |
| 1244 |
|
| 1245 |
- [pid](#pid): For completing process IDs |
| 1246 |
|
| 1247 |
--- |
| 1248 |
|
| 1249 |
### range |
| 1250 |
|
| 1251 |
> Complete sequences of integers |
| 1252 |
|
| 1253 |
**SYNOPSIS** |
| 1254 |
|
| 1255 |
```yaml |
| 1256 |
['range', <START>, <STOP>] |
| 1257 |
|
| 1258 |
['range', <START>, <STOP>, <STEP>] |
| 1259 |
``` |
| 1260 |
|
| 1261 |
**PARAMETERS** |
| 1262 |
|
| 1263 |
`START`: |
| 1264 |
The first value of the range. |
| 1265 |
|
| 1266 |
`STOP`: |
| 1267 |
The last value of the range. |
| 1268 |
|
| 1269 |
`STEP`: |
| 1270 |
The increment between values. Defaults to `1`. |
| 1271 |
|
| 1272 |
|
| 1273 |
**EXAMPLE** |
| 1274 |
|
| 1275 |
```yaml |
| 1276 |
prog: 'example' |
| 1277 |
options: |
| 1278 |
- option_strings: ['--range-1'] |
| 1279 |
complete: ['range', 1, 9] |
| 1280 |
|
| 1281 |
- option_strings: ['--range-2'] |
| 1282 |
complete: ['range', 1, 9, 2] |
| 1283 |
``` |
| 1284 |
|
| 1285 |
``` |
| 1286 |
~ > example --range-1=<TAB> |
| 1287 |
1 2 3 4 5 6 7 8 9 |
| 1288 |
|
| 1289 |
~ > example --range-2=<TAB> |
| 1290 |
1 3 5 7 9 |
| 1291 |
``` |
| 1292 |
|
| 1293 |
--- |
| 1294 |
|
| 1295 |
### service |
| 1296 |
|
| 1297 |
> Complete systemd service names |
| 1298 |
|
| 1299 |
**SYNOPSIS** |
| 1300 |
|
| 1301 |
```yaml |
| 1302 |
['service'] |
| 1303 |
``` |
| 1304 |
|
| 1305 |
**EXAMPLE** |
| 1306 |
|
| 1307 |
```yaml |
| 1308 |
prog: 'example' |
| 1309 |
options: |
| 1310 |
- option_strings: ['--service'] |
| 1311 |
complete: ['service'] |
| 1312 |
``` |
| 1313 |
|
| 1314 |
``` |
| 1315 |
~ > example --service=<TAB> |
| 1316 |
TODO |
| 1317 |
[...] |
| 1318 |
``` |
| 1319 |
|
| 1320 |
--- |
| 1321 |
|
| 1322 |
### signal |
| 1323 |
|
| 1324 |
> Complete signal names |
| 1325 |
|
| 1326 |
**SYNOPSIS** |
| 1327 |
|
| 1328 |
```yaml |
| 1329 |
['signal'] |
| 1330 |
``` |
| 1331 |
|
| 1332 |
**EXAMPLE** |
| 1333 |
|
| 1334 |
```yaml |
| 1335 |
prog: 'example' |
| 1336 |
options: |
| 1337 |
- option_strings: ['--signal'] |
| 1338 |
complete: ['signal'] |
| 1339 |
``` |
| 1340 |
|
| 1341 |
``` |
| 1342 |
~ > example --signal=<TAB> |
| 1343 |
ABRT -- Process abort signal |
| 1344 |
ALRM -- Alarm clock |
| 1345 |
BUS -- Access to an undefined portion of a memory object |
| 1346 |
CHLD -- Child process terminated, stopped, or continued |
| 1347 |
CONT -- Continue executing, if stopped |
| 1348 |
FPE -- Erroneous arithmetic operation |
| 1349 |
HUP -- Hangup |
| 1350 |
ILL -- Illegal instruction |
| 1351 |
INT -- Terminal interrupt signal |
| 1352 |
[...] |
| 1353 |
``` |
| 1354 |
|
| 1355 |
--- |
| 1356 |
|
| 1357 |
### uid |
| 1358 |
|
| 1359 |
> Complete user IDs |
| 1360 |
|
| 1361 |
**SYNOPSIS** |
| 1362 |
|
| 1363 |
```yaml |
| 1364 |
['uid'] |
| 1365 |
``` |
| 1366 |
|
| 1367 |
**EXAMPLE** |
| 1368 |
|
| 1369 |
```yaml |
| 1370 |
prog: 'example' |
| 1371 |
options: |
| 1372 |
- option_strings: ['--uid'] |
| 1373 |
complete: ['uid'] |
| 1374 |
``` |
| 1375 |
|
| 1376 |
``` |
| 1377 |
~ > example --uid=<TAB> |
| 1378 |
0 -- root |
| 1379 |
1000 -- braph |
| 1380 |
102 -- polkitd |
| 1381 |
133 -- rtkit |
| 1382 |
14 -- ftp |
| 1383 |
1 -- bin |
| 1384 |
2 -- daemon |
| 1385 |
33 -- http |
| 1386 |
65534 -- nobody |
| 1387 |
[...] |
| 1388 |
``` |
| 1389 |
|
| 1390 |
**SEE ALSO** |
| 1391 |
|
| 1392 |
- [user](#user): For completing user names |
| 1393 |
|
| 1394 |
--- |
| 1395 |
|
| 1396 |
### user |
| 1397 |
|
| 1398 |
> Complete user names |
| 1399 |
|
| 1400 |
**SYNOPSIS** |
| 1401 |
|
| 1402 |
```yaml |
| 1403 |
['user'] |
| 1404 |
``` |
| 1405 |
|
| 1406 |
**EXAMPLE** |
| 1407 |
|
| 1408 |
```yaml |
| 1409 |
prog: 'example' |
| 1410 |
options: |
| 1411 |
- option_strings: ['--user'] |
| 1412 |
complete: ['user'] |
| 1413 |
``` |
| 1414 |
|
| 1415 |
``` |
| 1416 |
~ > example --user=<TAB> |
| 1417 |
avahi bin braph |
| 1418 |
colord daemon dbus |
| 1419 |
dhcpcd ftp git |
| 1420 |
[...] |
| 1421 |
``` |
| 1422 |
|
| 1423 |
**SEE ALSO** |
| 1424 |
|
| 1425 |
- [uid](#uid): For completing user IDs |
| 1426 |
|
| 1427 |
--- |
| 1428 |
|
| 1429 |
### value\_list |
| 1430 |
|
| 1431 |
> Complete comma-separated lists of values |
| 1432 |
|
| 1433 |
**SYNOPSIS** |
| 1434 |
|
| 1435 |
```yaml |
| 1436 |
['value_list', <OPTIONS>] |
| 1437 |
``` |
| 1438 |
|
| 1439 |
**PARAMETERS** |
| 1440 |
|
| 1441 |
`OPTIONS`: |
| 1442 |
A dictionary containing additional options for configuring the completion. |
| 1443 |
|
| 1444 |
- `values`: |
| 1445 |
A list or dictionary containing the values to offer for completion. |
| 1446 |
|
| 1447 |
If a list is supplied, all values are offered without descriptions. |
| 1448 |
|
| 1449 |
If a dictionary is supplied, the keys are used as completion values and |
| 1450 |
the values are used as descriptions. |
| 1451 |
|
| 1452 |
- `separator`: |
| 1453 |
The separator used between list elements. Defaults to `,`. |
| 1454 |
|
| 1455 |
- `duplicates`: |
| 1456 |
Allow duplicate values to be offered for completion. Defaults to `false`. |
| 1457 |
|
| 1458 |
|
| 1459 |
**EXAMPLE** |
| 1460 |
|
| 1461 |
```yaml |
| 1462 |
prog: 'example' |
| 1463 |
options: |
| 1464 |
- option_strings: ['--value-list-1'] |
| 1465 |
complete: ['value_list', {'values': ['exec', 'noexec']}] |
| 1466 |
|
| 1467 |
- option_strings: ['--value-list-2'] |
| 1468 |
complete: ['value_list', {'values': {'one': 'Description 1', 'two': 'Description 2'}}] |
| 1469 |
``` |
| 1470 |
|
| 1471 |
``` |
| 1472 |
~ > example --value-list-1=<TAB> |
| 1473 |
exec noexec |
| 1474 |
|
| 1475 |
~ > example --value-list-1=exec,<TAB> |
| 1476 |
noexec |
| 1477 |
|
| 1478 |
~ > example --value-list-2=<TAB> |
| 1479 |
one -- Description 1 |
| 1480 |
two -- Description 2 |
| 1481 |
``` |
| 1482 |
|
| 1483 |
**SEE ALSO** |
| 1484 |
|
| 1485 |
- [list](#list): For completing comma-separated lists using a completer |
| 1486 |
|
| 1487 |
- [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs |
| 1488 |
|
| 1489 |
--- |
| 1490 |
|
| 1491 |
### variable |
| 1492 |
|
| 1493 |
> Complete shell variable names |
| 1494 |
|
| 1495 |
**SYNOPSIS** |
| 1496 |
|
| 1497 |
```yaml |
| 1498 |
['variable'] |
| 1499 |
``` |
| 1500 |
|
| 1501 |
**EXAMPLE** |
| 1502 |
|
| 1503 |
```yaml |
| 1504 |
prog: 'example' |
| 1505 |
options: |
| 1506 |
- option_strings: ['--variable'] |
| 1507 |
complete: ['variable'] |
| 1508 |
``` |
| 1509 |
|
| 1510 |
``` |
| 1511 |
~ > example --variable=HO<TAB> |
| 1512 |
HOME HOSTNAME HOSTTYPE |
| 1513 |
``` |
| 1514 |
|
| 1515 |
**SEE ALSO** |
| 1516 |
|
| 1517 |
- [environment](#environment): For completing environment variable names |
| 1518 |
|
| 1519 |
--- |
| 1520 |
|
| 1521 |
### combine |
| 1522 |
|
| 1523 |
> Combine multiple completers |
| 1524 |
|
| 1525 |
**SYNOPSIS** |
| 1526 |
|
| 1527 |
```yaml |
| 1528 |
['combine', <COMPLETERS>] |
| 1529 |
``` |
| 1530 |
|
| 1531 |
**PARAMETERS** |
| 1532 |
|
| 1533 |
Combines multiple completers into a single completer. |
| 1534 |
|
| 1535 |
`COMPLETERS`: |
| 1536 |
A list of completers to combine. |
| 1537 |
|
| 1538 |
|
| 1539 |
**EXAMPLE** |
| 1540 |
|
| 1541 |
```yaml |
| 1542 |
prog: 'example' |
| 1543 |
options: |
| 1544 |
- option_strings: ['--combine'] |
| 1545 |
complete: ['combine', [['user'], ['pid']]] |
| 1546 |
``` |
| 1547 |
|
| 1548 |
``` |
| 1549 |
~ > example --combine=avahi,daemon,<TAB> |
| 1550 |
1439404 3488332 3571716 3607235 4134206 |
| 1551 |
alpm avahi bin braph daemon |
| 1552 |
root rtkit systemd-coredump systemd-journal-remote systemd-network |
| 1553 |
[...] |
| 1554 |
``` |
| 1555 |
|
| 1556 |
--- |
| 1557 |
|
| 1558 |
### key\_value\_list |
| 1559 |
|
| 1560 |
> Complete comma-separated lists of key=value pairs |
| 1561 |
|
| 1562 |
**SYNOPSIS** |
| 1563 |
|
| 1564 |
```yaml |
| 1565 |
['key_value_list', <PAIR_SEPARATOR>, <VALUE_SEPARATOR>, <DEFINITIONS>] |
| 1566 |
|
| 1567 |
['key_value_list', <PAIR_SEPARATOR>, <VALUE_SEPARATOR>, <DEFINITIONS>, <CONDITION_FUNCTION>] |
| 1568 |
``` |
| 1569 |
|
| 1570 |
**PARAMETERS** |
| 1571 |
|
| 1572 |
`PAIR_SEPARATOR`: |
| 1573 |
The separator used to separate individual key-value pairs. |
| 1574 |
|
| 1575 |
`VALUE_SEPARATOR`: |
| 1576 |
The separator used to separate a key from its value. |
| 1577 |
|
| 1578 |
`DEFINITIONS`: |
| 1579 |
A list of key definitions. |
| 1580 |
|
| 1581 |
Each definition has one of the following forms: |
| 1582 |
|
| 1583 |
`[<KEY>, <DESCRIPTION>, <COMPLETER>]` |
| 1584 |
|
| 1585 |
-- OR -- |
| 1586 |
|
| 1587 |
`[<KEY>, <DESCRIPTION>, <COMPLETER>, <EXCLUDES>]` |
| 1588 |
|
| 1589 |
`KEY`: |
| 1590 |
The name of the key. |
| 1591 |
Prefix the name with `*` to allow the key to be completed multiple times. |
| 1592 |
|
| 1593 |
`DESCRIPTION`: |
| 1594 |
A description shown during completion. |
| 1595 |
Use `null` to omit the description. |
| 1596 |
|
| 1597 |
`COMPLETER`: |
| 1598 |
The completer used for the value of the key. |
| 1599 |
Use `null` if the key does not take an argument. |
| 1600 |
Use `['none']` if the key takes an argument but cannot be completed. |
| 1601 |
|
| 1602 |
`EXCLUDES`: |
| 1603 |
A list of keys that should no longer be offered for completion once this key has been used. |
| 1604 |
|
| 1605 |
`CONDITION_FUNCTION`: |
| 1606 |
A command or function that determines whether a key should be offered for |
| 1607 |
completion. |
| 1608 |
|
| 1609 |
It is invoked with the key as its first argument. If it exits with status `0`, |
| 1610 |
the key is offered for completion. Any non-zero exit status suppresses the |
| 1611 |
key. |
| 1612 |
|
| 1613 |
By default, each key is offered for completion only once. |
| 1614 |
To allow a key to be completed multiple times, prefix its name with `*`. |
| 1615 |
|
| 1616 |
|
| 1617 |
**EXAMPLE** |
| 1618 |
|
| 1619 |
```yaml |
| 1620 |
prog: 'example' |
| 1621 |
options: |
| 1622 |
- option_strings: ['--key-value-list'] |
| 1623 |
complete: ['key_value_list', ',', '=', [ |
| 1624 |
['flag', 'An option flag', null], |
| 1625 |
['nodesc', null, null], |
| 1626 |
['nocomp', 'An option with arg but without completer', ['none']], |
| 1627 |
['user', 'Takes a username', ['user']], |
| 1628 |
['*repeatable', 'This option is repeatable', null], |
| 1629 |
['exclusive', 'This option disables other options', null, ['flag', 'nodesc', 'nocomp']], |
| 1630 |
['check', 'Specify file name conversions', ['choices', { |
| 1631 |
'relaxed': 'convert to lowercase before lookup', |
| 1632 |
'strict': 'no conversion' |
| 1633 |
}]] |
| 1634 |
]] |
| 1635 |
``` |
| 1636 |
|
| 1637 |
``` |
| 1638 |
~ > example --key-value-list flag,user=<TAB> |
| 1639 |
bin braph |
| 1640 |
colord dbus |
| 1641 |
dhcpcd git |
| 1642 |
[...] |
| 1643 |
``` |
| 1644 |
|
| 1645 |
**SEE ALSO** |
| 1646 |
|
| 1647 |
- [list](#list): For completing comma-separated lists using a completer |
| 1648 |
|
| 1649 |
- [value\_list](#value_list): For completing comma-separated lists of values |
| 1650 |
|
| 1651 |
- [key\_value\_pair](#key_value_pair): For completing single key=value pairs |
| 1652 |
|
| 1653 |
- [key\_value\_list\_exec](#key_value_list_exec): For completing comma-separated lists of key=value pairs (dynamically generated by a function) |
| 1654 |
|
| 1655 |
--- |
| 1656 |
|
| 1657 |
### key\_value\_pair |
| 1658 |
|
| 1659 |
> Complete single key=value pairs |
| 1660 |
|
| 1661 |
**SYNOPSIS** |
| 1662 |
|
| 1663 |
```yaml |
| 1664 |
['key_value_pair', <VALUE_SEPARATOR>, <DEFINITIONS>] |
| 1665 |
|
| 1666 |
['key_value_pair', <VALUE_SEPARATOR>, <DEFINITIONS>, <CONDITION_FUNCTION>] |
| 1667 |
``` |
| 1668 |
|
| 1669 |
**PARAMETERS** |
| 1670 |
|
| 1671 |
`VALUE_SEPARATOR`: |
| 1672 |
The separator used to separate a key from its value. |
| 1673 |
|
| 1674 |
`DEFINITIONS`: |
| 1675 |
A list of key definitions. |
| 1676 |
|
| 1677 |
Each definition has the following form: |
| 1678 |
|
| 1679 |
`[<KEY>, <DESCRIPTION>, <COMPLETER>]` |
| 1680 |
|
| 1681 |
`KEY`: |
| 1682 |
The name of the key. |
| 1683 |
Prefix the name with `*` to allow the key to be completed multiple times. |
| 1684 |
|
| 1685 |
`DESCRIPTION`: |
| 1686 |
A description shown during completion. |
| 1687 |
Use `null` to omit the description. |
| 1688 |
|
| 1689 |
`COMPLETER`: |
| 1690 |
The completer used for the value of the key. |
| 1691 |
Use `null` if the key does not take an argument. |
| 1692 |
Use `['none']` if the key takes an argument but cannot be completed. |
| 1693 |
|
| 1694 |
`CONDITION_FUNCTION`: |
| 1695 |
A command or function that determines whether a key should be offered for |
| 1696 |
completion. |
| 1697 |
|
| 1698 |
It is invoked with the key as its first argument. If it exits with status `0`, |
| 1699 |
the key is offered for completion. Any non-zero exit status suppresses the |
| 1700 |
key. |
| 1701 |
|
| 1702 |
|
| 1703 |
**EXAMPLE** |
| 1704 |
|
| 1705 |
```yaml |
| 1706 |
prog: 'example' |
| 1707 |
options: |
| 1708 |
- option_strings: ['--key-value-pair'] |
| 1709 |
complete: ['key_value_pair', '=', [ |
| 1710 |
['flag', 'An option flag', null], |
| 1711 |
['nodesc', null, null], |
| 1712 |
['nocomp', 'An option with arg but without completer', ['none']], |
| 1713 |
['user', 'Takes a username', ['user']], |
| 1714 |
['check', 'Specify file name conversions', ['choices', { |
| 1715 |
'relaxed': 'convert to lowercase before lookup', |
| 1716 |
'strict': 'no conversion' |
| 1717 |
}]] |
| 1718 |
]] |
| 1719 |
``` |
| 1720 |
|
| 1721 |
``` |
| 1722 |
~ > example --key-value-pair <TAB> |
| 1723 |
check -- Specify file name conversions |
| 1724 |
flag -- An option flag |
| 1725 |
nocomp -- An option with arg but without completer |
| 1726 |
user -- Takes a username |
| 1727 |
nodesc |
| 1728 |
|
| 1729 |
~ > example --key-value-pair user=<TAB> |
| 1730 |
bin braph |
| 1731 |
colord dbus |
| 1732 |
dhcpcd git |
| 1733 |
[...] |
| 1734 |
``` |
| 1735 |
|
| 1736 |
**SEE ALSO** |
| 1737 |
|
| 1738 |
- [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs |
| 1739 |
|
| 1740 |
- [key\_value\_pair\_exec](#key_value_pair_exec): For completing single key=value pairs (dynamically generated by a function) |
| 1741 |
|
| 1742 |
--- |
| 1743 |
|
| 1744 |
### list |
| 1745 |
|
| 1746 |
> Complete comma-separated lists using a completer |
| 1747 |
|
| 1748 |
**SYNOPSIS** |
| 1749 |
|
| 1750 |
```yaml |
| 1751 |
['list', <COMPLETER>] |
| 1752 |
|
| 1753 |
['list', <COMPLETER>, <OPTIONS>] |
| 1754 |
``` |
| 1755 |
|
| 1756 |
**PARAMETERS** |
| 1757 |
|
| 1758 |
`COMPLETER`: |
| 1759 |
The completer used to generate the list elements. |
| 1760 |
|
| 1761 |
`OPTIONS`: |
| 1762 |
A dictionary containing additional options for configuring the list completion. |
| 1763 |
|
| 1764 |
- `separator`: The separator used between list elements. Defaults to `,` |
| 1765 |
|
| 1766 |
- `duplicates`: Allow duplicate values to be offered for completion. Defaults to `false` |
| 1767 |
|
| 1768 |
|
| 1769 |
**EXAMPLE** |
| 1770 |
|
| 1771 |
```yaml |
| 1772 |
prog: 'example' |
| 1773 |
options: |
| 1774 |
- option_strings: ['--user-list'] |
| 1775 |
complete: ['list', ['user']] |
| 1776 |
|
| 1777 |
- option_strings: ['--option-list'] |
| 1778 |
complete: ['list', ['choices', ['setuid', 'async', 'block']], {'separator': ':', 'duplicates': true}] |
| 1779 |
``` |
| 1780 |
|
| 1781 |
``` |
| 1782 |
~ > example --user-list=avahi,daemon,<TAB> |
| 1783 |
bin braph |
| 1784 |
colord dbus |
| 1785 |
dhcpcd git |
| 1786 |
[...] |
| 1787 |
|
| 1788 |
~ > example --option-list=setuid:<TAB> |
| 1789 |
setuid async block |
| 1790 |
``` |
| 1791 |
|
| 1792 |
**SEE ALSO** |
| 1793 |
|
| 1794 |
- [value\_list](#value_list): For completing comma-separated lists of values |
| 1795 |
|
| 1796 |
- [file\_list](#file_list): For completing comma-separated lists of files |
| 1797 |
|
| 1798 |
- [directory\_list](#directory_list): For completing comma-separated lists of directories |
| 1799 |
|
| 1800 |
- [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs |
| 1801 |
|
| 1802 |
--- |
| 1803 |
|
| 1804 |
### none |
| 1805 |
|
| 1806 |
> No completion, but specify that an argument is required |
| 1807 |
|
| 1808 |
**SYNOPSIS** |
| 1809 |
|
| 1810 |
```yaml |
| 1811 |
['none'] |
| 1812 |
``` |
| 1813 |
|
| 1814 |
**PARAMETERS** |
| 1815 |
|
| 1816 |
Disables autocompletion for an option but still marks it as requiring an argument. |
| 1817 |
|
| 1818 |
Without specifying `complete`, the option would not take an argument. |
| 1819 |
|
| 1820 |
|
| 1821 |
**EXAMPLE** |
| 1822 |
|
| 1823 |
```yaml |
| 1824 |
prog: 'example' |
| 1825 |
options: |
| 1826 |
- option_strings: ['--none'] |
| 1827 |
complete: ['none'] |
| 1828 |
``` |
| 1829 |
|
| 1830 |
``` |
| 1831 |
~ > example --none=<TAB> |
| 1832 |
<NO OUTPUT> |
| 1833 |
``` |
| 1834 |
|
| 1835 |
--- |
| 1836 |
|
| 1837 |
### prefix |
| 1838 |
|
| 1839 |
> Prefix completions with a string |
| 1840 |
|
| 1841 |
**SYNOPSIS** |
| 1842 |
|
| 1843 |
```yaml |
| 1844 |
['prefix', <PREFIX>, <COMPLETER>] |
| 1845 |
``` |
| 1846 |
|
| 1847 |
**PARAMETERS** |
| 1848 |
|
| 1849 |
`PREFIX`: |
| 1850 |
The string to prepend to each completion candidate. |
| 1851 |
|
| 1852 |
`COMPLETER`: |
| 1853 |
The completer used to generate the completion candidates. |
| 1854 |
|
| 1855 |
|
| 1856 |
**EXAMPLE** |
| 1857 |
|
| 1858 |
```yaml |
| 1859 |
prog: 'example' |
| 1860 |
options: |
| 1861 |
- option_strings: ['--prefix'] |
| 1862 |
complete: ['prefix', 'input:', ['file']] |
| 1863 |
``` |
| 1864 |
|
| 1865 |
``` |
| 1866 |
~ > example --prefix=<TAB> |
| 1867 |
~ > example --prefix=input: |
| 1868 |
|
| 1869 |
~ > example --prefix=input:<TAB> |
| 1870 |
~ > example --prefix=input:file1.txt |
| 1871 |
``` |
| 1872 |
|
| 1873 |
--- |
| 1874 |
|
| 1875 |
### exec |
| 1876 |
|
| 1877 |
> Complete values from the output of a command or function |
| 1878 |
|
| 1879 |
**SYNOPSIS** |
| 1880 |
|
| 1881 |
```yaml |
| 1882 |
['exec', <COMMAND>] |
| 1883 |
``` |
| 1884 |
|
| 1885 |
**PARAMETERS** |
| 1886 |
|
| 1887 |
`COMMAND`: |
| 1888 |
The command or function to execute. Its output must be formatted as tab-separated values: |
| 1889 |
|
| 1890 |
``` |
| 1891 |
<ITEM_1>\t<DESCRIPTION_1> |
| 1892 |
<ITEM_2>\t<DESCRIPTION_2> |
| 1893 |
[...] |
| 1894 |
``` |
| 1895 |
|
| 1896 |
Each line represents one completion candidate. The item and its description are separated by a tab character. |
| 1897 |
|
| 1898 |
|
| 1899 |
**NOTES** |
| 1900 |
|
| 1901 |
- Functions can be put inside a file and included with `--include-file` |
| 1902 |
|
| 1903 |
**EXAMPLE** |
| 1904 |
|
| 1905 |
```yaml |
| 1906 |
prog: 'example' |
| 1907 |
options: |
| 1908 |
- option_strings: ['--exec'] |
| 1909 |
complete: ['exec', "printf '%s\\t%s\\n' 'Item 1' 'Description 1' 'Item 2' 'Description 2'"] |
| 1910 |
``` |
| 1911 |
|
| 1912 |
``` |
| 1913 |
~ > example --exec=<TAB> |
| 1914 |
Item 1 (Description 1) Item 2 (Description 2) |
| 1915 |
``` |
| 1916 |
|
| 1917 |
**SEE ALSO** |
| 1918 |
|
| 1919 |
- [exec\_fast](#exec_fast): Faster implementation of exec |
| 1920 |
|
| 1921 |
- [exec\_internal](#exec_internal): Use the shell's internal completion mechanisms |
| 1922 |
|
| 1923 |
--- |
| 1924 |
|
| 1925 |
### exec\_fast |
| 1926 |
|
| 1927 |
> Complete values from the output of a command or function (fast and unsafe) |
| 1928 |
|
| 1929 |
**SYNOPSIS** |
| 1930 |
|
| 1931 |
```yaml |
| 1932 |
['exec_fast', <COMMAND>] |
| 1933 |
``` |
| 1934 |
|
| 1935 |
**PARAMETERS** |
| 1936 |
|
| 1937 |
Faster version of `exec` for handling large amounts of data. |
| 1938 |
|
| 1939 |
Unlike `exec`, this implementation does not safely handle arbitrary output. |
| 1940 |
Completion items must not contain whitespace or special shell characters. |
| 1941 |
|
| 1942 |
|
| 1943 |
**NOTES** |
| 1944 |
|
| 1945 |
- Functions can be put inside a file and included with `--include-file` |
| 1946 |
|
| 1947 |
**EXAMPLE** |
| 1948 |
|
| 1949 |
```yaml |
| 1950 |
prog: 'example' |
| 1951 |
options: |
| 1952 |
- option_strings: ['--exec-fast'] |
| 1953 |
complete: ['exec_fast', "printf '%s\\t%s\\n' 1 one 2 two"] |
| 1954 |
``` |
| 1955 |
|
| 1956 |
``` |
| 1957 |
~ > example --exec-fast=<TAB> |
| 1958 |
1 -- one |
| 1959 |
2 -- one |
| 1960 |
``` |
| 1961 |
|
| 1962 |
--- |
| 1963 |
|
| 1964 |
### exec\_internal |
| 1965 |
|
| 1966 |
> Use the shell's internal completion mechanisms |
| 1967 |
|
| 1968 |
**SYNOPSIS** |
| 1969 |
|
| 1970 |
```yaml |
| 1971 |
['exec_internal', <COMMAND>] |
| 1972 |
``` |
| 1973 |
|
| 1974 |
**PARAMETERS** |
| 1975 |
|
| 1976 |
Execute a function that internally modifies the completion state. |
| 1977 |
|
| 1978 |
This is useful if a more advanced completion is needed. |
| 1979 |
|
| 1980 |
For **Bash**, it might look like: |
| 1981 |
|
| 1982 |
```sh |
| 1983 |
my_completion_func() { |
| 1984 |
COMPREPLY=( $(compgen -W 'read write append' -- '$cur') ) |
| 1985 |
} |
| 1986 |
``` |
| 1987 |
|
| 1988 |
For **Zsh**, it might look like: |
| 1989 |
|
| 1990 |
```sh |
| 1991 |
my_completion_func() { |
| 1992 |
local items=( |
| 1993 |
read:'Read data from a file' |
| 1994 |
write:'Write data from a file' |
| 1995 |
append:'Append data to a file' |
| 1996 |
) |
| 1997 |
|
| 1998 |
_describe 'my items' items |
| 1999 |
} |
| 2000 |
``` |
| 2001 |
|
| 2002 |
For **Fish**, it might look like: |
| 2003 |
|
| 2004 |
```sh |
| 2005 |
function my_completion_func |
| 2006 |
printf '%s\t%s\n' \ |
| 2007 |
read 'Read data from a file' \ |
| 2008 |
write 'Write data from a file' \ |
| 2009 |
append 'Append data to a file' |
| 2010 |
end |
| 2011 |
``` |
| 2012 |
|
| 2013 |
|
| 2014 |
**NOTES** |
| 2015 |
|
| 2016 |
- Functions can be put inside a file and included with `--include-file` |
| 2017 |
|
| 2018 |
**EXAMPLE** |
| 2019 |
|
| 2020 |
```yaml |
| 2021 |
prog: 'example' |
| 2022 |
options: |
| 2023 |
- option_strings: ['--exec-internal'] |
| 2024 |
complete: ['exec_internal', 'my_completion_func'] |
| 2025 |
``` |
| 2026 |
|
| 2027 |
``` |
| 2028 |
~ > example --exec-internal=<TAB> |
| 2029 |
append -- Append data to a file |
| 2030 |
read -- Read data from a file |
| 2031 |
write -- Write data from a file |
| 2032 |
``` |
| 2033 |
|
| 2034 |
--- |
| 2035 |
|
| 2036 |
### key\_value\_list\_exec |
| 2037 |
|
| 2038 |
> Complete dynamically generated comma-separted lists of key=value pairs |
| 2039 |
|
| 2040 |
**SYNOPSIS** |
| 2041 |
|
| 2042 |
```yaml |
| 2043 |
['key_value_list_exec', <PAIR_SEPARATOR>, <VALUE_SEPARATOR>, <COMMAND>] |
| 2044 |
``` |
| 2045 |
|
| 2046 |
**PARAMETERS** |
| 2047 |
|
| 2048 |
`PAIR_SEPARATOR`: |
| 2049 |
The separator used to separate individual key-value pairs. |
| 2050 |
|
| 2051 |
`VALUE_SEPARATOR`: |
| 2052 |
The separator used to separate a key from its value. |
| 2053 |
|
| 2054 |
`COMMAND`: |
| 2055 |
The command or function used to generate the available keys and values. |
| 2056 |
|
| 2057 |
If invoked without arguments, it must output the available keys in the |
| 2058 |
following format: |
| 2059 |
|
| 2060 |
``` |
| 2061 |
[*]<KEY_1>[=][?]\t<DESCRIPTION_1>\t<EXCLUDES> |
| 2062 |
[*]<KEY_2>[=][?]\t<DESCRIPTION_2>\t<EXCLUDES> |
| 2063 |
[...] |
| 2064 |
``` |
| 2065 |
|
| 2066 |
Prefixing a key with `*` marks it as repeatable. |
| 2067 |
|
| 2068 |
Appending `=` to a key indicates that it requires a value. |
| 2069 |
|
| 2070 |
Appending `=?` to a key indicates that it requires an optional value. |
| 2071 |
|
| 2072 |
`EXCLUDES` is a space-separated list of keys that should no longer be |
| 2073 |
offered once the current key has been used. |
| 2074 |
|
| 2075 |
If invoked with a single argument, the argument is the selected key. |
| 2076 |
The command must output the possible values for that key in the following |
| 2077 |
format: |
| 2078 |
|
| 2079 |
``` |
| 2080 |
<ITEM_1>\t<DESCRIPTION_1> |
| 2081 |
<ITEM_2>\t<DESCRIPTION_2> |
| 2082 |
[...] |
| 2083 |
``` |
| 2084 |
|
| 2085 |
Each line represents one completion candidate. The item and its description |
| 2086 |
are separated by a tab character. |
| 2087 |
|
| 2088 |
Example function: |
| 2089 |
|
| 2090 |
```sh |
| 2091 |
_complete_key_value_list() { |
| 2092 |
if (( $# == 0 )); then |
| 2093 |
printf '%s\t%s\t%s\n' \ |
| 2094 |
'flag' 'option without an argument' '' \ |
| 2095 |
'argument=' 'option with an argument' '' \ |
| 2096 |
'optional=?' 'option with an optional argument' '' \ |
| 2097 |
'*repeatable' 'a repeatable option' '' \ |
| 2098 |
'excludes' 'disable options' 'flag argument' |
| 2099 |
else |
| 2100 |
case '$1' in |
| 2101 |
argument|optional) |
| 2102 |
printf '%s\t%s\n' \ |
| 2103 |
'foo' 'a foo value' \ |
| 2104 |
'bar' 'a bar value';; |
| 2105 |
esac |
| 2106 |
fi |
| 2107 |
} |
| 2108 |
``` |
| 2109 |
|
| 2110 |
|
| 2111 |
**NOTES** |
| 2112 |
|
| 2113 |
- Functions can be put inside a file and included with `--include-file` |
| 2114 |
|
| 2115 |
**EXAMPLE** |
| 2116 |
|
| 2117 |
```yaml |
| 2118 |
prog: 'example' |
| 2119 |
options: |
| 2120 |
- option_strings: ['-o'] |
| 2121 |
complete: ['key_value_list_exec', ',', '=', '_complete_key_value_list'] |
| 2122 |
``` |
| 2123 |
|
| 2124 |
``` |
| 2125 |
~ > example -o <TAB> |
| 2126 |
argument -- option with an argument |
| 2127 |
excludes -- disable options |
| 2128 |
flag -- option without an argument |
| 2129 |
optional -- option with an optional argument |
| 2130 |
repeatable -- a repeatable option |
| 2131 |
|
| 2132 |
~ > example -o argument=<TAB> |
| 2133 |
foo -- a foo value |
| 2134 |
bar -- a bar value |
| 2135 |
|
| 2136 |
~ > example -o excludes,<TAB> |
| 2137 |
optional -- option with an optional argument |
| 2138 |
repeatable -- a repeatable option |
| 2139 |
``` |
| 2140 |
|
| 2141 |
**SEE ALSO** |
| 2142 |
|
| 2143 |
- [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs |
| 2144 |
|
| 2145 |
--- |
| 2146 |
|
| 2147 |
### key\_value\_pair\_exec |
| 2148 |
|
| 2149 |
> Complete dynamically generated a key=value pairs |
| 2150 |
|
| 2151 |
**SYNOPSIS** |
| 2152 |
|
| 2153 |
```yaml |
| 2154 |
['key_value_pair_exec', <VALUE_SEPARATOR>, <COMMAND>] |
| 2155 |
``` |
| 2156 |
|
| 2157 |
**PARAMETERS** |
| 2158 |
|
| 2159 |
`VALUE_SEPARATOR`: |
| 2160 |
The separator used to separate a key from its value. |
| 2161 |
|
| 2162 |
`COMMAND`: |
| 2163 |
The command or function used to generate the available keys and values. |
| 2164 |
|
| 2165 |
If invoked without arguments, it must output the available keys in the |
| 2166 |
following format: |
| 2167 |
|
| 2168 |
``` |
| 2169 |
<KEY_1>[=]\t<DESCRIPTION_1> |
| 2170 |
<KEY_2>[=]\t<DESCRIPTION_2> |
| 2171 |
[...] |
| 2172 |
``` |
| 2173 |
|
| 2174 |
Appending `=` to a key indicates that it requires a value. |
| 2175 |
|
| 2176 |
If invoked with a single argument, the argument is the selected key. The |
| 2177 |
command must output the possible values for that key in the following |
| 2178 |
format: |
| 2179 |
|
| 2180 |
``` |
| 2181 |
<ITEM_1>\t<DESCRIPTION_1> |
| 2182 |
<ITEM_2>\t<DESCRIPTION_2> |
| 2183 |
[...] |
| 2184 |
``` |
| 2185 |
|
| 2186 |
Each line represents one completion candidate. The item and its description |
| 2187 |
are separated by a tab character. |
| 2188 |
|
| 2189 |
Example function: |
| 2190 |
|
| 2191 |
```sh |
| 2192 |
_complete_key_value_pair() { |
| 2193 |
if (( $# == 0 )); then |
| 2194 |
printf '%s\t%s\n' \ |
| 2195 |
'flag' 'a flag' \ |
| 2196 |
'option=' 'option with value' |
| 2197 |
else |
| 2198 |
case '$1' in |
| 2199 |
option) |
| 2200 |
printf '%s\t%s\n' \ |
| 2201 |
'foo' 'a foo value' \ |
| 2202 |
'bar' 'a bar value';; |
| 2203 |
esac |
| 2204 |
fi |
| 2205 |
} |
| 2206 |
``` |
| 2207 |
|
| 2208 |
|
| 2209 |
**NOTES** |
| 2210 |
|
| 2211 |
- Functions can be put inside a file and included with `--include-file` |
| 2212 |
|
| 2213 |
**EXAMPLE** |
| 2214 |
|
| 2215 |
```yaml |
| 2216 |
prog: 'example' |
| 2217 |
options: |
| 2218 |
- option_strings: ['-o'] |
| 2219 |
complete: ['key_value_pair_exec', '=', '_complete_key_value_pair'] |
| 2220 |
``` |
| 2221 |
|
| 2222 |
``` |
| 2223 |
~ > example -o <TAB> |
| 2224 |
flag -- a flag |
| 2225 |
option -- option with value |
| 2226 |
|
| 2227 |
~ > example -o option=<TAB> |
| 2228 |
foo -- a foo value |
| 2229 |
bar -- a bar value |
| 2230 |
``` |
| 2231 |
|
| 2232 |
**SEE ALSO** |
| 2233 |
|
| 2234 |
- [key\_value\_pair](#key_value_pair): For completing single key=value pairs |