This file is indexed.

/usr/share/doc/zsh-common/html/Completion-Using-compctl.html is in zsh-doc 5.0.2-3ubuntu6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on December 21, 2012 by texi2html 1.82
texi2html was written by: 
            Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>zsh: 21. Completion Using compctl</title>

<meta name="description" content="zsh: 21. Completion Using compctl">
<meta name="keywords" content="zsh: 21. Completion Using compctl">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Completion-Using-compctl"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Completion-System.html#Completion-Directories" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Types-of-completion" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Completion-System.html#Completion-System" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Completion-Using-compctl-1"></a>
<h1 class="chapter">21. Completion Using compctl</h1>
<a name="index-completion_002c-programmable-2"></a>
<a name="index-completion_002c-controlling-2"></a>

<hr size="6">
<a name="Types-of-completion"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Description-5" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section">21.1 Types of completion</h2>
<p>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 <a href="Completion-System.html#Completion-System">Completion System</a>, and the basic shell mechanisms which support
it are described in <a href="Completion-Widgets.html#Completion-Widgets">Completion Widgets</a>.  This chapter describes
the older <tt>compctl</tt> command.
</p>
<hr size="6">
<a name="Description-5"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Types-of-completion" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Command-Flags" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section">21.2 Description</h2>
<a name="index-compctl"></a>
<dl compact="compact">
<dt> <tt>compctl</tt> [ <tt>-CDT</tt> ] <var>options</var> [ <var>command</var> ... ]</dt>
<dt> <tt>compctl</tt> [ <tt>-CDT</tt> ] <var>options</var> [ <tt>-x</tt> <var>pattern</var> <var>options</var> <tt>-</tt> ... <tt>-</tt><tt>-</tt> ] [ <tt>+</tt> <var>options</var> [ <tt>-x</tt> ... <tt>-</tt><tt>-</tt> ] ... [<tt>+</tt>] ] [ <var>command</var> ... ]</dt>
<dt> <tt>compctl</tt> <tt>-M</tt> <var>match-specs</var> ...</dt>
<dt> <tt>compctl</tt> <tt>-L</tt> [ <tt>-CDTM</tt> ] [ <var>command</var> ... ]</dt>
<dt> <tt>compctl</tt> <tt>+</tt> <var>command</var> ...</dt>
<dt></dt>
</dl>

<p>Control the editor&rsquo;s completion behavior according to the supplied set
of <var>options</var>.  Various editing commands, notably
<tt>expand-or-complete-word</tt>, usually bound to tab, will
attempt to complete a word typed by the user, while others, notably
<tt>delete-char-or-list</tt>, usually bound to ^D in EMACS editing
mode, list the possibilities; <tt>compctl</tt> 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.
</p><table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Command-Flags">21.3 Command Flags</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Option-Flags">21.4 Option Flags</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Alternative-Completion">21.5 Alternative Completion</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Extended-Completion">21.6 Extended Completion</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Example">21.7 Example</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr size="6">
<a name="Command-Flags"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Description-5" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Option-Flags" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Command-Flags-1"></a>
<h2 class="section">21.3 Command Flags</h2>
<p>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 <tt>-L</tt>) may be combined with any combination of the
<var>options</var> described subsequently in <a href="#Option-Flags">Option Flags</a>:
</p>
<dl compact="compact">
<dt> <var>command</var> ...</dt>
<dd><p>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 <tt>=</tt>, completion is tried with the pathname of the command.
</p>
<p>Any of the <var>command</var> strings may be patterns of the form normally
used for filename generation.  These should be quoted to protect them
from immediate expansion; for example the command string <tt>&rsquo;foo*&rsquo;</tt>
arranges for completion of the words of any command beginning with
<tt>foo</tt>.  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 <tt>-tn</tt> in the flags for the pattern
completion.
</p>
<p>Note that aliases
are expanded before the command name is determined unless the
<tt>COMPLETE_ALIASES</tt> option is set.  Commands may not be combined
with the <tt>-C</tt>, <tt>-D</tt> or <tt>-T</tt> flags.
</p>
</dd>
<dt> <tt>-C</tt></dt>
<dd><p>controls completion when the command word itself is being completed.
If no <tt>compctl -C</tt> 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.
</p>
</dd>
<dt> <tt>-D</tt></dt>
<dd><p>controls default completion behavior for the arguments of commands not
assigned any special behavior.  If no <tt>compctl -D</tt> command has
been issued, filenames are completed.
</p>
</dd>
<dt> <tt>-T</tt></dt>
<dd><p>supplies completion flags to be used before any other processing is
done, even before processing for <tt>compctl</tt>s defined for specific
commands.  This is especially useful when combined with extended
completion (the <tt>-x</tt> flag, see <a href="#Extended-Completion">Extended Completion</a> 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 &lsquo;<tt>~</tt>&rsquo; is too slow to be usable), you can use
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
</pre></td></tr></table>

