20. Completion Using compctl
20.1 Types of completion
This version of zsh has two ways of performing completion of words on the
command line. New users of the shell may prefer to use the newer
and more powerful system based on shell functions; this is described
in 19. Completion System, and the basic shell mechanisms which support
it are described in 18. Completion Widgets. This chapter describes
the older compctl command.
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Various editing commands, notably
expand-or-complete-word, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
delete-char-or-list, usually bound to ^D in EMACS editing
mode, list the possibilities; compctl controls what those
possibilities are. They may for example be filenames (the most common
case, and hence the default), shell variables, or words from a
user-specified list.
20.3 Command Flags
Completion of the arguments of a command may be different for each
command or may use the default. The behavior when completing the
command word itself may also be separately specified. These
correspond to the following flags and arguments, all of which (except
for -L) may be combined with any combination of the
options described subsequently in 20.4 Option Flags:
- command ...
- controls completion for the named commands, which must be listed last
on the command line. If completion is attempted for a command with a
pathname containing slashes and no completion definition is found, the
search is retried with the last pathname component. If the command starts
with a =, completion is tried with the pathname of the command.
Any of the command strings may be patterns of the form normally
used for filename generation. These should be be quoted to protect them
from immediate expansion; for example the command string 'foo*'
arranges for completion of the words of any command beginning with
foo. When completion is attempted, all pattern completions are
tried in the reverse order of their definition until one matches. By
default, completion then proceeds as normal, i.e. the shell will try to
generate more matches for the specific command on the command line; this
can be overridden by including -tn in the flags for the pattern
completion.
Note that aliases
are expanded before the command name is determined unless the
COMPLETE_ALIASES option is set. Commands may not be combined
with the -C, -D or -T flags.
- -C
- controls completion when the command word itself is being completed.
If no compctl -C command has been issued, the names of any
executable command (whether in the path or specific to the shell, such
as aliases or functions) are completed.
- -D
- controls default completion behavior for the arguments of commands not
assigned any special behavior. If no compctl -D command has
been issued, filenames are completed.
- -T
- supplies completion flags to be used before any other processing is
done, even before processing for compctls defined for specific
commands. This is especially useful when combined with extended
completion (the -x flag, see 20.6 Extended Completion below).
Using this flag you can define default behavior
which will apply to all commands without exception, or you can alter
the standard behavior for all commands. For example, if your access
to the user database is too slow and/or it contains too many users (so
that completion after `~' is too slow to be usable), you can use
| | compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
|
to complete the strings in the array friends after a `~'.
The C[...] argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
- -L
- lists the existing completion behavior in a manner suitable for
putting into a start-up script; the existing behavior is not changed.
Any combination of the above forms, or the -M flag (which must
follow the -L flag), may be specified, otherwise all defined
completions are listed. Any other flags supplied are ignored.
- no argument
- If no argument is given, compctl lists all defined completions
in an abbreviated form; with a list of options, all completions
with those flags set (not counting extended completion) are listed.
If the + flag is alone and followed immediately by the command
list, the completion behavior for all the commands in the list is reset to
the default. In other words, completion will subsequently use the
options specified by the -D flag.
The form TT>ftp#SEC139"> < ]
[ > ] |
| [ << ] |
[ Up ] |
[ >> ] |
| | | | [Top] |
[Contents] |
[Index] |
[ ? ] |
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Various editing commands, notably
expand-or-complete-word, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
delete-char-or-list, usually bound to ^D in EMACS editing
mode, list the possibilities; compctl controls what those
possibilities are. They may for example be filenames (the most common
case, and hence the default), shell variables, or words from a
user-specified list.
20.3 Command Flags
Completion of the arguments of a command may be different for each
command or may use the default. The behavior when completing the
command word itself may also be separately specified. These
correspond to the following flags and arguments, all of which (except
for -L) may be combined with any combination of the
options described subsequently in 20.4 Option Flags:
- command ...
- controls completion for the named commands, which must be listed last
on the command line. If completion is attempted for a command with a
pathname containing slashes and no completion definition is found, the
search is retried with the last pathname component. If the command starts
with a =, completion is tried with the pathname of the command.
Any of the command strings may be patterns of the form normally
used for filename generation. These should be be quoted to protect them
from immediate expansion; for example the command string 'foo*'
arranges for completion of the words of any command beginning with
foo. When completion is attempted, all pattern completions are
tried in the reverse order of their definition until one matches. By
default, completion then proceeds as normal, i.e. the shell will try to
generate more matches for the specific command on the command line; this
can be overridden by including -tn in the flags for the pattern
completion.
Note that aliases
are expanded before the command name is determined unless the
COMPLETE_ALIASES option is set. Commands may not be combined
with the -C, -D or -T flags.
- -C
- controls completion when the command word itself is being completed.
If no compctl -C command has been issued, the names of any
executable command (whether in the path or specific to the shell, such
as aliases or functions) are completed.
- -D
- controls default completion behavior for the arguments of commands not
assigned any special behavior. If no compctl -D command has
been issued, filenames are completed.
- -T
- supplies completion flags to be used before any other processing is
done, even before processing for compctls defined for specific
commands. This is especially useful when combined with extended
completion (the -x flag, see 20.6 Extended Completion below).
Using this flag you can define default behavior
which will apply to all commands without exception, or you can alter
the standard behavior for all commands. For example, if your access
to the user database is too slow and/or it contains too many users (so
that completion after `~' is too slow to be usable), you can use
| | compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
|
to complete the strings in the array friends after a `~'.
The C[...] argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
- -L
- lists the existing completion behavior in a manner suitable for
putting into a start-up script; the existing behavior is not changed.
Any combination of the above forms, or the -M flag (which must
follow the -L flag), may be specified, otherwise all defined
completions are listed. Any other flags supplied are ignored.
- no argument
- If no argument is given, compctl lists all defined completions
in an abbreviated form; with a list of options, all completions
with those flags set (not counting extended completion) are listed.
If the + flag is alone and followed immediately by the command
list, the completion behavior for all the commands in the list is reset to
the default. In other words, completion will subsequently use the
options specified by the -D flag.
The form TT>ftp#SEC139"> < ]
[ > ] |
| [ << ] |
[ Up ] |
[ >> ] |
| | | | [Top] |
[Contents] |
[Index] |
[ ? ] |
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Various editing commands, notably
expand-or-complete-word, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
delete-char-or-list, usually bound to ^D in EMACS editing
mode, list the possibilities; compctl controls what those
possibilities are. They may for example be filenames (the most common
case, and hence the default), shell variables, or words from a
user-specified list.
20.3 Command Flags
Completion of the arguments of a command may be different for each
command or may use the default. The behavior when completing the
command word itself may also be separately specified. These
correspond to the following flags and arguments, all of which (except
for -L) may be combined with any combination of the
options described subsequently in 20.4 Option Flags:
- command ...
- controls completion for the named commands, which must be listed last
on the command line. If completion is attempted for a command with a
pathname containing slashes and no completion definition is found, the
search is retried with the last pathname component. If the command starts
with a =, completion is tried with the pathname of the command.
Any of the command strings may be patterns of the form normally
used for filename generation. These should be be quoted to protect them
from immediate expansion; for example the command string 'foo*'
arranges for completion of the words of any command beginning with
foo. When completion is attempted, all pattern completions are
tried in the reverse order of their definition until one matches. By
default, completion then proceeds as normal, i.e. the shell will try to
generate more matches for the specific command on the command line; this
can be overridden by including -tn in the flags for the pattern
completion.
Note that aliases
are expanded before the command name is determined unless the
COMPLETE_ALIASES option is set. Commands may not be combined
with the -C, -D or -T flags.
- -C
- controls completion when the command word itself is being completed.
If no compctl -C command has been issued, the names of any
executable command (whether in the path or specific to the shell, such
as aliases or functions) are completed.
- -D
- controls default completion behavior for the arguments of commands not
assigned any special behavior. If no compctl -D command has
been issued, filenames are completed.
- -T
- supplies completion flags to be used before any other processing is
done, even before processing for compctls defined for specific
commands. This is especially useful when combined with extended
completion (the -x flag, see 20.6 Extended Completion below).
Using this flag you can define default behavior
which will apply to all commands without exception, or you can alter
the standard behavior for all commands. For example, if your access
to the user database is too slow and/or it contains too many users (so
that completion after `~' is too slow to be usable), you can use
| | compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
|
to complete the strings in the array friends after a `~'.
The C[...] argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
- -L
- lists the existing completion behavior in a manner suitable for
putting into a start-up script; the existing behavior is not changed.
Any combination of the above forms, or the -M flag (which must
follow the -L flag), may be specified, otherwise all defined
completions are listed. Any other flags supplied are ignored.
- no argument
- If no argument is given, compctl lists all defined completions
in an abbreviated form; with a list of options, all completions
with those flags set (not counting extended completion) are listed.
If the + flag is alone and followed immediately by the command
list, the completion behavior for all the commands in the list is reset to
the default. In other words, completion will subsequently use the
options specified by the -D flag.
The form TT>ftp#SEC139"> < ]
[ > ] |
| [ << ] |
[ Up ] |
[ >> ] |
| | | | [Top] |
[Contents] |
[Index] |
[ ? ] |
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Various editing commands, notably
expand-or-complete-word, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
delete-char-or-list, usually bound to ^D in EMACS editing
mode, list the possibilities; compctl controls what those
possibilities are. They may for example be filenames (the most common
case, and hence the default), shell variables, or words from a
user-specified list.
20.3 Command Flags
Completion of the arguments of a command may be different for each
command or may use the default. The behavior when completing the
command word itself may also be separately specified. These
correspond to the following flags and arguments, all of which (except
for -L) may be combined with any combination of the
options described subsequently in 20.4 Option Flags:
- command ...
- controls completion for the named commands, which must be listed last
on the command line. If completion is attempted for a command with a
pathname containing slashes and no completion definition is found, the
search is retried with the last pathname component. If the command starts
with a =, completion is tried with the pathname of the command.
Any of the command strings may be patterns of the form normally
used for filename generation. These should be be quoted to protect them
from immediate expansion; for example the command string 'foo*'
arranges for completion of the words of any command beginning with
foo. When completion is attempted, all pattern completions are
tried in the reverse order of their definition until one matches. By
default, completion then proceeds as normal, i.e. the shell will try to
generate more matches for the specific command on the command line; this
can be overridden by including -tn in the flags for the pattern
completion.
Note that aliases
are expanded before the command name is determined unless the
COMPLETE_ALIASES option is set. Commands may not be combined
with the -C, -D or -T flags.
- -C
- controls completion when the command word itself is being completed.
If no compctl -C command has been issued, the names of any
executable command (whether in the path or specific to the shell, such
as aliases or functions) are completed.
- -D
- controls default completion behavior for the arguments of commands not
assigned any special behavior. If no compctl -D command has
been issued, filenames are completed.
- -T
- supplies completion flags to be used before any other processing is
done, even before processing for compctls defined for specific
commands. This is especially useful when combined with extended
completion (the -x flag, see 20.6 Extended Completion below).
Using this flag you can define default behavior
which will apply to all commands without exception, or you can alter
the standard behavior for all commands. For example, if your access
to the user database is too slow and/or it contains too many users (so
that completion after `~' is too slow to be usable), you can use
| | compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
|
to complete the strings in the array friends after a `~'.
The C[...] argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
- -L
- lists the existing completion behavior in a manner suitable for
putting into a start-up script; the existing behavior is not changed.
Any combination of the above forms, or the -M flag (which must
follow the -L flag), may be specified, otherwise all defined
completions are listed. Any other flags supplied are ignored.
- no argument
- If no argument is given, compctl lists all defined completions
in an abbreviated form; with a list of options, all completions
with those flags set (not counting extended completion) are listed.
If the + flag is alone and followed immediately by the command
list, the completion behavior for all the commands in the list is reset to
the default. In other words, completion will subsequently use the
options specified by the -D flag.
The form TT>ftp#SEC139"> < ]
[ > ] |
| [ << ] |
[ Up ] |
[ >> ] |
| | | | [Top] |
[Contents] |
[Index] |
[ ? ] |
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Various editing commands, notably
expand-or-complete-word, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
delete-char-or-list, usually bound to ^D in EMACS editing
mode, list the possibilities; compctl controls what those
possibilities are. They may for example be filenames (the most common
case, and hence the default), shell variables, or words from a
user-specified list.
20.3 Command Flags
Completion of the arguments of a command may be different for each
command or may use the default. The behavior when completing the
command word itself may also be separately specified. These
correspond to the following flags and arguments, all of which (except
for -L) may be combined with any combination of the
options described subsequently in 20.4 Option Flags:
- command ...
- controls completion for the named commands, which must be listed last
on the command line. If completion is attempted for a command with a
pathname containing slashes and no completion definition is found, the
search is retried with the last pathname component. If the command starts
with a =, completion is tried with the pathname of the command.
Any of the command strings may be patterns of the form normally
used for filename generation. These should be be quoted to protect them
from immediate expansion; for example the command string 'foo*'
arranges for completion of the words of any command beginning with
foo. When completion is attempted, all pattern completions are
tried in the reverse order of their definition until one matches. By
default, completion then proceeds as normal, i.e. the shell will try to
generate more matches for the specific command on the command line; this
can be overridden by including -tn in the flags for the pattern
completion.
Note that aliases
are expanded before the command name is determined unless the
COMPLETE_ALIASES option is set. Commands may not be combined
with the -C, -D or -T flags.
- -C
- controls completion when the command word itself is being completed.
If no compctl -C command has been issued, the names of any
executable command (whether in the path or specific to the shell, such
as aliases or functions) are completed.
- -D
- controls default completion behavior for the arguments of commands not
assigned any special behavior. If no compctl -D command has
been issued, filenames are completed.
- -T
- supplies completion flags to be used before any other processing is
done, even before processing for compctls defined for specific
commands. This is especially useful when combined with extended
completion (the -x flag, see 20.6 Extended Completion below).
Using this flag you can define default behavior
which will apply to all commands without exception, or you can alter
the standard behavior for all commands. For example, if your access
to the user database is too slow and/or it contains too many users (so
that completion after `~' is too slow to be usable), you can use
| | compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
|
to complete the strings in the array friends after a `~'.
The C[...] argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
- -L
- lists the existing completion behavior in a manner suitable for
putting into a start-up script; the existing behavior is not changed.
Any combination of the above forms, or the -M flag (which must
follow the -L flag), may be specified, otherwise all defined
completions are listed. Any other flags supplied are ignored.
- no argument
- If no argument is given, compctl lists all defined completions
in an abbreviated form; with a list of options, all completions
with those flags set (not counting extended completion) are listed.
If the + flag is alone and followed immediately by the command
list, the completion behavior for all the commands in the list is reset to
the default. In other words, completion will subsequently use the
options specified by the -D flag.
The form TT>ftp#SEC139"> < ]
[ > ] |
| [ << ] |
[ Up ] |
[ >> ] |
| | | | [Top] |
[Contents] |
[Index] |
[ ? ] |
20.2 Description
- compctl [ -CDT ] options [ command ... ]
- compctl [ -CDT ] options [ -x pattern options - ... -- ] [ + options [ -x ... -- ] ... [+] ] [ command ... ]
- compctl -M match-specs ...
- compctl -L [ -CDTM ] [ command ... ]
- compctl + command ...
-
Control the editor's completion behavior according to the supplied set
of options. Va