{
    "content": [
        {
            "type": "text",
            "text": "# zshcompwid (man)\n\n## NAME\n\nzshcompwid - zsh completion widgets\n\n## DESCRIPTION\n\nThe  shell's  programmable  completion  mechanism  can  be  manipulated in two ways; here the\nlow-level features supporting the newer, function-based mechanism are  defined.   A  complete\nset  of shell functions based on these features is described in zshcompsys(1), and users with\nno interest in adding to that system (or, potentially, writing their own  --  see  dictionary\nentry  for  `hubris') should skip the current section.  The older system based on the compctl\nbuiltin command is described in zshcompctl(1).\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION**\n- **COMPLETION SPECIAL PARAMETERS** (1 subsections)\n- **COMPLETION BUILTIN COMMANDS** (1 subsections)\n- **COMPLETION CONDITION CODES** (4 subsections)\n- **COMPLETION MATCHING CONTROL**\n- **COMPLETION WIDGET EXAMPLE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "zshcompwid",
        "section": "",
        "mode": "man",
        "summary": "zshcompwid - zsh completion widgets",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "COMPLETION SPECIAL PARAMETERS",
                "lines": 52,
                "subsections": [
                    {
                        "name": "compstate",
                        "lines": 242
                    }
                ]
            },
            {
                "name": "COMPLETION BUILTIN COMMANDS",
                "lines": 256,
                "subsections": [
                    {
                        "name": "compset -q",
                        "lines": 82
                    }
                ]
            },
            {
                "name": "COMPLETION CONDITION CODES",
                "lines": 5,
                "subsections": [
                    {
                        "name": "-prefix",
                        "lines": 2
                    },
                    {
                        "name": "-suffix",
                        "lines": 2
                    },
                    {
                        "name": "-after",
                        "lines": 2
                    },
                    {
                        "name": "-between",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "COMPLETION MATCHING CONTROL",
                "lines": 203,
                "subsections": []
            },
            {
                "name": "COMPLETION WIDGET EXAMPLE",
                "lines": 18,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "zshcompwid - zsh completion widgets\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The  shell's  programmable  completion  mechanism  can  be  manipulated in two ways; here the\nlow-level features supporting the newer, function-based mechanism are  defined.   A  complete\nset  of shell functions based on these features is described in zshcompsys(1), and users with\nno interest in adding to that system (or, potentially, writing their own  --  see  dictionary\nentry  for  `hubris') should skip the current section.  The older system based on the compctl\nbuiltin command is described in zshcompctl(1).\n\nCompletion widgets are defined by the -C option to the zle builtin command  provided  by  the\nzsh/zle module (see zshzle(1)). For example,\n\nzle -C complete expand-or-complete completer\n\ndefines  a  widget  named  `complete'.  The second argument is the name of any of the builtin\nwidgets that handle completions: complete-word,  expand-or-complete,  expand-or-complete-pre‐‐\nfix,   menu-complete,   menu-expand-or-complete,   reverse-menu-complete,   list-choices,  or\ndelete-char-or-list.  Note that this will still work even if the widget in question has  been\nre-bound.\n\nWhen this newly defined widget is bound to a key using the bindkey builtin command defined in\nthe zsh/zle module (see zshzle(1)), typing that key will call the shell function `completer'.\nThis function is responsible for generating the possible matches using the builtins described\nbelow.  As with other ZLE widgets, the function is called with its standard input closed.\n\nOnce the function returns, the completion code  takes  over  control  again  and  treats  the\nmatches in the same manner as the specified builtin widget, in this case expand-or-complete.\n",
                "subsections": []
            },
            "COMPLETION SPECIAL PARAMETERS": {
                "content": "The  parameters ZLEREMOVESUFFIXCHARS and ZLESPACESUFFIXCHARS are used by the completion\nmechanism, but are not special. See Parameters Used By The Shell in zshparam(1).\n\nInside completion widgets, and any functions called from them, some parameters  have  special\nmeaning; outside these functions they are not special to the shell in any way.  These parame‐\nters are used to pass information between the completion code and the completion widget. Some\nof the builtin commands and the condition codes use or change the current values of these pa‐\nrameters.  Any existing values will be hidden during execution of completion widgets;  except\nfor  compstate,  the  parameters  are  reset on each function exit (including nested function\ncalls from within the completion widget) to the values they had when  the  function  was  en‐\ntered.\n\nCURRENT\nThis  is  the  number of the current word, i.e. the word the cursor is currently on in\nthe words array.  Note that this value is only correct if the ksharrays option is  not\nset.\n\nIPREFIX\nInitially this will be set to the empty string.  This parameter functions like PREFIX;\nit contains a string which precedes the one in PREFIX and is not  considered  part  of\nthe  list of matches.  Typically, a string is transferred from the beginning of PREFIX\nto the end of IPREFIX, for example:\n\nIPREFIX=${PREFIX%%\\=*}=\nPREFIX=${PREFIX#*=}\n\ncauses the part of the prefix up to and including the  first  equal  sign  not  to  be\ntreated  as  part  of a matched string.  This can be done automatically by the compset\nbuiltin, see below.\n\nISUFFIX\nAs IPREFIX, but for a suffix that should not be considered part of the  matches;  note\nthat the ISUFFIX string follows the SUFFIX string.\n\nPREFIX Initially  this  will be set to the part of the current word from the beginning of the\nword up to the position of the cursor; it may be altered to give a common  prefix  for\nall matches.\n\nQIPREFIX\nThis  parameter  is read-only and contains the quoted string up to the word being com‐\npleted. E.g. when completing `\"foo', this parameter contains the double quote. If  the\n-q  option of compset is used (see below), and the original string was `\"foo bar' with\nthe cursor on the `bar', this parameter contains `\"foo '.\n\nQISUFFIX\nLike QIPREFIX, but containing the suffix.\n\nSUFFIX Initially this will be set to the part of the current word from the cursor position to\nthe end; it may be altered to give a common suffix for all matches.  It is most useful\nwhen the option COMPLETEINWORD is set, as otherwise the whole word  on  the  command\nline is treated as a prefix.\n",
                "subsections": [
                    {
                        "name": "compstate",
                        "content": "This  is  an  associative  array with various keys and values that the completion code\nuses to exchange information with the completion widget.  The keys are:\n\nallquotes\nThe -q option of the compset builtin command (see below) allows a quoted string\nto  be broken into separate words; if the cursor is on one of those words, that\nword will be completed, possibly invoking `compset -q' recursively.  With  this\nkey it is possible to test the types of quoted strings which are currently bro‐\nken into parts in this fashion.  Its value  contains  one  character  for  each\nquoting level.  The characters are a single quote or a double quote for strings\nquoted with these characters, a dollars sign for strings quoted with $'...' and\na backslash for strings not starting with a quote character.  The first charac‐\nter in the value always corresponds to the innermost quoting level.\n\ncontext\nThis will be set by the completion code to the overall context in which comple‐\ntion is attempted. Possible values are:\n\narrayvalue\nwhen  completing  inside  the value of an array parameter assignment; in\nthis case the words array contains the words inside the parentheses.\n\nbraceparameter\nwhen completing the name of a parameter in a parameter expansion  begin‐\nning  with  ${.  This context will also be set when completing parameter\nflags following ${(; the full command line argument is presented and the\nhandler  must  test  the value to be completed to ascertain that this is\nthe case.\n\nassignparameter\nwhen completing the name of a parameter in a parameter assignment.\n\ncommand\nwhen completing for a normal command (either in command position or  for\nan argument of the command).\n\ncondition\nwhen  completing inside a `[[...]]' conditional expression; in this case\nthe words array contains only the words inside the  conditional  expres‐\nsion.\n\nmath   when  completing  in a mathematical environment such as a `((...))' con‐\nstruct.\n\nparameter\nwhen completing the name of a parameter in a parameter expansion  begin‐\nning with $ but not ${.\n\nredirect\nwhen completing after a redirection operator.\n\nsubscript\nwhen completing inside a parameter subscript.\n\nvalue  when completing the value of a parameter assignment.\n\nexact  Controls the behaviour when the RECEXACT option is set.  It will be set to ac‐‐\ncept if an exact match would be accepted, and will be unset otherwise.\n\nIf it was set when at least one match equal to the string on the line was  gen‐\nerated, the match is accepted.\n\nexactstring\nThe string of an exact match if one was found, otherwise unset.\n\nignored\nThe  number of words that were ignored because they matched one of the patterns\ngiven with the -F option to the compadd builtin command.\n\ninsert This controls the manner in which a match is inserted into  the  command  line.\nOn  entry  to the widget function, if it is unset the command line is not to be\nchanged; if set to unambiguous, any prefix common to all matches is to  be  in‐\nserted; if set to automenu-unambiguous, the common prefix is to be inserted and\nthe next invocation of the completion code may start menu  completion  (due  to\nthe  AUTOMENU  option  being  set); if set to menu or automenu menu completion\nwill be started for the matches currently generated (in the  latter  case  this\nwill  happen  because  the  AUTOMENU  is  set). The value may also contain the\nstring `tab' when the completion code would normally not really do  completion,\nbut only insert the TAB character.\n\nOn exit it may be set to any of the values above (where setting it to the empty\nstring is the same as unsetting it), or to a number, in which  case  the  match\nwhose number is given will be inserted into the command line.  Negative numbers\ncount backward from the last match (with `-1' selecting  the  last  match)  and\nout-of-range  values  are  wrapped  around, so that a value of zero selects the\nlast match and a value one more than the maximum selects the first. Unless  the\nvalue  of  this key ends in a space, the match is inserted as in a menu comple‐\ntion, i.e. without automatically appending a space.\n\nBoth menu and automenu may also specify the number  of  the  match  to  insert,\ngiven  after a colon.  For example, `menu:2' says to start menu completion, be‐\nginning with the second match.\n\nNote that a value containing the substring `tab' makes the matches generated be\nignored and only the TAB be inserted.\n\nFinally,  it  may  also be set to all, which makes all matches generated be in‐\nserted into the line.\n\ninsertpositions\nWhen the completion system inserts an unambiguous string into the  line,  there\nmay  be multiple places where characters are missing or where the character in‐\nserted differs from at least one match.  The value of this key contains a colon\nseparated list of all these positions, as indexes into the command line.\n\nlastprompt\nIf this is set to a non-empty string for every match added, the completion code\nwill move the cursor back to the previous prompt after the list of  completions\nhas  been  displayed.   Initially  this  is  set  or unset according to the AL‐‐\nWAYSLASTPROMPT option.\n\nlist   This controls whether or how the list of matches will be displayed.  If  it  is\nunset  or  empty they will never be listed; if its value begins with list, they\nwill always be listed; if it begins with autolist or ambiguous,  they  will  be\nlisted when the AUTOLIST or LISTAMBIGUOUS options respectively would normally\ncause them to be.\n\nIf the substring force appears in the value, this makes the list be shown  even\nif there is only one match. Normally, the list would be shown only if there are\nat least two matches.\n\nThe value contains the substring packed if the LISTPACKED option  is  set.  If\nthis  substring is given for all matches added to a group, this group will show\nthe LISTPACKED behavior. The same is done for the LISTROWSFIRST option  with\nthe substring rows.\n\nFinally,  if  the  value contains the string explanations, only the explanation\nstrings, if any, will be listed and if it contains messages, only the  messages\n(added  with the -x option of compadd) will be listed.  If it contains both ex‐‐\nplanations and messages both kinds of explanation strings will be  listed.   It\nwill  be  set  appropriately on entry to a completion widget and may be changed\nthere.\n\nlistlines\nThis gives the number of lines that are needed to display the full list of com‐\npletions.  Note that to calculate the total number of lines to display you need\nto add the number of lines needed for the command line to this value,  this  is\navailable as the value of the BUFFERLINES special parameter.\n\nlistmax\nInitially  this is set to the value of the LISTMAX parameter.  It may be set to\nany other value; when the widget exits this value will be used in the same  way\nas the value of LISTMAX.\n\nnmatches\nThe number of matches generated and accepted by the completion code so far.\n\noldinsert\nOn  entry  to  the widget this will be set to the number of the match of an old\nlist of completions that is currently inserted into the  command  line.  If  no\nmatch has been inserted, this is unset.\n\nAs  with  oldlist, the value of this key will only be used if it is the string\nkeep. If it was set to this value by the widget and there was an old match  in‐\nserted  into  the command line, this match will be kept and if the value of the\ninsert key specifies that another match should be inserted, this  will  be  in‐\nserted after the old one.\n\noldlist\nThis  is set to yes if there is still a valid list of completions from a previ‐\nous completion at the time the widget is invoked.  This  will  usually  be  the\ncase  if  and only if the previous editing operation was a completion widget or\none of the builtin completion functions.  If there is a valid list  and  it  is\nalso currently shown on the screen, the value of this key is shown.\n\nAfter the widget has exited the value of this key is only used if it was set to\nkeep.  In this case the completion code will continue to use this old list.  If\nthe widget generated new matches, they will not be used.\n\nparameter\nThe  name  of the parameter when completing in a subscript or in the value of a\nparameter assignment.\n\npatterninsert\nNormally this is set to menu, which specifies that menu completion will be used\nwhenever  a  set of matches was generated using pattern matching.  If it is set\nto any other non-empty string by the user and menu completion is  not  selected\nby  other  option  settings, the code will instead insert any common prefix for\nthe generated matches as with normal completion.\n\npatternmatch\nLocally controls the behaviour given by the GLOBCOMPLETE option.  Initially it\nis  set to `*' if and only if the option is set.  The completion widget may set\nit to this value, to an empty string (which has the same  effect  as  unsetting\nit),  or to any other non-empty string.  If it is non-empty, unquoted metachar‐\nacters on the command line will be treated as patterns; if it is `*', then  ad‐\nditionally  a wildcard `*' is assumed at the cursor position; if it is empty or\nunset, metacharacters will be treated literally.\n\nNote that the matcher specifications given to the compadd builtin  command  are\nnot used if this is set to a non-empty string.\n\nquote  When  completing inside quotes, this contains the quotation character (i.e. ei‐\nther a single quote, a double quote, or a backtick).  Otherwise it is unset.\n\nquoting\nWhen completing inside single quotes, this is set to the string single;  inside\ndouble  quotes, the string double; inside backticks, the string backtick.  Oth‐\nerwise it is unset.\n\nredirect\nThe redirection operator when completing in a redirection position, i.e. one of\n<, >, etc.\n\nrestore\nThis  is set to auto before a function is entered, which forces the special pa‐\nrameters mentioned above (words, CURRENT, PREFIX, IPREFIX, SUFFIX, and ISUFFIX)\nto  be  restored to their previous values when the function exits.   If a func‐\ntion unsets it or sets it to any other string, they will not be restored.\n\ntoend Specifies the occasions on which the cursor is moved to the  end  of  a  string\nwhen  a  match is inserted.  On entry to a widget function, it may be single if\nthis will happen when a single unambiguous match was inserted or  match  if  it\nwill happen any time a match is inserted (for example, by menu completion; this\nis likely to be the effect of the ALWAYSTOEND option).\n\nOn exit, it may be set to single as above.  It may also be set to always, or to\nthe  empty  string or unset; in those cases the cursor will be moved to the end\nof the string always or never respectively.  Any other  string  is  treated  as\nmatch.\n\nunambiguous\nThis key is read-only and will always be set to the common (unambiguous) prefix\nthe completion code has generated for all matches added so far.\n\nunambiguouscursor\nThis gives the position the cursor would be placed at if the common  prefix  in\nthe  unambiguous key were inserted, relative to the value of that key. The cur‐\nsor would be placed before the character whose index is given by this key.\n\nunambiguouspositions\nThis contains all positions where characters  in  the  unambiguous  string  are\nmissing  or  where  the  character  inserted  differs  from at least one of the\nmatches.  The positions are given as indexes into the string given by the value\nof the unambiguous key.\n\nvared  If completion is called while editing a line using the vared builtin, the value\nof this key is set to the name of the parameter given as an argument to  vared.\nThis key is only set while a vared command is active.\n\nwords  This array contains the words present on the command line currently being edited.\n"
                    }
                ]
            },
            "COMPLETION BUILTIN COMMANDS": {
                "content": "compadd [ -akqQfenUl12C ] [ -F array ]\n[-P prefix ] [ -S suffix ]\n[-p hidden-prefix ] [ -s hidden-suffix ]\n[-i ignored-prefix ] [ -I ignored-suffix ]\n[-W file-prefix ] [ -d array ]\n[-J group-name ] [ -X explanation ] [ -x message ]\n[-V group-name ] [ -o [ order ] ]\n[-r remove-chars ] [ -R remove-func ]\n[-D array ] [ -O array ] [ -A array ]\n[-E number ]\n[-M match-spec ] [ -- ] [ words ... ]\n\nThis  builtin command can be used to add matches directly and control all the informa‐\ntion the completion code stores with each possible match. The return status is zero if\nat least one match was added and non-zero if no matches were added.\n\nThe completion code breaks the string to complete into seven fields in the order:\n\n<ipre><apre><hpre><word><hsuf><asuf><isuf>\n\nThe  first field is an ignored prefix taken from the command line, the contents of the\nIPREFIX parameter plus the string given with the -i option. With the -U  option,  only\nthe  string  from the -i option is used. The field <apre> is an optional prefix string\ngiven with the -P option.  The <hpre> field is a string that is considered part of the\nmatch but that should not be shown when listing completions, given with the -p option;\nfor example, functions that do filename generation might specify a common path  prefix\nthis  way.   <word> is the part of the match that should appear in the list of comple‐\ntions, i.e. one of the words given at the end of the compadd command  line.  The  suf‐\nfixes  <hsuf>,  <asuf> and <isuf> correspond to the prefixes <hpre>, <apre> and <ipre>\nand are given by the options -s, -S and -I, respectively.\n\nThe supported flags are:\n\n-P prefix\nThis gives a string to be inserted before the given words.  The string given is\nnot considered as part of the match and any shell metacharacters in it will not\nbe quoted when the string is inserted.\n\n-S suffix\nLike -P, but gives a string to be inserted after the match.\n\n-p hidden-prefix\nThis gives a string that should be inserted into the command  line  before  the\nmatch  but  that should not appear in the list of matches. Unless the -U option\nis given, this string must be matched as part of  the  string  on  the  command\nline.\n\n-s hidden-suffix\nLike `-p', but gives a string to insert after the match.\n\n-i ignored-prefix\nThis  gives  a  string  to  insert into the command line just before any string\ngiven with the `-P' option.  Without `-P' the string  is  inserted  before  the\nstring given with `-p' or directly before the match.\n\n-I ignored-suffix\nLike -i, but gives an ignored suffix.\n\n-a     With  this flag the words are taken as names of arrays and the possible matches\nare their values.  If only some elements of the arrays are  needed,  the  words\nmay also contain subscripts, as in `foo[2,-1]'.\n\n-k     With  this flag the words are taken as names of associative arrays and the pos‐\nsible matches are their keys.  As for -a,  the  words  may  also  contain  sub‐\nscripts, as in `foo[(R)*bar*]'.\n\n-d array\nThis  adds  per-match display strings. The array should contain one element per\nword given. The completion code will then display the first element instead  of\nthe  first  word, and so on. The array may be given as the name of an array pa‐\nrameter or directly as a space-separated list of words in parentheses.\n\nIf there are fewer display strings than words, the leftover words will be  dis‐\nplayed unchanged and if there are more display strings than words, the leftover\ndisplay strings will be silently ignored.\n\n-l     This option only has an effect if used together with the -d option.  If  it  is\ngiven, the display strings are listed one per line, not arrayed in columns.\n\n-o [ order ]\nThis controls the order in which matches are sorted. order is a comma-separated\nlist comprising the following possible values.  These values can be abbreviated\nto  their  initial  two or three characters.  Note that the order forms part of\nthe group name space so matches with different orderings will  not  be  in  the\nsame group.\n\nmatch  If  given,  the  order of the output is determined by the match strings;\notherwise it is determined by the  display  strings  (i.e.  the  strings\ngiven  by  the  -d option). This is the default if `-o' is specified but\nthe order argument is omitted.\n\nnosort This specifies that the matches are pre-sorted and their order should be\npreserved.   This  value  only  makes sense alone and cannot be combined\nwith any others.\n\nnumeric\nIf the matches include numbers, sort them numerically rather than  lexi‐\ncographically.\n\nreverse\nArrange the matches backwards by reversing the sort ordering.\n\n-J group-name\nGives the name of the group of matches the words should be stored in.\n\n-V group-name\nLike  -J but naming an unsorted group. This option is identical to the combina‐\ntion of -J and -o nosort.\n\n-1     If given together with the -V option, makes only consecutive duplicates in  the\ngroup  be  removed. If combined with the -J option, this has no visible effect.\nNote that groups with and without this flag are in different name spaces.\n\n-2     If given together with the -J or -V  option,  makes  all  duplicates  be  kept.\nAgain, groups with and without this flag are in different name spaces.\n\n-X explanation\nThe  explanation  string  will  be  printed with the list of matches, above the\ngroup currently selected.\n\nWithin the explanation, the following sequences may be used to  specify  output\nattributes  as  described  in the section EXPANSION OF PROMPT SEQUENCES in zsh‐\nmisc(1): `%B', `%S', `%U', `%F', `%K' and their  lower  case  counterparts,  as\nwell as `%{...%}'.  `%F', `%K' and `%{...%}' take arguments in the same form as\nprompt expansion.  (Note that the sequence `%G' is not available;  an  argument\nto `%{' should be used instead.)  The sequence `%%' produces a literal `%'.\n\nThese  sequences  are  most often employed by users when customising the format\nstyle (see zshcompsys(1)), but they must also be taken into account when  writ‐\ning completion functions, as passing descriptions with unescaped `%' characters\nto utility functions such as arguments and message may produce unexpected re‐\nsults.  If  arbitrary  text is to be passed in a description, it can be escaped\nusing e.g. ${mystr//\\%/%%}.\n\n-x message\nLike -X, but the message will be printed even if there are no  matches  in  the\ngroup.\n\n-q     The  suffix  given  with -S will be automatically removed if the next character\ntyped is a blank or does not insert anything, or if the suffix consists of only\none character and the next character typed is the same character.\n\n-r remove-chars\nThis  is  a  more versatile form of the -q option.  The suffix given with -S or\nthe slash automatically added after completing directories  will  be  automati‐\ncally  removed  if the next character typed inserts one of the characters given\nin the remove-chars.  This string is parsed as a characters  class  and  under‐\nstands  the  backslash  sequences  used by the print command.  For example, `-r\n\"a-z\\t\"' removes the suffix if the next character typed inserts  a  lower  case\ncharacter  or  a  TAB, and `-r \"^0-9\"' removes the suffix if the next character\ntyped inserts anything but a digit. One extra backslash sequence is  understood\nin  this  string:  `\\-' stands for all characters that insert nothing. Thus `-S\n\"=\" -q' is the same as `-S \"=\" -r \"= \\t\\n\\-\"'.\n\nThis option may also be used without the  -S  option;  then  any  automatically\nadded space will be removed when one of the characters in the list is typed.\n\n-R remove-func\nThis  is another form of the -r option. When a suffix has been inserted and the\ncompletion accepted, the function remove-func will be  called  after  the  next\ncharacter  typed.  It is passed the length of the suffix as an argument and can\nuse the special parameters available in ordinary (non-completion)  zle  widgets\n(see zshzle(1)) to analyse and modify the command line.\n\n-f     If  this flag is given, all of the matches built from words are marked as being\nthe names of files.  They are not required to be actual filenames, but if  they\nare,  and  the option LISTTYPES is set, the characters describing the types of\nthe files in the completion lists will be shown. This also forces a slash to be\nadded when the name of a directory is completed.\n\n-e     This  flag  can  be used to tell the completion code that the matches added are\nparameter names for a parameter expansion. This will make the  AUTOPARAMSLASH\nand AUTOPARAMKEYS options be used for the matches.\n\n-W file-prefix\nThis  string is a pathname that will be prepended to each of the matches formed\nby the given words together with any prefix specified by the -p option to  form\na  complete filename for testing.  Hence it is only useful if combined with the\n-f flag, as the tests will not otherwise be performed.\n\n-F array\nSpecifies an array containing patterns. Words matching one  of  these  patterns\nare ignored, i.e. not considered to be possible matches.\n\nThe  array  may be the name of an array parameter or a list of literal patterns\nenclosed in parentheses and quoted, as in `-F \"(*?.o *?.h)\"'. If the name of an\narray is given, the elements of the array are taken as the patterns.\n\n-Q     This  flag instructs the completion code not to quote any metacharacters in the\nwords when inserting them into the command line.\n\n-M match-spec\nThis gives local match specifications as described below in the  section  `Com‐\npletion  Matching  Control'.  This option may be given more than once.  In this\ncase all match-specs given are concatenated with spaces between  them  to  form\nthe  specification  string  to use.  Note that they will only be used if the -U\noption is not given.\n\n-n     Specifies that the words added are to be used as possible matches, but are  not\nto appear in the completion listing.\n\n-U     If this flag is given, all words given will be accepted and no matching will be\ndone by the completion code. Normally this is used in  functions  that  do  the\nmatching themselves.\n\n-O array\nIf this option is given, the words are not added to the set of possible comple‐\ntions.  Instead, matching is done as usual and all of the words given as  argu‐\nments that match the string on the command line will be stored in the array pa‐\nrameter whose name is given as array.\n\n-A array\nAs the -O option, except that instead of those of the words which  match  being\nstored  in  array,  the strings generated internally by the completion code are\nstored. For example, with a matching specification of `-M \"L:|no=\"', the string\n`nof' on the command line and the string `foo' as one of the words, this option\nstores the string `nofoo' in the array, whereas the -O option stores the  `foo'\noriginally given.\n\n-D array\nAs  with  -O,  the words are not added to the set of possible completions.  In‐\nstead, the completion code tests whether each word in turn matches what  is  on\nthe  line.  If the nth word does not match, the nth element of the array is re‐\nmoved.  Elements for which the corresponding word is matched are retained.\n\n-C     This option adds a special match which expands to all other  matches  when  in‐\nserted into the line, even those that are added after this option is used.  To‐\ngether with the -d option it is possible to specify a  string  that  should  be\ndisplayed  in  the list for this special match.  If no string is given, it will\nbe shown as a string containing the strings that  would  be  inserted  for  the\nother matches, truncated to the width of the screen.\n\n-E number\nThis  option  adds  number  empty  matches after the words have been added.  An\nempty match takes up space in completion listings but will never be inserted in\nthe  line  and  can't be selected with menu completion or menu selection.  This\nmakes empty matches only useful to format completion lists and to make explana‐\ntory string be shown in completion lists (since empty matches can be given dis‐\nplay strings with the -d option).  And because all but one empty  string  would\notherwise be removed, this option implies the -V and -2 options (even if an ex‐\nplicit -J option is given).  This can be important to note as  it  affects  the\nname space into which matches are added.\n\n-\n--     This  flag  ends  the list of flags and options. All arguments after it will be\ntaken as the words to use as matches even if they begin with hyphens.\n\nExcept for the -M flag, if any of these flags is given more than once, the  first  one\n(and its argument) will be used.\n\ncompset -p number\ncompset -P [ number ] pattern\ncompset -s number\ncompset -S [ number ] pattern\ncompset -n begin [ end ]\ncompset -N beg-pat [ end-pat ]",
                "subsections": [
                    {
                        "name": "compset -q",
                        "content": "This  command simplifies modification of the special parameters, while its return sta‐\ntus allows tests on them to be carried out.\n\nThe options are:\n\n-p number\nIf the value of the PREFIX parameter is at least number  characters  long,  the\nfirst number characters are removed from it and appended to the contents of the\nIPREFIX parameter.\n\n-P [ number ] pattern\nIf the value of the PREFIX parameter begins with anything that matches the pat‐\ntern, the matched portion is removed from PREFIX and appended to IPREFIX.\n\nWithout  the  optional  number,  the  longest  match is taken, but if number is\ngiven, anything up to the numberth match is moved.  If the number is  negative,\nthe numberth longest match is moved. For example, if PREFIX contains the string\n`a=b=c', then compset -P '*\\=' will move the string `a=b=' into the IPREFIX pa‐\nrameter, but compset -P 1 '*\\=' will move only the string `a='.\n\n-s number\nAs  -p, but transfer the last number characters from the value of SUFFIX to the\nfront of the value of ISUFFIX.\n\n-S [ number ] pattern\nAs -P, but match the last portion of SUFFIX and transfer the matched portion to\nthe front of the value of ISUFFIX.\n\n-n begin [ end ]\nIf  the  current word position as specified by the parameter CURRENT is greater\nthan or equal to begin, anything up to the beginth word  is  removed  from  the\nwords array and the value of the parameter CURRENT is decremented by begin.\n\nIf the optional end is given, the modification is done only if the current word\nposition is also less than or equal to end. In this case, the words from  posi‐\ntion end onwards are also removed from the words array.\n\nBoth  begin and end may be negative to count backwards from the last element of\nthe words array.\n\n-N beg-pat [ end-pat ]\nIf one of the elements of the words array before the one at the index given  by\nthe value of the parameter CURRENT matches the pattern beg-pat, all elements up\nto and including the matching one are removed from  the  words  array  and  the\nvalue of CURRENT is changed to point to the same word in the changed array.\n\nIf  the  optional pattern end-pat is also given, and there is an element in the\nwords array matching this pattern, the parameters are modified only if the  in‐\ndex of this word is higher than the one given by the CURRENT parameter (so that\nthe matching word has to be after the cursor). In this case, the words starting\nwith  the  one matching end-pat are also removed from the words array. If words\ncontains no word matching end-pat, the testing and modification is performed as\nif it were not given.\n\n-q     The  word currently being completed is split on spaces into separate words, re‐\nspecting the usual shell quoting conventions.  The resulting words  are  stored\nin  the  words  array,  and CURRENT, PREFIX, SUFFIX, QIPREFIX, and QISUFFIX are\nmodified to reflect the word part that is completed.\n\nIn all the above cases the return status is zero if the test succeeded and the parame‐\nters  were  modified  and  non-zero  otherwise. This allows one to use this builtin in\ntests such as:\n\nif compset -P '*\\='; then ...\n\nThis forces anything up to and including the last equal sign to be ignored by the com‐\npletion code.\n\ncompcall [ -TD ]\nThis  allows  the use of completions defined with the compctl builtin from within com‐\npletion widgets.  The list of matches will be generated as if one  of  the  non-widget\ncompletion functions (complete-word, etc.)  had been called, except that only compctls\ngiven for specific commands are used. To force the code  to  try  completions  defined\nwith  the  -T option of compctl and/or the default completion (whether defined by com‐‐\npctl -D or the builtin default) in the appropriate places, the -T and/or -D flags  can\nbe passed to compcall.\n\nThe  return  status can be used to test if a matching compctl definition was found. It\nis non-zero if a compctl was found and zero otherwise.\n\nNote that this builtin is defined by the zsh/compctl module.\n"
                    }
                ]
            },
            "COMPLETION CONDITION CODES": {
                "content": "The following additional condition codes for use within the [[ ... ]] construct are available\nin completion widgets.  These work on the special parameters.  All of these tests can also be\nperformed by the compset builtin, but in the case of the condition codes the contents of  the\nspecial parameters are not modified.\n",
                "subsections": [
                    {
                        "name": "-prefix",
                        "content": "true if the test for the -P option of compset would succeed.\n"
                    },
                    {
                        "name": "-suffix",
                        "content": "true if the test for the -S option of compset would succeed.\n"
                    },
                    {
                        "name": "-after",
                        "content": "true if the test of the -N option with only the beg-pat given would succeed.\n"
                    },
                    {
                        "name": "-between",
                        "content": "true if the test for the -N option with both patterns would succeed.\n"
                    }
                ]
            },
            "COMPLETION MATCHING CONTROL": {
                "content": "It  is  possible  by  use  of the -M option of the compadd builtin command to specify how the\ncharacters in the string to be completed (referred to here as the command line) map onto  the\ncharacters  in  the  list of matches produced by the completion code (referred to here as the\ntrial completions). Note that this is not used if the command line contains  a  glob  pattern\nand the GLOBCOMPLETE option is set or the patternmatch of the compstate special association\nis set to a non-empty string.\n\nThe match-spec given as the argument to the -M  option  (see  `Completion  Builtin  Commands'\nabove)  consists of one or more matching descriptions separated by whitespace.  Each descrip‐\ntion consists of a letter followed by a colon and then the patterns describing which  charac‐\nter  sequences  on the line match which character sequences in the trial completion.  Any se‐\nquence of characters not handled in this fashion must match exactly, as usual.\n\nThe forms of match-spec understood are as follows. In each case, the form with an upper  case\ninitial character retains the string already typed on the command line as the final result of\ncompletion, while with a lower case initial character the  string  on  the  command  line  is\nchanged into the corresponding part of the trial completion.\n\nm:lpat=tpat\nM:lpat=tpat\nHere,  lpat is a pattern that matches on the command line, corresponding to tpat which\nmatches in the trial completion.\n\nl:lanchor|lpat=tpat\nL:lanchor|lpat=tpat\nl:lanchor||ranchor=tpat\nL:lanchor||ranchor=tpat\nb:lpat=tpat\nB:lpat=tpat\nThese letters are for patterns that are anchored by another pattern on the left  side.\nMatching for lpat and tpat is as for m and M, but the pattern lpat matched on the com‐\nmand line must be preceded by the pattern lanchor.  The lanchor can be blank to anchor\nthe match to the start of the command line string; otherwise the anchor can occur any‐\nwhere, but must match in both the command line and trial completion strings.\n\nIf no lpat is given but a ranchor is, this matches the gap between substrings  matched\nby lanchor and ranchor. Unlike lanchor, the ranchor only needs to match the trial com‐\npletion string.\n\nThe b and B forms are similar to l and L with an empty anchor, but need to match  only\nthe beginning of the word on the command line or trial completion, respectively.\n\nr:lpat|ranchor=tpat\nR:lpat|ranchor=tpat\nr:lanchor||ranchor=tpat\nR:lanchor||ranchor=tpat\ne:lpat=tpat\nE:lpat=tpat\nAs  l, L, b and B, with the difference that the command line and trial completion pat‐\nterns are anchored on the right side.  Here an empty ranchor and the  e  and  E  forms\nforce the match to the end of the command line or trial completion string.\n\nx:     This  form  is  used to mark the end of matching specifications: subsequent specifica‐\ntions are ignored. In a single standalone list of specifications this has no  use  but\nwhere  matching specifications are accumulated, such as from nested function calls, it\ncan allow one function to override another.\n\nEach lpat, tpat or anchor is either an empty string or consists  of  a  sequence  of  literal\ncharacters  (which  may  be  quoted with a backslash), question marks, character classes, and\ncorrespondence classes; ordinary shell patterns are not used.  Literal characters match  only\nthemselves, question marks match any character, and character classes are formed as for glob‐\nbing and match any character in the given set.\n\nCorrespondence classes are defined like character classes, but with two differences: they are\ndelimited by a pair of braces, and negated classes are not allowed, so the characters ! and ^\nhave no special meaning directly after the opening brace.  They  indicate  that  a  range  of\ncharacters on the line match a range of characters in the trial completion, but (unlike ordi‐\nnary character classes) paired according to the corresponding position in the sequence.   For\nexample,  to  make any ASCII lower case letter on the line match the corresponding upper case\nletter in the trial completion, you can use `m:{a-z}={A-Z}' (however, see below for the  rec‐\nommended  form  for  this).  More than one pair of classes can occur, in which case the first\nclass before the = corresponds to the first after it, and so on.  If one side has  more  such\nclasses  than  the  other side, the superfluous classes behave like normal character classes.\nIn anchor patterns correspondence classes also behave like normal character classes.\n\nThe standard `[:name:]' forms described for standard shell patterns (see the section FILENAME\nGENERATION  in  zshexpn(1))  may appear in correspondence classes as well as normal character\nclasses.  The only special behaviour in correspondence classes is if the form on the left and\nthe  form on the right are each one of [:upper:], [:lower:].  In these cases the character in\nthe word and the character on the line must be the same up to a difference in case.  Hence to\nmake any lower case character on the line match the corresponding upper case character in the\ntrial completion you can use `m:{[:lower:]}={[:upper:]}'.  Although the matching system  does\nnot  yet handle multibyte characters, this is likely to be a future extension, at which point\nthis syntax will handle arbitrary alphabets; hence this form, rather than the use of explicit\nranges,  is  the  recommended form.  In other cases `[:name:]' forms are allowed.  If the two\nforms on the left and right are the same, the characters must match  exactly.   In  remaining\ncases,  the  corresponding  tests  are applied to both characters, but they are not otherwise\nconstrained; any matching character in one set goes with any matching character in the  other\nset:  this is equivalent to the behaviour of ordinary character classes.\n\nThe  pattern  tpat  may also be one or two stars, `*' or `'. This means that the pattern on\nthe command line can match any number of characters in the trial completion. In this case the\npattern  must be anchored (on either side); in the case of a single star, the anchor then de‐\ntermines how much of the trial completion is to be included -- only the characters up to  the\nnext  appearance of the anchor will be matched. With two stars, substrings matched by the an‐\nchor can be matched, too.\n\nExamples:\n\nThe keys of the options association defined by the parameter module are the option  names  in\nall-lower-case  form,  without underscores, and without the optional no at the beginning even\nthough the builtins setopt and unsetopt understand option names with upper case letters,  un‐\nderscores,  and  the optional no.  The following alters the matching rules so that the prefix\nno and any underscore are ignored when trying to match the trial  completions  generated  and\nupper case letters on the line match the corresponding lower case letters in the words:\n\ncompadd -M 'L:|[nN][oO]= M:= M:{[:upper:]}={[:lower:]}' - \\\n${(k)options}\n\nThe first part says that the pattern `[nN][oO]' at the beginning (the empty anchor before the\npipe symbol) of the string on the line matches the empty string in the list of  words  gener‐\nated  by  completion,  so it will be ignored if present. The second part does the same for an\nunderscore anywhere in the command line  string,  and  the  third  part  uses  correspondence\nclasses so that any upper case letter on the line matches the corresponding lower case letter\nin the word. The use of the upper case forms of the specification characters (L and M)  guar‐\nantees  that  what  has  already been typed on the command line (in particular the prefix no)\nwill not be deleted.\n\nNote that the use of L in the first part means that it matches only when at the beginning  of\nboth  the command line string and the trial completion. I.e., the string `NOf' would not be\ncompleted to `NOfoo', nor would `NONOf' be completed to `NONOfoo' because of the  leading\nunderscore  or  the second `NO' on the line which makes the pattern fail even though they are\notherwise ignored. To fix this, one would use `B:[nN][oO]=' instead of the first part. As de‐\nscribed  above,  this  matches at the beginning of the trial completion, independent of other\ncharacters or substrings at the beginning of the command line word which are ignored  by  the\nsame or other match-specs.\n\nThe second example makes completion case insensitive.  This is just the same as in the option\nexample, except here we wish to retain the characters in the list of completions:\n\ncompadd -M 'm:{[:lower:]}={[:upper:]}' ...\n\nThis makes lower case letters match their upper case counterparts.  To make upper  case  let‐\nters match the lower case forms as well:\n\ncompadd -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' ...\n\nA nice example for the use of * patterns is partial word completion. Sometimes you would like\nto make strings like `c.s.u' complete to strings like `comp.source.unix', i.e.  the  word  on\nthe  command  line consists of multiple parts, separated by a dot in this example, where each\npart should be completed separately -- note, however, that the case where each  part  of  the\nword, i.e. `comp', `source' and `unix' in this example, is to be completed from separate sets\nof matches is a different problem to be solved by the implementation of the  completion  wid‐\nget.  The example can be handled by:\n\ncompadd -M 'r:|.=* r:|=*' \\\n- comp.sources.unix comp.sources.misc ...\n\nThe first specification says that lpat is the empty string, while anchor is a dot; tpat is *,\nso this can match anything except for the `.' from the anchor in the trial  completion  word.\nSo  in  `c.s.u',  the  matcher sees `c', followed by the empty string, followed by the anchor\n`.', and likewise for the second dot, and replaces the empty strings before the anchors, giv‐\ning `c[omp].s[ources].u[nix]', where the last part of the completion is just as normal.\n\nWith  the pattern shown above, the string `c.u' could not be completed to `comp.sources.unix'\nbecause the single star means that no dot (matched by the anchor) can be  skipped.  By  using\ntwo  stars  as  in  `r:|.=', however, `c.u' could be completed to `comp.sources.unix'. This\nalso shows that in some cases, especially if the anchor is a real pattern, like  a  character\nclass, the form with two stars may result in more matches than one would like.\n\nThe  second specification is needed to make this work when the cursor is in the middle of the\nstring on the command line and the option COMPLETEINWORD is set. In this case  the  comple‐\ntion  code would normally try to match trial completions that end with the string as typed so\nfar, i.e. it will only insert new characters at the cursor position rather than at  the  end.\nHowever  in our example we would like the code to recognise matches which contain extra char‐\nacters after the string on the line (the `nix' in the example).  Hence we say that the  empty\nstring  at  the  end of the string on the line matches any characters at the end of the trial\ncompletion.\n\nMore generally, the specification\n\ncompadd -M 'r:|[.,-]=* r:|=*' ...\n\nallows one to complete words with abbreviations before any of the characters  in  the  square\nbrackets.   For example, to complete veryverylongfile.c rather than veryverylongheader.h with\nthe above in effect, you can just type very.c before attempting completion.\n\nThe specifications with both a left and a right anchor are useful to complete  partial  words\nwhose  parts are not separated by some special character. For example, in some places strings\nhave to be completed that are formed `LikeThis' (i.e. the separate parts are determined by  a\nleading  upper  case letter) or maybe one has to complete strings with trailing numbers. Here\none could use the simple form with only one anchor as in:\n\ncompadd -M 'r:|[[:upper:]0-9]=* r:|=*' LikeTHIS FooHoo 5foo123 5bar234\n\nBut with this, the string `H' would neither complete to `FooHoo' nor to `LikeTHIS' because in\neach  case  there  is  an upper case letter before the `H' and that is matched by the anchor.\nLikewise, a `2' would not be completed.  In  both  cases  this  could  be  changed  by  using\n`r:|[[:upper:]0-9]=',  but  then  `H'  completes  to both `LikeTHIS' and `FooHoo' and a `2'\nmatches the other strings because characters can be inserted before every upper  case  letter\nand digit. To avoid this one would use:\n\ncompadd -M 'r:[^[:upper:]0-9]||[[:upper:]0-9]= r:|=*' \\\nLikeTHIS FooHoo foo123 bar234\n\nBy  using these two anchors, a `H' matches only upper case `H's that are immediately preceded\nby something matching the left anchor `[^[:upper:]0-9]'. The effect is, of course,  that  `H'\nmatches only the string `FooHoo', a `2' matches only `bar234' and so on.\n\nWhen  using  the completion system (see zshcompsys(1)), users can define match specifications\nthat are to be used for specific contexts by using the matcher and matcher-list  styles.  The\nvalues for the latter will be used everywhere.\n",
                "subsections": []
            },
            "COMPLETION WIDGET EXAMPLE": {
                "content": "The first step is to define the widget:\n\nzle -C complete complete-word complete-files\n\nThen the widget can be bound to a key using the bindkey builtin command:\n\nbindkey '^X\\t' complete\n\nAfter  that the shell function complete-files will be invoked after typing control-X and TAB.\nThe function should then generate the matches, e.g.:\n\ncomplete-files () { compadd - * }\n\nThis function will complete files in the current directory matching the current word.\n\n\n\nzsh 5.8.1                                 February 12, 2022                            ZSHCOMPWID(1)",
                "subsections": []
            }
        }
    }
}