<p>to complete the strings in the array <tt>friends</tt> after a &lsquo;<tt>~</tt>&rsquo;.
The <tt>C[...]</tt> argument is necessary so that this form of ~-completion is
not tried after the directory name is finished.
</p>
</dd>
<dt> <tt>-L</tt></dt>
<dd><p>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 <tt>-M</tt> flag (which must
follow the <tt>-L</tt> flag), may be specified, otherwise all defined
completions are listed.  Any other flags supplied are ignored.
</p>
</dd>
<dt> <em>no argument</em></dt>
<dd><p>If no argument is given, <tt>compctl</tt> lists all defined completions
in an abbreviated form;  with a list of <var>options</var>, all completions
with those flags set (not counting extended completion) are listed.
</p>
</dd>
</dl>

<p>If the <tt>+</tt> flag is alone and followed immediately by the <var>command</var>
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 <tt>-D</tt> flag.
</p>
<p>The form with <tt>-M</tt> as the first and only option defines global
matching specifications (see
<a href="Completion-Widgets.html#Completion-Matching-Control">Completion Matching Control</a>). The match specifications given will be used for every completion
attempt (only when using <tt>compctl</tt>, not with the new completion
system) and are tried in the order in which they are defined until one 
generates at least one match. E.g.:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -M '' 'm:{a-zA-Z}={A-Za-z}'
</pre></td></tr></table>

<p>This will first try completion without any global match specifications 
(the empty string) and, if that generates no matches, will try case
insensitive completion.
</p>
<hr size="6">
<a name="Option-Flags"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Command-Flags" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Simple-Flags" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Option-Flags-1"></a>
<h2 class="section">21.4 Option Flags</h2>
<dl compact="compact">
<dt> [ <tt>-fcFBdeaRGovNAIOPZEnbjrzu/12</tt> ]</dt>
<dt> [ <tt>-k</tt> <var>array</var> ] [ <tt>-g</tt> <var>globstring</var> ] [ <tt>-s</tt> <var>subststring</var> ]</dt>
<dt> [ <tt>-K</tt> <var>function</var> ]</dt>
<dt> [ <tt>-Q</tt> ] [ <tt>-P</tt> <var>prefix</var> ] [ <tt>-S</tt> <var>suffix</var> ]</dt>
<dt> [ <tt>-W</tt> <var>file-prefix</var> ] [ <tt>-H</tt> <var>num pattern</var> ]</dt>
<dt> [ <tt>-q</tt> ] [ <tt>-X</tt> <var>explanation</var> ] [ <tt>-Y</tt> <var>explanation</var> ]</dt>
<dt> [ <tt>-y</tt> <var>func-or-var</var> ] [ <tt>-l</tt> <var>cmd</var> ] [ <tt>-h</tt> <var>cmd</var> ] [ <tt>-U</tt> ]</dt>
<dt> [ <tt>-t</tt> <var>continue</var> ] [ <tt>-J</tt> <var>name</var> ] [ <tt>-V</tt> <var>name</var> ]</dt>
<dt> [ <tt>-M</tt> <var>match-spec</var> ]</dt>
<dt></dt>
</dl>

