COMPGEN(1)

NAME
compgen - command completion

SYNOPSIS
compgen [flags] [word...]

DESCRIPTION

Complete possible matches for word according to the flags, which may be an option accepted by complete with the exception of -p and -r, and write the matches to standard output. When using the -F or -C options, the shell variables set by the programmable completion facilities, while available, will not have useful values.

FLAGS

-A action
    action may be one of the following list of completions:

alias
    Equivalent to -a.

arrayvar
    Array variable names.

binding
    breadline` key binding names.

builtin
    Equivalent to -b.

command
    Equivalent to -c.

directory
    Equivalent to -d.

disabled
    Names of disabled shell builtins.

enabled
    Names of enabled shell builtins.

export
    Equivalent to -e.

file
    Equivalent to -f.

function
    Names of shell functions.

group
    Equivalent to -g.

helptopic
    Help topics as accepted by the help builtin.

hostname
    Hostnames, as taken from the file specified by the HOSTFILE shell variable.

job Equivalent to -j.

keyword
    Equivalent to -k.

running
    Names of running jobs if job control is active.

service
    Equivalent to -s.

setopt
    Valid option names as acceptered by the shopt builtin.

signal
    Signal names.

stopped
    Names of stopped jobs if job control is active.

user
    Equivalent to -u.

variable
    Equivalent to -v.

-o option
    option may be one of the following list of completions:

bashdefault
    perform bash default completions if there are no matches

default
    Use default filename completion of there are no matches.

dirnames
    Perform directory name completion if there are no matches.

filenames
    Match file names.

nospace
    No space will be appended to words completed at the end of the line.

-G globpat
    The filename expansion pattern globpat is expanded to generate the possible completions.

-W wordlist
    The wordlist is split using the characters in IFS as delimiters, and the resultant word is expanded. The possible completions are the members of the resultant list which match the word being completed.

-C command
    command is executed in a subshell environment, and its output is used as the possible completions.

-D  Use this completion as a default for commands that don't have a completion specified.

-E  Use this completion when for a blank line.

-F function
    The shell function function is executed in the current environment. When it finishes the possible list of completions are retrieved from the indexed array variable COMPREPLY.

-X pattern
    pattern is used to filter filename expansions. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching pattern is removed from the list. A leading ! in pattern negates the pattern.

-P prefix
    prefix is prepended to each possible completion after all other options have been applied.

-S suffix
    suffix is appended to each possible completion after all other options have been applied.

-a  Generate the list of alias names.

-b  Generate the list of builtins.

-c  Generate the list of command names.

-d  Generate the list of directory names.

-e  Generate the list of exported variable names.

-f  Generate the list of file names.

-g  Generate the list of group names.

-j  Generate the list of job names if job control is active.

-k  Generate the list of shell reserved words.

-s  Generate the list of service names.

-u  Generate the list of user names.

-v  Generate the list of variable names.

EXIT STATUS

0   No errors occurred.

>0  An error occurred.

SEE ALSO

complete(1), readonly(1), export(1)

AUTHOR
David J. Korn, et. al.

COPYRIGHT
2019, David J. Korn, et.al.