### Meta commands | Command | Description | | ----------------------------------- | ------------------------------------------------------- | | [combine](#combine) | Combine multiple completers | | [key\_value\_list](#key_value_list) | Complete comma-separated lists of key=value pairs | | [key\_value\_pair](#key_value_pair) | Complete single key=value pairs | | [list](#list) | Complete comma-separated lists using a completer | | [none](#none) | No completion, but specify that an argument is required | | [prefix](#prefix) | Prefix completions with a string | --- ### Built-in commands | Command | Description | | ------------------------------------------ | --------------------------------------------- | | [choices](#choices) | Complete from a predefined set of values | | [command](#command) | Complete command names | | [command\_arg](#command_arg) | Complete command arguments | | [commandline\_string](#commandline_string) | Complete command lines as strings | | [date](#date) | Complete date strings | | [date\_format](#date_format) | Complete date format strings | | [directory](#directory) | Complete directory names | | [directory\_list](#directory_list) | Complete comma-separated lists of directories | | [environment](#environment) | Complete environment variable names | | [file](#file) | Complete file names | | [file\_list](#file_list) | Complete comma-separated lists of files | | [filesystem\_type](#filesystem_type) | Complete filesystem types | | [float](#float) | Complete floating-point values | | [gid](#gid) | Complete group IDs | | [group](#group) | Complete group names | | [history](#history) | Complete based on a shell's history | | [hostname](#hostname) | Complete hostnames | | [integer](#integer) | Complete integer values | | [ip\_address](#ip_address) | Complete local IP addresses | | [mime\_file](#mime_file) | Complete files by MIME type | | [pid](#pid) | Complete process IDs | | [process](#process) | Complete process names | | [range](#range) | Complete sequences of integers | | [service](#service) | Complete systemd service names | | [signal](#signal) | Complete signal names | | [uid](#uid) | Complete user IDs | | [user](#user) | Complete user names | | [value\_list](#value_list) | Complete comma-separated lists of values | | [variable](#variable) | Complete shell variable names | --- ### User-defined commands | Command | Description | | ---------------------------------------------- | -------------------------------------------------------------------------- | | [exec](#exec) | Complete values from the output of a command or function | | [exec\_fast](#exec_fast) | Complete values from the output of a command or function (fast and unsafe) | | [exec\_internal](#exec_internal) | Use the shell's internal completion mechanisms | | [key\_value\_list\_exec](#key_value_list_exec) | Complete dynamically generated comma-separted lists of key=value pairs | | [key\_value\_pair\_exec](#key_value_pair_exec) | Complete dynamically generated a key=value pairs | --- ### Bonus commands | Command | Description | | -------------------------------- | --------------------------- | | [alsa\_card](#alsa_card) | Complete ALSA cards | | [alsa\_device](#alsa_device) | Complete ALSA devices | | [charset](#charset) | Complete character sets | | [locale](#locale) | Complete locales | | [login\_shell](#login_shell) | Complete login shells | | [mountpoint](#mountpoint) | Complete mount points | | [net\_interface](#net_interface) | Complete network interfaces | | [timezone](#timezone) | Complete timezones | --- ### alsa\_card > Complete ALSA cards **SYNOPSIS** ```yaml ['alsa_card'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--alsa-card'] complete: ['alsa_card'] ``` ``` ~ > example --alsa-card= 0 1 ``` **SEE ALSO** - [alsa\_device](#alsa_device): For completing ALSA devices --- ### alsa\_device > Complete ALSA devices **SYNOPSIS** ```yaml ['alsa_device'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--alsa-device'] complete: ['alsa_device'] ``` ``` ~ > example --alsa-device= hw:0 hw:1 ``` **SEE ALSO** - [alsa\_card](#alsa_card): For completing ALSA cards --- ### charset > Complete character sets **SYNOPSIS** ```yaml ['charset'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--charset'] complete: ['charset'] ``` ``` ~ > example --charset=A ANSI_X3.110-1983 ANSI_X3.4-1968 ARMSCII-8 ASMO_449 ``` --- ### locale > Complete locales **SYNOPSIS** ```yaml ['locale'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--locale'] complete: ['locale'] ``` ``` ~ > example --locale= C C.UTF-8 de_DE de_DE@euro de_DE.iso88591 de_DE.iso885915@euro de_DE.UTF-8 deutsch en_US en_US.iso88591 en_US.UTF-8 german POSIX ``` --- ### login\_shell > Complete login shells **SYNOPSIS** ```yaml ['login_shell'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--login-shell'] complete: ['login_shell'] ``` ``` ~ > example --login-shell= /bin/bash /bin/sh /usr/bin/fish /usr/bin/sh [...] ``` --- ### mountpoint > Complete mount points **SYNOPSIS** ```yaml ['mountpoint'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--mountpoint'] complete: ['mountpoint'] ``` ``` ~ > example --mountpoint= / /boot /home /proc /run /sys /tmp [...] ``` --- ### net\_interface > Complete network interfaces **SYNOPSIS** ```yaml ['net_interface'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--net-interface'] complete: ['net_interface'] ``` ``` ~ > example --net-interface= eno1 enp1s0 lo wlo1 wlp2s0 [...] ``` **SEE ALSO** - [ip\_address](#ip_address): For completing IP addresses --- ### timezone > Complete timezones **SYNOPSIS** ```yaml ['timezone'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--timezone'] complete: ['timezone'] ``` ``` ~ > example --timezone=Europe/B Belfast Belgrade Berlin Bratislava Brussels Bucharest Budapest Busingen ``` --- ### choices > Complete from a predefined set of values **SYNOPSIS** ```yaml ['choices', ] ``` **PARAMETERS** `ITEMS`: A list or dictionary containing the values to offer for completion. If a list is supplied, all items are offered without descriptions. If a dictionary is supplied, the keys are used as completion values and the values are used as descriptions. **NOTES** - If the completion suggestions should appear in their original order, set `nosort` to `true` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--choices-1'] complete: ['choices', ['Item 1', 'Item 2']] - option_strings: ['--choices-2'] complete: ['choices', {'Item 1': 'Description 1', 'Item 2': 'Description 2'}] - option_strings: ['--choices-keep-order'] complete: ['choices', ['zebra', 'cat', 'monkey']] nosort: true ``` ``` ~ > example --choices-2= Item 1 (Description 1) Item 2 (Description 2) ~ > example --choices-keep-order= zebra cat monkey ``` --- ### command > Complete command names **SYNOPSIS** ```yaml ['command'] ['command', ] ``` **PARAMETERS** This completer provides completion suggestions for executable commands available in the system's `$PATH`. `OPTIONS`: A dictionary containing additional options for configuring the completion. - `path`: Override the default `$PATH` used for searching executables. - `path_append`: Append directories to the default `$PATH`. - `path_prepend`: Prepend directories to the default `$PATH`. **NOTES** - `path_append` and `path_prepend` can be used together, but both are mutually exclusive with `path`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--command'] complete: ['command'] - option_strings: ['--command-sbin'] complete: ['command', {'path_append': '/sbin:/usr/sbin'}] ``` ``` ~ > example --command=bas base32 base64 basename basenc bash bashbug ``` **SEE ALSO** - [command\_arg](#command_arg): For completing arguments of a command - [commandline\_string](#commandline_string): For completing command lines as strings --- ### command\_arg > Complete command arguments **SYNOPSIS** ```yaml ['command_arg'] ``` **NOTES** - This completer can only be used in combination with a previously defined `command` completer. - This completer requires `repeatable: true`. **EXAMPLE** ```yaml prog: 'example' positionals: - number: 1 complete: ['command'] - number: 2 complete: ['command_arg'] repeatable: true ``` ``` ~ > example sudo bas base32 base64 basename basenc bash bashbug ``` **SEE ALSO** - [command](#command): For completing command names - [commandline\_string](#commandline_string): For completing command lines as strings --- ### commandline\_string > Complete command lines as strings **SYNOPSIS** ```yaml ['commandline_string'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--commandline'] complete: ['commandline_string'] ``` ``` ~ > example --commandline='sudo ba base32 base64 basename basenc bash bashbug ``` **SEE ALSO** - [command](#command): For completing command names - [command\_arg](#command_arg): For completing command arguments --- ### date > Complete date strings **SYNOPSIS** ```yaml ['date', ] ``` **PARAMETERS** `FORMAT`: The date format as described in `strftime(3)`. **NOTES** - This completer is currently only implemented in **Zsh**. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--date'] complete: ['date', '%Y-%m-%d'] ``` ``` ~ > example --date= November Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ``` **SEE ALSO** - [date\_format](#date_format): For completing date format strings --- ### date\_format > Complete date format strings **SYNOPSIS** ```yaml ['date_format'] ``` **NOTES** - This completer is currently only implemented in **Fish** and **Zsh**. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--date-format'] complete: ['date_format'] ``` ``` ~ > example --date-format '% a -- abbreviated day name A -- full day name B -- full month name c -- preferred locale date and time C -- 2-digit century d -- day of month (01-31) D -- American format month/day/year (%m/%d/%y) e -- day of month ( 1-31) [...] ``` **SEE ALSO** - [date](#date): For completing dates --- ### directory > Complete directory names **SYNOPSIS** ```yaml ['directory'] ['directory', ] ``` **PARAMETERS** `OPTIONS`: A dictionary containing additional options for configuring the completion. - `directory`: Restrict completion to directories inside the specified directory. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--directory'] complete: ['directory'] - option_strings: ['--directory-tmp'] complete: ['directory', {'directory': '/tmp'}] ``` ``` ~ > example --directory= dir1/ dir2/ ``` **SEE ALSO** - [directory\_list](#directory_list): For completing comma-separated lists of directories --- ### directory\_list > Complete comma-separated lists of directories **SYNOPSIS** ```yaml ['directory_list'] ['directory_list', ] ``` **PARAMETERS** This is an alias for `['list', ['directory']]`. `OPTIONS`: A dictionary containing additional options for configuring the completion. - `directory`: Restrict completion to directories inside the specified directory. - `duplicates`: Allow duplicate values to be offered for completion. Defaults to `false`. - `separator`: The separator used between list elements. Defaults to `,`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--directory-list'] complete: ['directory_list'] ``` ``` ~ > example --directory-list=directory1,directory2, directory3 directory4 ``` **SEE ALSO** - [list](#list): For completion comma-separated lists using a completer - [directory](#directory): For completing directory names - [file\_list](#file_list): For completing comma-separated lists of files --- ### environment > Complete environment variable names **SYNOPSIS** ```yaml ['environment'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--environment'] complete: ['environment'] ``` ``` ~ > example --environment=X XDG_RUNTIME_DIR XDG_SEAT XDG_SESSION_CLASS XDG_SESSION_ID XDG_SESSION_TYPE XDG_VTNR ``` **SEE ALSO** - [variable](#variable): For completing shell variable names --- ### file > Complete file names **SYNOPSIS** ```yaml ['file'] ['file', ] ``` **PARAMETERS** `OPTIONS`: A dictionary containing additional options for configuring the completion. - `directory`: Restrict completion to files inside the specified directory. - `extensions`: A list of file extensions to offer for completion. - `fuzzy`: Enable fuzzy extension matching. By default, files must end with one of the specified extensions. With fuzzy matching enabled, files with additional suffixes are also matched, for example `foo.txt.1`. - `ignore_globs`: A list of Bash globs for files that should not be offered for completion. **NOTE:** Restricting completion to specific file extensions only makes sense if the program being completed actually expects files of those types. On Unix-like systems, file extensions generally have no inherent meaning and are only conventions. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--file'] complete: ['file'] - option_strings: ['--file-tmp'] complete: ['file', {'directory': '/tmp'}] - option_strings: ['--file-ext'] complete: ['file', {'extensions': ['c', 'cpp']}] - option_strings: ['--file-ignore'] complete: ['file', {'ignore_globs': ['*.[tT][xX][tT]', '*.c++']}] ``` ``` ~ > example --file= dir1/ dir2/ file1 file2 ~ > example --file-ext= dir1/ dir2/ file.c file.cpp ``` **SEE ALSO** - [file\_list](#file_list): For completing comma-separated lists of files - [mime\_file](#mime_file): For completing files by MIME type --- ### file\_list > Complete comma-separated lists of files **SYNOPSIS** ```yaml ['file_list'] ['file_list', ] ``` **PARAMETERS** This is an alias for `['list', ['file']]`. `OPTIONS`: A dictionary containing additional options for configuring the completion. - `directory`: Restrict completion to files inside the specified directory. - `extensions`: A list of file extensions to offer for completion. - `fuzzy`: Enable fuzzy extension matching. By default, files must end with one of the specified extensions. With fuzzy matching enabled, files with additional suffixes are also matched, for example `foo.txt.1`. - `ignore_globs`: A list of Bash globs for files that should not be offered for completion. - `duplicates`: Allow duplicate values to be offered for completion. Defaults to `false`. - `separator`: The separator used between list elements. Defaults to `,`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--file-list'] complete: ['file_list'] ``` ``` ~ > example --file-list=file1,file2, file3 file4 ``` **SEE ALSO** - [list](#list): For completing comma-separted lists using a completer - [file](#file): For completing file names - [directory\_list](#directory_list): For completing comma-separated lists of directories --- ### filesystem\_type > Complete filesystem types **SYNOPSIS** ```yaml ['filesystem_type'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--filesystem-type'] complete: ['filesystem_type'] ``` ``` ~ > example --filesystem-type= adfs autofs bdev bfs binder binfmt_misc bpf cgroup cgroup2 configfs cramfs debugfs devpts devtmpfs [...] ``` --- ### float > Complete floating-point values **SYNOPSIS** ```yaml ['float'] ['float', ] ``` **PARAMETERS** `OPTIONS`: A dictionary containing additional options for configuring the completion. - `min`: The minimum allowed value. - `max`: The maximum allowed value. - `suffixes`: A dictionary of suffixes and their descriptions. The suffix is appended to the completed value. - `help`: The help text shown during completion. If not specified, the `help` attribute of the option is used. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--time'] complete: ['float', {'suffixes': {'s': 'seconds', 'm': 'minutes', 'h': 'hours'}}] ``` ``` ~ > example --time=3.0 s -- seconds m -- minutes h -- hours ``` **SEE ALSO** - [integer](#integer): For completing integer values --- ### gid > Complete group IDs **SYNOPSIS** ```yaml ['gid'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--gid'] complete: ['gid'] ``` ``` ~ > example --gid= 0 -- root 1000 -- braph 102 -- polkitd 108 -- vboxusers 11 -- ftp 12 -- mail 133 -- rtkit 19 -- log [...] ``` **SEE ALSO** - [group](#group): For completing group names --- ### group > Complete group names **SYNOPSIS** ```yaml ['group'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--group'] complete: ['group'] ``` ``` ~ > example --group= adm audio avahi bin braph colord daemon dbus dhcpcd disk floppy ftp games git groups [...] ``` **SEE ALSO** - [gid](#gid): For completing group IDs --- ### history > Complete based on a shell's history **SYNOPSIS** ```yaml ['history', ] ``` **PARAMETERS** `REGEX`: An extended regular expression used to filter history entries. The regular expression is passed to `grep -E`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--history'] complete: ['history', '[a-zA-Z0-9]+@[a-zA-Z0-9]+'] ``` ``` ~ > example --history= foo@bar mymail@myprovider ``` --- ### hostname > Complete hostnames **SYNOPSIS** ```yaml ['hostname'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--hostname'] complete: ['hostname'] ``` ``` ~ > example --hostname= localhost ``` **SEE ALSO** - [ip\_address](#ip_address): For completing local IP addresses --- ### integer > Complete integer values **SYNOPSIS** ```yaml ['integer'] ['integer', ] ``` **PARAMETERS** `OPTIONS`: A dictionary containing additional options for configuring the completion. - `min`: The minimum allowed value. - `max`: The maximum allowed value. - `suffixes`: A dictionary of suffixes and their descriptions. The suffix is appended to the completed value. - `help`: The help text shown during completion. If not specified, the `help` attribute of the option is used. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--time'] complete: ['integer', {'suffixes': {'s': 'seconds', 'm': 'minutes', 'h': 'hours'}}] ``` ``` ~ > example --integer=3 s -- seconds m -- minutes h -- hours ``` **SEE ALSO** - [float](#float): For completing floating-point values - [range](#range): For completing sequences of integers --- ### ip\_address > Complete local IP addresses **SYNOPSIS** ```yaml ['ip_address', ] ``` **PARAMETERS** `TYPE`: The type of ip addresses to complete: - `ipv4`: IPv4 addresses - `ipv6`: IPv6 addresses - `all`: Both IPv4 and IPv6 addresses Append `+` to include the unspecified address of the selected family: - `ipv4+`: Includes `0.0.0.0` - `ipv6+`: Includes `::` - `all+`: Includes both 0.0.0.0 and `::` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--ip-address'] complete: ['ip_address'] - option_strings: ['--ip-address-v4'] complete: ['ip_address', 'ipv4'] - option_strings: ['--ip-address-v6'] complete: ['ip_address', 'ipv6'] ``` ``` ~ > example --ip-address= ::1 10.0.0.71 127.0.0.1 fe80::f567:7a1a:3c98:808d ~ > example --ip-address-v4= 10.0.0.71 127.0.0.1 ~ > example --ip-address-v6= ::1 fe80::f567:7a1a:3c98:808d ``` **SEE ALSO** - [net\_interface](#net_interface): For completing network interfaces - [hostname](#hostname): For completing hostnames --- ### mime\_file > Complete files by MIME type **SYNOPSIS** ```yaml ['mime_file', ] ``` **PARAMETERS** `MIME_REGEX`: An extended regular expression used to match MIME types. The expression is passed to `grep -E` to filter the results. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--image'] complete: ['mime_file', 'image/'] ``` ``` ~ > example --image= dir1/ dir2/ img.png img.jpg ``` --- ### pid > Complete process IDs **SYNOPSIS** ```yaml ['pid'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--pid'] complete: ['pid'] ``` ``` ~ > example --pid= 1 13 166 19 254 31 45 1006 133315 166441 19042 26 32 46 10150 1392 166442 195962 27 33 4609 ``` **SEE ALSO** - [process](#process): For completing process names --- ### process > Complete process names **SYNOPSIS** ```yaml ['process'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--process'] complete: ['process'] ``` ``` ~ > example --process=s scsi_eh_0 scsi_eh_1 scsi_eh_2 scsi_eh_3 scsi_eh_4 scsi_eh_5 sh sudo syndaemon systemd systemd-journald systemd-logind systemd-udevd ``` **SEE ALSO** - [pid](#pid): For completing process IDs --- ### range > Complete sequences of integers **SYNOPSIS** ```yaml ['range', , ] ['range', , , ] ``` **PARAMETERS** `START`: The first value of the range. `STOP`: The last value of the range. `STEP`: The increment between values. Defaults to `1`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--range-1'] complete: ['range', 1, 9] - option_strings: ['--range-2'] complete: ['range', 1, 9, 2] ``` ``` ~ > example --range-1= 1 2 3 4 5 6 7 8 9 ~ > example --range-2= 1 3 5 7 9 ``` --- ### service > Complete systemd service names **SYNOPSIS** ```yaml ['service'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--service'] complete: ['service'] ``` ``` ~ > example --service= TODO [...] ``` --- ### signal > Complete signal names **SYNOPSIS** ```yaml ['signal'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--signal'] complete: ['signal'] ``` ``` ~ > example --signal= ABRT -- Process abort signal ALRM -- Alarm clock BUS -- Access to an undefined portion of a memory object CHLD -- Child process terminated, stopped, or continued CONT -- Continue executing, if stopped FPE -- Erroneous arithmetic operation HUP -- Hangup ILL -- Illegal instruction INT -- Terminal interrupt signal [...] ``` --- ### uid > Complete user IDs **SYNOPSIS** ```yaml ['uid'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--uid'] complete: ['uid'] ``` ``` ~ > example --uid= 0 -- root 1000 -- braph 102 -- polkitd 133 -- rtkit 14 -- ftp 1 -- bin 2 -- daemon 33 -- http 65534 -- nobody [...] ``` **SEE ALSO** - [user](#user): For completing user names --- ### user > Complete user names **SYNOPSIS** ```yaml ['user'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--user'] complete: ['user'] ``` ``` ~ > example --user= avahi bin braph colord daemon dbus dhcpcd ftp git [...] ``` **SEE ALSO** - [uid](#uid): For completing user IDs --- ### value\_list > Complete comma-separated lists of values **SYNOPSIS** ```yaml ['value_list', ] ``` **PARAMETERS** `OPTIONS`: A dictionary containing additional options for configuring the completion. - `values`: A list or dictionary containing the values to offer for completion. If a list is supplied, all values are offered without descriptions. If a dictionary is supplied, the keys are used as completion values and the values are used as descriptions. - `separator`: The separator used between list elements. Defaults to `,`. - `duplicates`: Allow duplicate values to be offered for completion. Defaults to `false`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--value-list-1'] complete: ['value_list', {'values': ['exec', 'noexec']}] - option_strings: ['--value-list-2'] complete: ['value_list', {'values': {'one': 'Description 1', 'two': 'Description 2'}}] ``` ``` ~ > example --value-list-1= exec noexec ~ > example --value-list-1=exec, noexec ~ > example --value-list-2= one -- Description 1 two -- Description 2 ``` **SEE ALSO** - [list](#list): For completing comma-separated lists using a completer - [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs --- ### variable > Complete shell variable names **SYNOPSIS** ```yaml ['variable'] ``` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--variable'] complete: ['variable'] ``` ``` ~ > example --variable=HO HOME HOSTNAME HOSTTYPE ``` **SEE ALSO** - [environment](#environment): For completing environment variable names --- ### combine > Combine multiple completers **SYNOPSIS** ```yaml ['combine', ] ``` **PARAMETERS** Combines multiple completers into a single completer. `COMPLETERS`: A list of completers to combine. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--combine'] complete: ['combine', [['user'], ['pid']]] ``` ``` ~ > example --combine=avahi,daemon, 1439404 3488332 3571716 3607235 4134206 alpm avahi bin braph daemon root rtkit systemd-coredump systemd-journal-remote systemd-network [...] ``` --- ### key\_value\_list > Complete comma-separated lists of key=value pairs **SYNOPSIS** ```yaml ['key_value_list', , , ] ['key_value_list', , , , ] ``` **PARAMETERS** `PAIR_SEPARATOR`: The separator used to separate individual key-value pairs. `VALUE_SEPARATOR`: The separator used to separate a key from its value. `DEFINITIONS`: A list of key definitions. Each definition has one of the following forms: `[, , ]` -- OR -- `[, , , ]` `KEY`: The name of the key. Prefix the name with `*` to allow the key to be completed multiple times. `DESCRIPTION`: A description shown during completion. Use `null` to omit the description. `COMPLETER`: The completer used for the value of the key. Use `null` if the key does not take an argument. Use `['none']` if the key takes an argument but cannot be completed. `EXCLUDES`: A list of keys that should no longer be offered for completion once this key has been used. `CONDITION_FUNCTION`: A command or function that determines whether a key should be offered for completion. It is invoked with the key as its first argument. If it exits with status `0`, the key is offered for completion. Any non-zero exit status suppresses the key. By default, each key is offered for completion only once. To allow a key to be completed multiple times, prefix its name with `*`. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--key-value-list'] complete: ['key_value_list', ',', '=', [ ['flag', 'An option flag', null], ['nodesc', null, null], ['nocomp', 'An option with arg but without completer', ['none']], ['user', 'Takes a username', ['user']], ['*repeatable', 'This option is repeatable', null], ['exclusive', 'This option disables other options', null, ['flag', 'nodesc', 'nocomp']], ['check', 'Specify file name conversions', ['choices', { 'relaxed': 'convert to lowercase before lookup', 'strict': 'no conversion' }]] ]] ``` ``` ~ > example --key-value-list flag,user= bin braph colord dbus dhcpcd git [...] ``` **SEE ALSO** - [list](#list): For completing comma-separated lists using a completer - [value\_list](#value_list): For completing comma-separated lists of values - [key\_value\_pair](#key_value_pair): For completing single key=value pairs - [key\_value\_list\_exec](#key_value_list_exec): For completing comma-separated lists of key=value pairs (dynamically generated by a function) --- ### key\_value\_pair > Complete single key=value pairs **SYNOPSIS** ```yaml ['key_value_pair', , ] ['key_value_pair', , , ] ``` **PARAMETERS** `VALUE_SEPARATOR`: The separator used to separate a key from its value. `DEFINITIONS`: A list of key definitions. Each definition has the following form: `[, , ]` `KEY`: The name of the key. Prefix the name with `*` to allow the key to be completed multiple times. `DESCRIPTION`: A description shown during completion. Use `null` to omit the description. `COMPLETER`: The completer used for the value of the key. Use `null` if the key does not take an argument. Use `['none']` if the key takes an argument but cannot be completed. `CONDITION_FUNCTION`: A command or function that determines whether a key should be offered for completion. It is invoked with the key as its first argument. If it exits with status `0`, the key is offered for completion. Any non-zero exit status suppresses the key. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--key-value-pair'] complete: ['key_value_pair', '=', [ ['flag', 'An option flag', null], ['nodesc', null, null], ['nocomp', 'An option with arg but without completer', ['none']], ['user', 'Takes a username', ['user']], ['check', 'Specify file name conversions', ['choices', { 'relaxed': 'convert to lowercase before lookup', 'strict': 'no conversion' }]] ]] ``` ``` ~ > example --key-value-pair check -- Specify file name conversions flag -- An option flag nocomp -- An option with arg but without completer user -- Takes a username nodesc ~ > example --key-value-pair user= bin braph colord dbus dhcpcd git [...] ``` **SEE ALSO** - [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs - [key\_value\_pair\_exec](#key_value_pair_exec): For completing single key=value pairs (dynamically generated by a function) --- ### list > Complete comma-separated lists using a completer **SYNOPSIS** ```yaml ['list', ] ['list', , ] ``` **PARAMETERS** `COMPLETER`: The completer used to generate the list elements. `OPTIONS`: A dictionary containing additional options for configuring the list completion. - `separator`: The separator used between list elements. Defaults to `,` - `duplicates`: Allow duplicate values to be offered for completion. Defaults to `false` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--user-list'] complete: ['list', ['user']] - option_strings: ['--option-list'] complete: ['list', ['choices', ['setuid', 'async', 'block']], {'separator': ':', 'duplicates': true}] ``` ``` ~ > example --user-list=avahi,daemon, bin braph colord dbus dhcpcd git [...] ~ > example --option-list=setuid: setuid async block ``` **SEE ALSO** - [value\_list](#value_list): For completing comma-separated lists of values - [file\_list](#file_list): For completing comma-separated lists of files - [directory\_list](#directory_list): For completing comma-separated lists of directories - [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs --- ### none > No completion, but specify that an argument is required **SYNOPSIS** ```yaml ['none'] ``` **PARAMETERS** Disables autocompletion for an option but still marks it as requiring an argument. Without specifying `complete`, the option would not take an argument. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--none'] complete: ['none'] ``` ``` ~ > example --none= ``` --- ### prefix > Prefix completions with a string **SYNOPSIS** ```yaml ['prefix', , ] ``` **PARAMETERS** `PREFIX`: The string to prepend to each completion candidate. `COMPLETER`: The completer used to generate the completion candidates. **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--prefix'] complete: ['prefix', 'input:', ['file']] ``` ``` ~ > example --prefix= ~ > example --prefix=input: ~ > example --prefix=input: ~ > example --prefix=input:file1.txt ``` --- ### exec > Complete values from the output of a command or function **SYNOPSIS** ```yaml ['exec', ] ``` **PARAMETERS** `COMMAND`: The command or function to execute. Its output must be formatted as tab-separated values: ``` \t \t [...] ``` Each line represents one completion candidate. The item and its description are separated by a tab character. **NOTES** - Functions can be put inside a file and included with `--include-file` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--exec'] complete: ['exec', "printf '%s\\t%s\\n' 'Item 1' 'Description 1' 'Item 2' 'Description 2'"] ``` ``` ~ > example --exec= Item 1 (Description 1) Item 2 (Description 2) ``` **SEE ALSO** - [exec\_fast](#exec_fast): Faster implementation of exec - [exec\_internal](#exec_internal): Use the shell's internal completion mechanisms --- ### exec\_fast > Complete values from the output of a command or function (fast and unsafe) **SYNOPSIS** ```yaml ['exec_fast', ] ``` **PARAMETERS** Faster version of `exec` for handling large amounts of data. Unlike `exec`, this implementation does not safely handle arbitrary output. Completion items must not contain whitespace or special shell characters. **NOTES** - Functions can be put inside a file and included with `--include-file` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--exec-fast'] complete: ['exec_fast', "printf '%s\\t%s\\n' 1 one 2 two"] ``` ``` ~ > example --exec-fast= 1 -- one 2 -- one ``` --- ### exec\_internal > Use the shell's internal completion mechanisms **SYNOPSIS** ```yaml ['exec_internal', ] ``` **PARAMETERS** Execute a function that internally modifies the completion state. This is useful if a more advanced completion is needed. For **Bash**, it might look like: ```sh my_completion_func() { COMPREPLY=( $(compgen -W 'read write append' -- '$cur') ) } ``` For **Zsh**, it might look like: ```sh my_completion_func() { local items=( read:'Read data from a file' write:'Write data from a file' append:'Append data to a file' ) _describe 'my items' items } ``` For **Fish**, it might look like: ```sh function my_completion_func printf '%s\t%s\n' \ read 'Read data from a file' \ write 'Write data from a file' \ append 'Append data to a file' end ``` **NOTES** - Functions can be put inside a file and included with `--include-file` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['--exec-internal'] complete: ['exec_internal', 'my_completion_func'] ``` ``` ~ > example --exec-internal= append -- Append data to a file read -- Read data from a file write -- Write data from a file ``` --- ### key\_value\_list\_exec > Complete dynamically generated comma-separted lists of key=value pairs **SYNOPSIS** ```yaml ['key_value_list_exec', , , ] ``` **PARAMETERS** `PAIR_SEPARATOR`: The separator used to separate individual key-value pairs. `VALUE_SEPARATOR`: The separator used to separate a key from its value. `COMMAND`: The command or function used to generate the available keys and values. If invoked without arguments, it must output the available keys in the following format: ``` [*][=][?]\t\t [*][=][?]\t\t [...] ``` Prefixing a key with `*` marks it as repeatable. Appending `=` to a key indicates that it requires a value. Appending `=?` to a key indicates that it requires an optional value. `EXCLUDES` is a space-separated list of keys that should no longer be offered once the current key has been used. If invoked with a single argument, the argument is the selected key. The command must output the possible values for that key in the following format: ``` \t \t [...] ``` Each line represents one completion candidate. The item and its description are separated by a tab character. Example function: ```sh _complete_key_value_list() { if (( $# == 0 )); then printf '%s\t%s\t%s\n' \ 'flag' 'option without an argument' '' \ 'argument=' 'option with an argument' '' \ 'optional=?' 'option with an optional argument' '' \ '*repeatable' 'a repeatable option' '' \ 'excludes' 'disable options' 'flag argument' else case '$1' in argument|optional) printf '%s\t%s\n' \ 'foo' 'a foo value' \ 'bar' 'a bar value';; esac fi } ``` **NOTES** - Functions can be put inside a file and included with `--include-file` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['-o'] complete: ['key_value_list_exec', ',', '=', '_complete_key_value_list'] ``` ``` ~ > example -o argument -- option with an argument excludes -- disable options flag -- option without an argument optional -- option with an optional argument repeatable -- a repeatable option ~ > example -o argument= foo -- a foo value bar -- a bar value ~ > example -o excludes, optional -- option with an optional argument repeatable -- a repeatable option ``` **SEE ALSO** - [key\_value\_list](#key_value_list): For completing comma-separated lists of key=value pairs --- ### key\_value\_pair\_exec > Complete dynamically generated a key=value pairs **SYNOPSIS** ```yaml ['key_value_pair_exec', , ] ``` **PARAMETERS** `VALUE_SEPARATOR`: The separator used to separate a key from its value. `COMMAND`: The command or function used to generate the available keys and values. If invoked without arguments, it must output the available keys in the following format: ``` [=]\t [=]\t [...] ``` Appending `=` to a key indicates that it requires a value. If invoked with a single argument, the argument is the selected key. The command must output the possible values for that key in the following format: ``` \t \t [...] ``` Each line represents one completion candidate. The item and its description are separated by a tab character. Example function: ```sh _complete_key_value_pair() { if (( $# == 0 )); then printf '%s\t%s\n' \ 'flag' 'a flag' \ 'option=' 'option with value' else case '$1' in option) printf '%s\t%s\n' \ 'foo' 'a foo value' \ 'bar' 'a bar value';; esac fi } ``` **NOTES** - Functions can be put inside a file and included with `--include-file` **EXAMPLE** ```yaml prog: 'example' options: - option_strings: ['-o'] complete: ['key_value_pair_exec', '=', '_complete_key_value_pair'] ``` ``` ~ > example -o flag -- a flag option -- option with value ~ > example -o option= foo -- a foo value bar -- a bar value ``` **SEE ALSO** - [key\_value\_pair](#key_value_pair): For completing single key=value pairs