<p>The remaining <var>options</var> specify the type of command arguments
to look for during completion.  Any combination of these flags may be
specified; the result is a sorted list of all the possibilities.  The
options are as follows.
</p><table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Simple-Flags">21.4.1 Simple Flags</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Flags-with-Arguments">21.4.2 Flags with Arguments</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Control-Flags">21.4.3 Control Flags</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr size="6">
<a name="Simple-Flags"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Option-Flags" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Flags-with-Arguments" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Option-Flags" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Simple-Flags-1"></a>
<h3 class="subsection">21.4.1 Simple Flags</h3>
<p>These produce completion lists made up by the shell itself:
</p>
<dl compact="compact">
<dt> <tt>-f</tt></dt>
<dd><p>Filenames and file system paths.
</p>
</dd>
<dt> <tt>-/</tt></dt>
<dd><p>Just file system paths.
</p>
</dd>
<dt> <tt>-c</tt></dt>
<dd><p>Command names, including aliases, shell functions, builtins
and reserved words.
</p>
</dd>
<dt> <tt>-F</tt></dt>
<dd><p>Function names.
</p>
</dd>
<dt> <tt>-B</tt></dt>
<dd><p>Names of builtin commands.
</p>
</dd>
<dt> <tt>-m</tt></dt>
<dd><p>Names of external commands.
</p>
</dd>
<dt> <tt>-w</tt></dt>
<dd><p>Reserved words.
</p>
</dd>
<dt> <tt>-a</tt></dt>
<dd><p>Alias names.
</p>
</dd>
<dt> <tt>-R</tt></dt>
<dd><p>Names of regular (non-global) aliases.
</p>
</dd>
<dt> <tt>-G</tt></dt>
<dd><p>Names of global aliases.
</p>
</dd>
<dt> <tt>-d</tt></dt>
<dd><p>This can be combined with <tt>-F</tt>, <tt>-B</tt>, <tt>-w</tt>,
<tt>-a</tt>, <tt>-R</tt> and <tt>-G</tt> to get names of disabled
functions, builtins, reserved words or aliases.
</p>
</dd>
<dt> <tt>-e</tt></dt>
<dd><p>This option (to show enabled commands) is in effect by default, but
may be combined with <tt>-d</tt>; <tt>-de</tt> in combination with
<tt>-F</tt>, <tt>-B</tt>, <tt>-w</tt>, <tt>-a</tt>, <tt>-R</tt> and <tt>-G</tt>
will complete names of functions, builtins, reserved words or aliases
whether or not they are disabled.
</p>
</dd>
<dt> <tt>-o</tt></dt>
<dd><p>Names of shell options (see
<a href="Options.html#Options">Options</a>).
</p>
</dd>
<dt> <tt>-v</tt></dt>
<dd><p>Names of any variable defined in the shell.
</p>
</dd>
<dt> <tt>-N</tt></dt>
<dd><p>Names of scalar (non-array) parameters.
</p>
</dd>
<dt> <tt>-A</tt></dt>
<dd><p>Array names.
</p>
</dd>
<dt> <tt>-I</tt></dt>
<dd><p>Names of integer variables.
</p>
</dd>
<dt> <tt>-O</tt></dt>
<dd><p>Names of read-only variables.
</p>
</dd>
<dt> <tt>-p</tt></dt>
<dd><p>Names of parameters used by the shell (including special parameters).
</p>
</dd>
<dt> <tt>-Z</tt></dt>
<dd><p>Names of shell special parameters.
</p>
</dd>
<dt> <tt>-E</tt></dt>
<dd><p>Names of environment variables.
</p>
</dd>
<dt> <tt>-n</tt></dt>
<dd><p>Named directories.
</p>
</dd>
<dt> <tt>-b</tt></dt>
<dd><p>Key binding names.
</p>
</dd>
<dt> <tt>-j</tt></dt>
<dd><p>Job names:  the first word of the job leader&rsquo;s command line.  This is useful
with the <tt>kill</tt> builtin.
</p>
</dd>
<dt> <tt>-r</tt></dt>
<dd><p>Names of running jobs.
</p>
</dd>
<dt> <tt>-z</tt></dt>
<dd><p>Names of suspended jobs.
</p>
</dd>
<dt> <tt>-u</tt></dt>
<dd><p>User names.
</p>
</dd>
</dl>

<hr size="6">
<a name="Flags-with-Arguments"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Simple-Flags" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Control-Flags" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Option-Flags" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Flags-with-Arguments-1"></a>
<h3 class="subsection">21.4.2 Flags with Arguments</h3>
<p>These have user supplied arguments to determine how the list of
completions is to be made up:
</p>
<dl compact="compact">
<dt> <tt>-k</tt> <var>array</var></dt>
<dd><p>Names taken from the elements of <tt>$</tt><var>array</var> (note that the &lsquo;<tt>$</tt>&rsquo;
does not appear on the command line).
Alternatively, the argument <var>array</var> itself may be a set
of space- or comma-separated values in parentheses, in which any
delimiter may be escaped with a backslash; in this case the argument
should be quoted.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -k &quot;(cputime filesize datasize stacksize
	       coredumpsize resident descriptors)&quot; limit
</pre></td></tr></table>

</dd>
<dt> <tt>-g</tt> <var>globstring</var></dt>
<dd><p>The <var>globstring</var> is expanded using filename globbing; it should be
quoted to protect it from immediate expansion. The resulting
filenames are taken as the possible completions.  Use &lsquo;<tt>*(/)</tt>&rsquo; instead of
&lsquo;<tt>*/</tt>&rsquo; for directories.  The <tt>fignore</tt> special parameter is not
applied to the resulting files.  More than one pattern may be given
separated by blanks. (Note that brace expansion is <em>not</em> part of
globbing.  Use the syntax &lsquo;<tt>(either|or)</tt>&rsquo; to match alternatives.)
</p>
</dd>
<dt> <tt>-s</tt> <var>subststring</var></dt>
<dd><p>The <var>subststring</var> is split into words and these words are than
expanded using all shell expansion mechanisms (see
<a href="Expansion.html#Expansion">Expansion</a>).  The resulting words are taken as possible
completions.  The <tt>fignore</tt> special parameter is not applied to the
resulting files.  Note that <tt>-g</tt> is faster for filenames.
</p>
</dd>
<dt> <tt>-K</tt> <var>function</var></dt>
<dd><a name="index-reply_002c-use-of-2"></a>
<p>Call the given function to get the completions.  Unless the name
starts with an underscore, the function is
passed two arguments: the prefix and the suffix of the word on which
completion is to be attempted, in other words those characters before
the cursor position, and those from the cursor position onwards.  The
whole command line can be accessed with the <tt>-c</tt> and <tt>-l</tt> flags
of the <tt>read</tt> builtin. The
function should set the variable <tt>reply</tt> to an array containing
the completions (one completion per element); note that <tt>reply</tt>
should not be made local to the function.  From such a function the
command line can be accessed with the <tt>-c</tt> and <tt>-l</tt> flags to
the <tt>read</tt> builtin.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">function whoson { reply=(`users`); }
compctl -K whoson talk
</pre></td></tr></table>

<p>completes only logged-on users after &lsquo;<tt>talk</tt>&rsquo;.  Note that &lsquo;<tt>whoson</tt>&rsquo; must
return an array, so &lsquo;<tt>reply=&lsquo;users&lsquo;</tt>&rsquo; would be incorrect.
</p>
</dd>
<dt> <tt>-H</tt> <var>num pattern</var></dt>
<dd><p>The possible completions are taken from the last <var>num</var> history
lines.  Only words matching <var>pattern</var> are taken.  If <var>num</var> is
zero or negative the whole history is searched and if <var>pattern</var> is
the empty string all words are taken (as with &lsquo;<tt>*</tt>&rsquo;).  A typical
use is
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -D -f + -H 0 ''
</pre></td></tr></table>

<p>which forces completion to look back in the history list for a word if
no filename matches.
</p>
</dd>
</dl>

<hr size="6">
<a name="Control-Flags"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Flags-with-Arguments" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Alternative-Completion" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Option-Flags" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Control-Flags-1"></a>
<h3 class="subsection">21.4.3 Control Flags</h3>
<p>These do not directly specify types of name to be completed, but
manipulate the options that do:
</p>
<dl compact="compact">
<dt> <tt>-Q</tt></dt>
<dd><p>This instructs the shell not to quote any metacharacters in the possible
completions.  Normally the results of a completion are inserted into
the command line with any metacharacters quoted so that they are
interpreted as normal characters.  This is appropriate for filenames
and ordinary strings.  However, for special effects, such as inserting
a backquoted expression from a completion array (<tt>-k</tt>) so that
the expression will not be evaluated until the complete line is
executed, this option must be used.
</p>
</dd>
<dt> <tt>-P</tt> <var>prefix</var></dt>
<dd><p>The <var>prefix</var> is inserted just before the completed string; any
initial part already typed will be completed and the whole <var>prefix</var>
ignored for completion purposes.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -j -P &quot;%&quot; kill
</pre></td></tr></table>

<p>inserts a &lsquo;%&rsquo; after the kill command and then completes job names.
</p>
</dd>
<dt> <tt>-S</tt> <var>suffix</var></dt>
<dd><p>When a completion is found the <var>suffix</var> is inserted after
the completed string.  In the case of menu completion the suffix is
inserted immediately, but it is still possible to cycle through the
list of completions by repeatedly hitting the same key.
</p>
</dd>
<dt> <tt>-W</tt> <var>file-prefix</var></dt>
<dd><p>With directory <var>file-prefix</var>:  for command, file, directory and
globbing completion (options <tt>-c</tt>, <tt>-f</tt>, <tt>-/</tt>, <tt>-g</tt>), the file
prefix is implicitly added in front of the completion.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -/ -W ~/Mail maildirs
</pre></td></tr></table>

<p>completes any subdirectories to any depth beneath the directory
<tt>~/Mail</tt>, although that prefix does not appear on the command line.
The <var>file-prefix</var> may also be of the form accepted by the <tt>-k</tt>
flag, i.e. the name of an array or a literal list in parenthesis. In
this case all the directories in the list will be searched for
possible completions.
</p>
</dd>
<dt> <tt>-q</tt></dt>
<dd><p>If used with a suffix as specified by the <tt>-S</tt> option, this
causes the suffix to be removed if the next character typed is a blank
or does not insert anything or if the suffix consists of only one character
and the next character typed is the same character; this the same rule used
for the <tt>AUTO_REMOVE_SLASH</tt> option.  The option is most useful for list
separators (comma, colon, etc.).
</p>
</dd>
<dt> <tt>-l</tt> <var>cmd</var></dt>
<dd><p>This option restricts the range
of command line words that are considered to be arguments.  If
combined with one of the extended completion patterns &lsquo;<tt>p[</tt>...<tt>]</tt>&rsquo;,
&lsquo;<tt>r[</tt>...<tt>]</tt>&rsquo;, or &lsquo;<tt>R[</tt>...<tt>]</tt>&rsquo;  (see <a href="#Extended-Completion">Extended Completion</a>
below) the range is restricted to the range of arguments
specified in the brackets.  Completion is then performed as if these
had been given as arguments to the <var>cmd</var> supplied with the
option. If the <var>cmd</var> string is empty the first word in the range
is instead taken as the command name, and command name completion
performed on the first word in the range.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -x 'r[-exec,;]' -l '' -- find
</pre></td></tr></table>

<p>completes arguments between &lsquo;<tt>-exec</tt>&rsquo; and the following &lsquo;<tt>;</tt>&rsquo; (or the end
of the command line if there is no such string) as if they were
a separate command line.
</p>
</dd>
<dt> <tt>-h</tt> <var>cmd</var></dt>
<dd><p>Normally zsh completes quoted strings as a whole. With this option,
completion can be done separately on different parts of such
strings. It works like the <tt>-l</tt> option but makes the completion code 
work on the parts of the current word that are separated by
spaces. These parts are completed as if they were arguments to the
given <var>cmd</var>. If <var>cmd</var> is the empty string, the first part is
completed as a command name, as with <tt>-l</tt>.
</p>
</dd>
<dt> <tt>-U</tt></dt>
<dd><p>Use the whole list of possible completions, whether or not they
actually match the word on the command line.  The word typed so far
will be deleted.  This is most useful with a function (given by the
<tt>-K</tt> option) which can examine the word components passed to it
(or via the <tt>read</tt> builtin&rsquo;s <tt>-c</tt> and <tt>-l</tt> flags) and
use its own criteria to decide what matches.  If there is no
completion, the original word is retained.  Since the produced 
possible completions seldom have interesting common prefixes
and suffixes, menu completion is started immediately if <tt>AUTO_MENU</tt> is
set and this flag is used.
</p>
</dd>
<dt> <tt>-y</tt> <var>func-or-var</var></dt>
<dd><a name="index-reply_002c-use-of-3"></a>
<p>The list provided by <var>func-or-var</var> is displayed instead of the list
of completions whenever a listing is required; the actual completions
to be inserted are not affected.  It can be provided in two
ways. Firstly, if <var>func-or-var</var> begins with a <tt>$</tt> it defines a
variable, or if it begins with a left parenthesis a literal
array, which contains the list.  A variable may have been set by a
call to a function using the <tt>-K</tt> option.  Otherwise it contains the
name of a function which will be executed to create the list.  The
function will be passed as an argument list all matching completions,
including prefixes and suffixes expanded in full, and should set the
array <tt>reply</tt> to the result.  In both cases, the display list will
only be retrieved after a complete list of matches has been created.
</p>
<p>Note that the returned list does not have to correspond, even in
length, to the original set of matches, and may be passed as a scalar
instead of an array.  No special formatting of characters is
performed on the output in this case; in particular, newlines are
printed literally and if they appear output in columns is suppressed.
</p>
</dd>
<dt> <tt>-X</tt> <var>explanation</var></dt>
<dd><p>Print <var>explanation</var> when trying completion on the current set of
options. A &lsquo;<tt>%n</tt>&rsquo; in this string is replaced by the number of
matches that were added for this explanation string.
The explanation only appears if completion was tried and there was
no unique match, or when listing completions. Explanation strings 
will be listed together with the matches of the group specified
together with the <tt>-X</tt> option (using the <tt>-J</tt> or <tt>-V</tt>
option). If the same explanation string is given to multiple <tt>-X</tt>
options, the string appears only once (for each group) and the number
of matches shown for the &lsquo;<tt>%n</tt>&rsquo; is the total number of all matches
for each of these uses. In any case, the explanation string will only
be shown if there was at least one match added for the explanation
string.
</p>
<p>The sequences <tt>%B</tt>, <tt>%b</tt>, <tt>%S</tt>, <tt>%s</tt>, <tt>%U</tt>, and <tt>%u</tt> specify
output attributes (bold, standout, and underline), <tt>%F</tt>, <tt>%f</tt>, <tt>%K</tt>,
<tt>%k</tt> specify foreground and background colours, and <tt>%{...%}</tt> can
be used to include literal escape sequences as in prompts.
</p>
</dd>
<dt> <tt>-Y</tt> <var>explanation</var></dt>
<dd><p>Identical to <tt>-X</tt>, except that the <var>explanation</var> first undergoes
expansion following the usual rules for strings in double quotes.
The expansion will be carried out after any functions are called for
the <tt>-K</tt> or <tt>-y</tt> options, allowing them to set variables.
</p>
</dd>
<dt> <tt>-t</tt> <var>continue</var></dt>
<dd><p>The <var>continue</var>-string contains a character that specifies which set
of completion flags should be used next.  It is useful:
</p>
<p>(i) With <tt>-T</tt>, or when trying a list of pattern completions, when
<tt>compctl</tt> would usually continue with ordinary processing after
finding matches; this can be suppressed with &lsquo;<tt>-tn</tt>&rsquo;.
</p>
<p>(ii) With a list of alternatives separated by <tt>+</tt>, when <tt>compctl</tt>
would normally stop when one of the alternatives generates matches.  It
can be forced to consider the next set of completions by adding &lsquo;<tt>-t+</tt>&rsquo;
to the flags of the alternative before the &lsquo;<tt>+</tt>&rsquo;.
</p>
<p>(iii) In an extended completion list (see below), when <tt>compctl</tt> would
normally continue until a set of conditions succeeded, then use only
the immediately following flags.  With &lsquo;<tt>-t-</tt>&rsquo;, <tt>compctl</tt> will
continue trying extended completions after the next &lsquo;<tt>-</tt>&rsquo;; with
&lsquo;<tt>-tx</tt>&rsquo; it will attempt completion with the default flags, in other
words those before the &lsquo;<tt>-x</tt>&rsquo;.
</p>
</dd>
<dt> <tt>-J</tt> <var>name</var></dt>
<dd><p>This gives the name of the group the matches should be placed in. Groups
are listed and sorted separately; likewise, menu completion will offer
the matches in the groups in the order in which the groups were
defined. If no group name is explicitly given, the matches are stored in
a group named <var>default</var>. The first time a group name is encountered,
a group with that name is created. After that all matches with the same
group name are stored in that group.
</p>
<p>This can be useful with non-exclusive alternative completions.  For
example, in
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -f -J files -t+ + -v -J variables foo
</pre></td></tr></table>

<p>both files and variables are possible completions, as the <tt>-t+</tt> forces
both sets of alternatives before and after the <tt>+</tt> to be considered at
once.  Because of the <tt>-J</tt> options, however, all files are listed
before all variables.
</p>
</dd>
<dt> <tt>-V</tt> <var>name</var></dt>
<dd><p>Like <tt>-J</tt>, but matches within the group will not be sorted in listings
nor in menu completion. These unsorted groups are in a different name
space from the sorted ones, so groups defined as <tt>-J files</tt> and <tt>-V
files</tt> are distinct.
</p>
</dd>
<dt> <tt>-1</tt></dt>
<dd><p>If given together with the <tt>-V</tt> option, makes
only consecutive duplicates in the group be removed. Note that groups
with and without this flag are in different name spaces.
</p>
</dd>
<dt> <tt>-2</tt></dt>
<dd><p>If given together with the <tt>-J</tt> or <tt>-V</tt> option, makes all
duplicates be kept. Again, groups with and without this flag are in
different name spaces.
</p>
</dd>
<dt> <tt>-M</tt> <var>match-spec</var></dt>
<dd><p>This defines additional matching control specifications that should be used
only when testing words for the list of flags this flag appears in. The format
of the <var>match-spec</var> string is described in 
<a href="Completion-Widgets.html#Completion-Matching-Control">Completion Matching Control</a>.
</p>
</dd>
</dl>

<hr size="6">
<a name="Alternative-Completion"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Control-Flags" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Extended-Completion" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Alternative-Completion-1"></a>
<h2 class="section">21.5 Alternative Completion</h2>
<dl compact="compact">
<dt> <tt>compctl</tt> [ <tt>-CDT</tt> ] <var>options</var> <tt>+</tt> <var>options</var> [ <tt>+</tt> ... ] [ <tt>+</tt> ] <var>command</var> ...</dt>
<dt></dt>
</dl>

<p>The form with &lsquo;<tt>+</tt>&rsquo; specifies alternative options. Completion is
tried with the options before the first &lsquo;<tt>+</tt>&rsquo;. If this produces no
matches completion is tried with the flags after the &lsquo;<tt>+</tt>&rsquo; and so on. If
there are no flags after the last &lsquo;<tt>+</tt>&rsquo; and a match has not been found
up to that point, default completion is tried.
If the list of flags contains a <tt>-t</tt> with a <tt>+</tt> character, the next
list of flags is used even if the current list produced matches.
</p>
<hr size="6">
<a name="Extended-Completion"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Alternative-Completion" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Example" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<p>Additional options are available that restrict completion to some part
of the command line; this is referred to as &lsquo;extended completion&rsquo;.
</p>

<a name="Extended-Completion-1"></a>
<h2 class="section">21.6 Extended Completion</h2>
<dl compact="compact">
<dt> <tt>compctl</tt> [ <tt>-CDT</tt> ] <var>options</var> <tt>-x</tt> <var>pattern</var> <var>options</var> <tt>-</tt> ... <tt>-</tt><tt>-</tt></dt>
<dt>          [ <var>command</var> ... ]</dt>
<dt> <tt>compctl</tt> [ <tt>-CDT</tt> ] <var>options</var> [ <tt>-x</tt> <var>pattern</var> <var>options</var> <tt>-</tt> ... <tt>-</tt><tt>-</tt> ]</dt>
<dt>          [ <tt>+</tt> <var>options</var> [ <tt>-x</tt> ... <tt>-</tt><tt>-</tt> ] ... [<tt>+</tt>] ] [ <var>command</var> ... ]</dt>
<dt></dt>
</dl>

<p>The form with &lsquo;<tt>-x</tt>&rsquo; specifies extended completion for the
commands given; as shown, it may be combined with alternative
completion using &lsquo;<tt>+</tt>&rsquo;.  Each <var>pattern</var> is examined in turn; when a
match is found, the corresponding <var>options</var>, as described in
<a href="#Option-Flags">Option Flags</a> above, are used to generate possible
completions.  If no <var>pattern</var> matches, the <var>options</var> given
before the <tt>-x</tt> are used.
</p>
<p>Note that each pattern should be supplied as a single argument and
should be quoted to prevent expansion of metacharacters by the
shell.
</p>
<p>A <var>pattern</var> is built of sub-patterns separated by commas; it
matches if at least one of these sub-patterns matches (they are
&lsquo;or&rsquo;ed). These sub-patterns are in turn composed of other
sub-patterns separated by white spaces which match if all of the
sub-patterns match (they are &lsquo;and&rsquo;ed).  An element of the
sub-patterns is of the form &lsquo;<var>c</var><tt>[</tt>...<tt>][</tt>...<tt>]</tt>&rsquo;, where the pairs of
brackets may be repeated as often as necessary, and matches if any of
the sets of brackets match (an &lsquo;or&rsquo;).  The example below makes this
clearer.
</p>
<p>The elements may be any of the following:
</p>
<dl compact="compact">
<dt> <tt>s[</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Matches if the current word on the command line starts with
one of the strings given in brackets.  The <var>string</var> is not removed
and is not part of the completion.
</p>
</dd>
<dt> <tt>S[</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Like <tt>s[</tt><var>string</var><tt>]</tt> except that the <var>string</var> is part of the
completion.
</p>
</dd>
<dt> <tt>p[</tt><var>from</var><tt>,</tt><var>to</var><tt>]</tt>...</dt>
<dd><p>Matches if the number of the current word is between one of
the <var>from</var> and <var>to</var> pairs inclusive. The comma and <var>to</var>
are optional; <var>to</var> defaults to the same value as <var>from</var>.  The
numbers may be negative: <tt>-</tt><var>n</var> refers to the <var>n</var>&rsquo;th last word
on the line.
</p>
</dd>
<dt> <tt>c[</tt><var>offset</var><tt>,</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Matches if the <var>string</var> matches the word offset by
<var>offset</var> from the current word position.  Usually <var>offset</var>
will be negative.
</p>
</dd>
<dt> <tt>C[</tt><var>offset</var><tt>,</tt><var>pattern</var><tt>]</tt>...</dt>
<dd><p>Like <tt>c</tt> but using pattern matching instead.
</p>
</dd>
<dt> <tt>w[</tt><var>index</var><tt>,</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Matches if the word in position <var>index</var> is equal
to the corresponding <var>string</var>.  Note that the word count is made
after any alias expansion.
</p>
</dd>
<dt> <tt>W[</tt><var>index</var><tt>,</tt><var>pattern</var><tt>]</tt>...</dt>
<dd><p>Like <tt>w</tt> but using pattern matching instead.
</p>
</dd>
<dt> <tt>n[</tt><var>index</var><tt>,</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Matches if the current word contains <var>string</var>.  Anything up to and
including the <var>index</var>th occurrence of this string will not be
considered part of the completion, but the rest will.  <var>index</var> may
be negative to count from the end: in most cases, <var>index</var> will be
1 or -1.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">compctl -s '`users`' -x 'n[1,@]' -k hosts -- talk
</pre></td></tr></table>

<p>will usually complete usernames, but if you insert an <tt>@</tt> after the
name, names from the array <var>hosts</var> (assumed to contain hostnames,
though you must make the array yourself) will be completed.  Other
commands such as <tt>rcp</tt> can be handled similarly.
</p>
</dd>
<dt> <tt>N[</tt><var>index</var><tt>,</tt><var>string</var><tt>]</tt>...</dt>
<dd><p>Like <tt>n</tt> except that the string will be
taken as a character class.  Anything up to and including the
<var>index</var>th occurrence of any of the characters in <var>string</var>
will not be considered part of the completion.
</p>
</dd>
<dt> <tt>m[</tt><var>min</var><tt>,</tt><var>max</var><tt>]</tt>...</dt>
<dd><p>Matches if the total number of words lies between <var>min</var> and
<var>max</var> inclusive.
</p>
</dd>
<dt> <tt>r[</tt><var>str1</var><tt>,</tt><var>str2</var><tt>]</tt>...</dt>
<dd><p>Matches if the cursor is after a word with prefix <var>str1</var>.  If there
is also a word with prefix <var>str2</var> on the command line after the one 
matched by <var>str1</var> it matches
only if the cursor is before this word. If the comma and <var>str2</var> are
omitted, it matches if the cursor is after a word with prefix <var>str1</var>.
</p>
</dd>
<dt> <tt>R[</tt><var>str1</var><tt>,</tt><var>str2</var><tt>]</tt>...</dt>
<dd><p>Like <tt>r</tt> but using pattern matching instead.
</p>
</dd>
<dt> <tt>q[</tt><var>str</var><tt>]</tt>...</dt>
<dd><p>Matches the word currently being completed is in single quotes and the 
<var>str</var> begins with the letter &lsquo;s&rsquo;, or if completion is done in
double quotes and <var>str</var> starts with the letter &lsquo;d&rsquo;, or if
completion is done in backticks and <var>str</var> starts with a &lsquo;b&rsquo;.
</p>
</dd>
</dl>

<hr size="6">
<a name="Example"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Extended-Completion" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Example-2"></a>
<h2 class="section">21.7 Example</h2>

<table><tr><td>&nbsp;</td><td><pre class="example">compctl -u -x 's[<tt>+</tt>] c[-1,-f],s[-f+]' \ 
  -g '~/Mail/*(:t)' - 's[-f],c[-1,-f]' -f -- mail
</pre></td></tr></table>

<p>This is to be interpreted as follows:
</p>
<p>If the current command is <tt>mail</tt>, then
</p>
<blockquote>
<p>if ((the current word begins with <tt>+</tt> and the previous word is <tt>-f</tt>)
or (the current word begins with <tt>-f+</tt>)), then complete the
non-directory part (the &lsquo;<tt>:t</tt>&rsquo; glob modifier) of files in the directory
<tt>~/Mail</tt>; else
</p>
<p>if the current word begins with <tt>-f</tt> or the previous word was <tt>-f</tt>, then
complete any file; else
</p>
<p>complete user names.
</p>
</blockquote>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Completion-Using-compctl" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Zsh-Modules.html#Zsh-Modules" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Peter Stephenson</em> on <em>December 21, 2012</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
 </font>
 <br>

</p>
</body>
</html>