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
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
|
texinode(Completion System)(Completion Using compctl)(Completion Widgets)(Top)
chapter(Completion System)
cindex(completion system)
cindex(completion, programmable)
cindex(completion, controlling)
sect(Description)
This describes the shell code for the `new' completion system, referred
to as tt(compsys). It is written in shell functions based on the
features described in
ifzman(zmanref(zshcompwid))\
ifnzman(the previous chapter, noderef(Completion Widgets)).
The features are contextual, sensitive to the point at which completion is
started. Many completions are already provided.
For this reason, a user can perform a great many tasks without
knowing any details beyond how to initialize the system, which is
described
ifzman(below in INITIALIZATION)\
ifnzman(in noderef(Initialization)).
The context that decides what completion is to be performed may be
startitemize()
itemiz(\
an argument or option position: these describe the position on the
command line at which completion is requested. For example `first argument
to rmdir, the word being completed names a directory';
)
itemiz(\
a special context, denoting an element in the shell's syntax. For example
`a word in command position' or `an array subscript'.
)
enditemize()
A full context specification contains other elements, as we shall describe.
Besides commands names and contexts, the system employs two more
concepts, em(styles) and em(tags). These provide ways for the user
to configure the system's behaviour.
Tags play a dual role. They serve as a classification system for
the matches, typically indicating a class of object that the user
may need to distinguish. For example, when completing arguments of the
tt(ls) command the user may prefer to try tt(files) before tt(directories),
so both of these are tags. They also appear as the rightmost
element in a context specification.
Styles modify various operations of the completion system, such as
output formatting, but also what kinds of completers are used (and in
what order), or which tags are examined. Styles may accept arguments
and are manipulated using the tt(zstyle) command described in
ifzman(see zmanref(zshmodules))\
ifnzman(noderef(The zsh/zutil Module)).
In summary, tags describe em(what) the completion objects are, and style
tt(how) they are to be completed. At various points of execution, the
completion system checks what styles and/or tags are defined for the
current context, and uses that to modify its behavior. The full
description of context handling, which determines how tags and other
elements of the context influence the behaviour of styles, is described
ifzman(below in COMPLETION SYSTEM CONFIGURATION)\
ifnzman(in noderef(Completion System Configuration)).
When a completion is requested, a dispatcher function is called;
see the description of tt(_main_complete) in the list of control functions
below. This dispatcher decides which function should
be called to produce the completions, and calls it. The result is
passed to one or more em(completers), functions that implement
individual completion strategies: simple completion, error correction,
completion with error correction, menu selection, etc.
More generally, the shell functions contained in the completion system are
of two types:
startitemize()
itemiz(\
those beginning `tt(comp)' are to be called directly; there are only
a few of these;
)
itemiz(\
those beginning `tt(_)' are called by the
completion code. The shell functions of this set, which implement
completion behaviour and may be bound to keystrokes, are referred to
as `widgets'. These proliferate as new completions are required.
)
enditemize()
startmenu()
menu(Initialization)
menu(Completion System Configuration)
menu(Control Functions)
menu(Bindable Commands)
menu(Completion Functions)
menu(Completion Directories)
endmenu()
texinode(Initialization)(Completion System Configuration)()(Completion System)
sect(Initialization)
findex(compinstall)
cindex(completion system, installing)
If the system was installed completely, it should be enough to
call the shell function tt(compinit) from your initialization file; see the
next section. However, the function tt(compinstall) can be run by a user
to configure various aspects of the completion system.
Usually, tt(compinstall) will insert code into tt(.zshrc), although if
that is not writable it will save it in another file and tell you that
file's location. Note that it is up to you to make sure that the lines
added to tt(.zshrc) are actually run; you may, for example, need to move
them to an earlier place in the file if tt(.zshrc) usually returns early.
So long as you keep them all together (including the comment lines at the
start and finish), you can rerun tt(compinstall) and it will correctly
locate and modify these lines. Note, however, that any code you add to
this section by hand is likely to be lost if you rerun tt(compinstall),
although lines using the command `tt(zstyle)' should be gracefully handled.
The new code will take effect next time you start the shell, or run
tt(.zshrc) by hand; there is also an option to make them take effect
immediately. However, if tt(compinstall) has removed definitions, you will
need to restart the shell to see the changes.
To run tt(compinstall) you will need to make sure it is in a directory
mentioned in your tt(fpath) parameter, which should already be the case if
zsh was properly configured as long as your startup files do not remove the
appropriate directories from tt(fpath). Then it must be autoloaded
(`tt(autoload -U compinstall)' is recommended). You can abort the
installation any time you are being prompted for information, and your
tt(.zshrc) will not be altered at all; changes only take place right at the
end, where you are specifically asked for confirmation.
subsect(Use of compinit)
findex(compinit)
cindex(completion system, initializing)
This section describes the use of tt(compinit) to initialize completion for
the current session when called directly; if you have run
tt(compinstall) it will be called automatically from your tt(.zshrc).
To initialize the system, the function tt(compinit) should be in a
directory mentioned in the tt(fpath) parameter, and should be autoloaded
(`tt(autoload -U compinit)' is recommended), and then run simply as
`tt(compinit)'. This will define a
few utility functions, arrange for all the necessary shell functions to be
autoloaded, and will then re-define all widgets that do completion to use the
new system. If you use the tt(menu-select) widget, which is part of the
tt(zsh/complist) module, you should make sure that that module is loaded
before the call to tt(compinit) so that that widget is also
re-defined. If completion styles (see below) are set up to perform
expansion as well as completion by default, and the TAB key is bound to
tt(expand-or-complete), tt(compinit) will rebind it to tt(complete-word);
this is necessary to use the correct form of expansion.
Should you need to use the original completion commands, you can still
bind keys to the old widgets by putting a `tt(.)' in front of the
widget name, e.g. `tt(.expand-or-complete)'.
To speed up the running of tt(compinit), it can be made to produce a dumped
configuration that will be read in on future invocations; this is the
default, but can be turned off by calling tt(compinit) with the
option tt(-D). The dumped file is tt(.zcompdump) in the same
directory as the startup files (i.e. tt($ZDOTDIR) or tt($HOME));
alternatively, an explicit file name can be given by `tt(compinit -d)
var(dumpfile)'. The next invocation of tt(compinit) will read the dumped
file instead of performing a full initialization.
If the number of completion files changes, tt(compinit) will recognise this
and produce a new dump file. However, if the name of a function or the
arguments in the first line of a tt(#compdef) function (as described below)
change, it is easiest to delete the dump file by hand so that
tt(compinit) will re-create it the next time it is run. The check
performed to see if there are new functions can be omitted by giving
the option tt(-C). In this case the dump file will only be created if
there isn't one already.
The dumping is actually done by another function, tt(compdump), but you
will only need to run this yourself if you change the configuration
(e.g. using tt(compdef)) and then want to dump the new one. The name of
the old dumped file will be remembered for this purpose.
If the parameter tt(_compdir) is set, tt(compinit) uses it as a directory
where completion functions can be found; this is only necessary if they are
not already in the function search path.
For security reasons tt(compinit) also checks if the completion system
would use files not owned by root or by the current user, or files in
directories that are world- or group-writable or that are not owned by
root or by the current user. If such files or directories are found,
tt(compinit) will ask if the completion system should really be used. To
avoid these tests and make all files found be used without asking, use the
option tt(-u), and to make tt(compinit) silently ignore all insecure files
and directories use the option tt(-i). This security check is skipped
entirely when the tt(-C) option is given.
findex(compaudit)
The security check can be retried at any time by running the function
tt(compaudit). This is the same check used by tt(compinit), but when it
is executed directly any changes to tt(fpath) are made local to the
function so they do not persist. The directories to be checked may be
passed as arguments; if none are given, tt(compaudit) uses tt(fpath) and
tt(_compdir) to find completion system directories, adding missing ones
to tt(fpath) as necessary. To force a check of exactly the directories
currently named in tt(fpath), set tt(_compdir) to an empty string before
calling tt(compaudit) or tt(compinit).
subsect(Autoloaded files)
cindex(completion system, autoloaded functions)
The convention for autoloaded functions used in completion is that they
start with an underscore; as already mentioned, the tt(fpath/FPATH)
parameter must contain the directory in which they are stored. If tt(zsh)
was properly installed on your system, then tt(fpath/FPATH) automatically
contains the required directories for the standard functions.
For incomplete installations, if tt(compinit) does not find enough files
beginning with an underscore (fewer than twenty) in the search path, it
will try to find more by adding the directory tt(_compdir) to the search
path. If that directory has a subdirectory named tt(Base), all
subdirectories will be added to the path. Furthermore, if the subdirectory
tt(Base) has a subdirectory named tt(Core), tt(compinit) will add all
subdirectories of the subdirectories is to the path: this allows
the functions to be in the same format as in the tt(zsh) source
distribution.
cindex(compdef, use of by compinit)
When tt(compinit) is run, it searches all such files accessible via
tt(fpath/FPATH) and reads the first line of each of them. This line should
contain one of the tags described below. Files whose first line does not
start with one of these tags are not considered to be part of the
completion system and will not be treated specially.
The tags are:
startitem()
item(tt(#compdef) var(names...) [ tt(-[pP]) var(patterns...) [ tt(-N) var(names...) ] ])(
The file will be made autoloadable and the function defined
in it will be called when completing var(names), each of which is
either the name of a command whose arguments are to be completed or one of
a number of special contexts in the form tt(-)var(context)tt(-) described
below.
Each var(name) may also be of the form `var(cmd)tt(=)var(service)'.
When completing the command var(cmd), the function typically behaves as
if the command (or special context) var(service) was being completed
instead. This provides a way of altering the behaviour of functions
that can perform many different completions. It is implemented
by setting the parameter tt($service) when calling the function;
the function may choose to interpret this how it wishes, and simpler
functions will probably ignore it.
If the tt(#compdef) line contains one of the options tt(-p) or tt(-P),
the words following are taken to be patterns. The function will be
called when completion is attempted for a command or context that matches
one of the patterns. The options tt(-p) and tt(-P) are used to specify
patterns to be tried before or after other completions respectively.
Hence tt(-P) may be used to specify default actions.
The option tt(-N) is used after a list following tt(-p) or tt(-P); it
specifies that remaining words no longer define patterns. It is
possible to toggle between the three options as many times as necessary.
)
item(tt(#compdef -k) var(style key-sequences...))(
This option creates a widget behaving like the
builtin widget var(style) and binds it to the given var(key-sequences),
if any. The var(style) must be one of the builtin widgets that perform
completion, namely tt(complete-word), tt(delete-char-or-list),
tt(expand-or-complete), tt(expand-or-complete-prefix), tt(list-choices),
tt(menu-complete), tt(menu-expand-or-complete), or
tt(reverse-menu-complete). If the tt(zsh/complist) module is loaded (see
ifzman(zmanref(zshmodules))\
ifnzman(noderef(The zsh/complist Module))\
) the widget tt(menu-select) is also available.
When one of the var(key-sequences) is typed, the function in the file will
be invoked to generate the matches. Note that a key will not be re-bound
if if it already was (that is, was bound to something other than
tt(undefined-key)). The widget created has the same name as the file and
can be bound to any other keys using tt(bindkey) as usual.
)
item(tt(#compdef -K) var(widget-name) var(style) var(key-sequences) ...)(
This is similar to tt(-k) except that only one var(key-sequences)
argument may be given for each var(widget-name) var(style) pair.
However, the entire set of three arguments may be repeated with a
different set of arguments. Note in particular that the
var(widget-name) must be distinct in each set. If it does not begin with
`tt(_)' this will be added. The var(widget-name) should not clash with
the name of any existing widget: names based on the name of the function
are most useful. For example,
example(#compdef -K _foo_complete complete-word "^X^C" \
_foo_list list-choices "^X^D")
(all on one line) defines a widget tt(_foo_complete) for completion, bound
to `tt(^X^C)', and a widget tt(_foo_list) for listing, bound to `tt(^X^D)'.
)
item(tt(#autoload) [ var(options) ])(
Functions with the tt(#autoload) tag are marked for autoloading but
are not otherwise treated specially. Typically they are to be called
from within one of the completion functions. Any var(options) supplied
will be passed to the tt(autoload) builtin; a typical use is tt(+X) to
force the function to be loaded immediately. Note that the tt(-U) and
tt(-z) flags are always added implicitly.
)
enditem()
The tt(#) is part of the tag name and no white space is allowed after it.
The tt(#compdef) tags use the tt(compdef) function described below; the
main difference is that the name of the function is supplied implicitly.
The special contexts for which completion functions can be defined are:
startitem()
kindex(-array-value-, completion context)
item(tt(-array-value-))(
The right hand side of an array-assignment
(`tt(foo=LPAR()...RPAR())')
)
kindex(-brace-parameter-, completion context)
item(tt(-brace-parameter-))(
The name of a parameter expansion within braces (`tt(${...})')
)
kindex(-assign-parameter-, completion context)
item(tt(-assign-parameter-))(
The name of a parameter in an assignment, i.e. on the left hand side of
an `tt(=)'
)
kindex(-command-, completion context)
item(tt(-command-))(
A word in command position
)
kindex(-condition-, completion context)
item(tt(-condition-))(
A word inside a condition (`tt([[...]])')
)
kindex(-default-, completion context)
item(tt(-default-))(
Any word for which no other completion is defined
)
kindex(-equal-, completion context)
item(tt(-equal-))(
A word beginning with an equals sign
)
kindex(-first-, completion context)
item(tt(-first-))(
This is tried before any other completion function. The function called
may set the tt(_compskip) parameter to one of various values:
tt(all): no further completion is attempted; a string
containing the substring tt(patterns): no pattern completion functions
will be called; a string containing tt(default): the
function for the `tt(-default-)' context will not be called, but
functions defined for commands will
)
kindex(-math-, completion context)
item(tt(-math-))(
Inside mathematical contexts, such as
`tt(LPAR()LPAR())...tt(RPAR()RPAR())'
)
kindex(-parameter-, completion context)
item(tt(-parameter-))(
The name of a parameter expansion (`tt($...)')
)
kindex(-redirect-, completion context)
item(tt(-redirect-))(
The word after a redirection operator.
)
kindex(-subscript-, completion context)
item(tt(-subscript-))(
The contents of a parameter subscript.
)
kindex(-tilde-, completion context)
item(tt(-tilde-))(
After an initial tilde (`tt(~)'), but before the first slash
in the word.
)
kindex(-value-, completion context)
item(tt(-value-))(
On the right hand side of an assignment.
)
enditem()
Default implementations are supplied for each of these
contexts. In most cases the context tt(-)var(context)tt(-) is
implemented by a corresponding function tt(_)var(context), for example
the context `tt(-tilde-)' and the function `tt(_tilde)').
The contexts tt(-redirect-) and tt(-value-) allow extra context-specific
information. (Internally, this is handled by the functions for each
context calling the function tt(_dispatch).) The extra
information is added separated by commas.
For the tt(-redirect-) context, the extra information is in the form
`tt(-redirect-,)var(op)tt(,)var(command)', where var(op) is the
redirection operator and var(command) is the name of the command on
the line. If there is no command on the line yet, the var(command)
field will be empty.
For the tt(-value-) context, the form is
`tt(-value-,)var(name)tt(,)var(command)', where var(name) is the name of
the parameter. In the case of elements of an associative array, for
example `tt(assoc=LPAR()key <TAB>)', var(name) is expanded to
`var(name)tt(-)var(key)'. In certain special contexts, such as
completing after `tt(make CFLAGS=)', the var(command) part gives the
name of the command, here tt(make); otherwise it is empty.
It is not necessary to define fully specific completions as the
functions provided will try to generate completions by progressively
replacing the elements with `tt(-default-)'. For example, when
completing after `tt(foo=<TAB>)', tt(_value) will try the names
`tt(-value-,foo,)' (note the empty var(command) part),
`tt(-value-,foo,-default-)' and`tt(-value-,-default-,-default-)', in
that order, until it finds a function to handle the context.
As an example:
example(compdef '_files -g "*.log"' '-redirect-,2>,-default-')
completes files matching `tt(*.log)' after `tt(2> <TAB>)' for any
command with no more specific handler defined.
Also:
example(compdef _foo -value-,-default-,-default-)
specifies that tt(_foo) provides completions for the values of
parameters for which no special function has been defined. This is
usually handled by the function tt(_value) itself.
The same lookup rules are used when looking up styles (as described
below); for example
example(zstyle ':completion:*:*:-redirect-,2>,*:*' file-patterns '*.log')
is another way to make completion after `tt(2> <TAB>)' complete files
matching `tt(*.log)'.
subsect(Functions)
The following function is defined by tt(compinit) and may be called
directly.
findex(compdef)
cindex(completion system, adding definitions)
startitem()
xitem(tt(compdef) [ tt(-an) ] var(function names...) [ tt(-[pP]) var(patterns...) [ tt(-N) var(names...) ] ])
xitem(tt(compdef -d) var(names...))
xitem(tt(compdef -k) [ tt(-an) ] var(function style key-sequences...))
item(tt(compdef -K) [ tt(-an) ] var(function name style key-sequences ...))(
The first form defines the var(function) to call for completion in the
given contexts as described for the tt(#compdef) tag above.
Alternatively, all the arguments may have the form
`var(cmd)tt(=)var(service)'. Here var(service) should already have been
defined by `var(cmd1)tt(=)var(service)' lines in tt(#compdef) files, as
described above. The argument for var(cmd) will be completed in the
same way as var(service).
The var(function) argument may alternatively be a string containing any
shell code. The string will be executed using the tt(eval) builtin
command to generate completions. This provides a way of avoiding having
to define a new completion function. For example, to complete
files ending in `tt(.h)' as arguments to the command tt(foo):
example(compdef '_files -g "*.h"' foo)
The option tt(-n) prevents any completions already defined for the
command or context from being overwritten.
The option tt(-d) deletes any completion defined for the command or
contexts listed.
The var(names) may also contain tt(-p), tt(-P) and tt(-N) options as
described for the tt(#compdef) tag. The effect on the argument list is
identical, switching between definitions of patterns tried initially,
patterns tried finally, and normal commands and contexts.
The parameter tt($_compskip) may be set by any function defined for a
pattern context. If it is set to a value containing the substring
`tt(patterns)' none of the pattern-functions will be called; if it is
set to a value containing the substring `tt(all)', no other function
will be called.
The form with tt(-k) defines a widget with the same name as the var(function)
that will be called for each of the var(key-sequences); this is like the
tt(#compdef -k) tag. The function should generate the completions needed
and will otherwise behave like the builtin widget whose name is given as
the var(style) argument. The widgets usable for this are:
tt(complete-word), tt(delete-char-or-list), tt(expand-or-complete),
tt(expand-or-complete-prefix), tt(list-choices), tt(menu-complete),
tt(menu-expand-or-complete), and tt(reverse-menu-complete), as well as
tt(menu-select) if the tt(zsh/complist) module is loaded. The option tt(-n)
prevents the key being bound if it is already to bound to something other
than tt(undefined-key).
The form with tt(-K) is similar and defines multiple widgets based on the
same var(function), each of which requires the set of three arguments
var(name), var(style) and var(key-sequences), where the latter two are as
for tt(-k) and the first must be a unique widget name beginning with an
underscore.
Wherever applicable, the tt(-a) option makes the var(function)
autoloadable, equivalent to tt(autoload -U )var(function).
)
enditem()
The function tt(compdef) can be used to associate existing completion
functions with new commands. For example,
example(compdef _pids foo)
uses the function tt(_pids) to complete process IDs for the command tt(foo).
Note also the tt(_gnu_generic) function described below, which can be
used to complete options for commands that understand the
`tt(-)tt(-help)' option.
texinode(Completion System Configuration)(Control Functions)(Initialization)(Completion System)
sect(Completion System Configuration)
cindex(completion system, configuration)
This section gives a short overview of how the completion system works,
and then more detail on how users can configure how and when matches are
generated.
subsect(Overview)
When completion is attempted somewhere on the command line the
completion system first works out the context. This takes account of a
number of things including the command word (such as `tt(grep)' or
`tt(zsh)') and options to which the current word may be an argument
(such as the `tt(-o)' option to tt(zsh) which takes a shell option as an
argument).
This context information is condensed into a string consisting of
multiple fields separated by colons, referred to simply as `the context'
in the remainder of the documentation. This is used to look up
em(styles), context-sensitive options that can be used to configure the
completion system. The context used for lookup may vary during the same
call to the completion system.
The context string always consists of a fixed set of fields, separated
by colons and with a leading colon before the first, in the form
tt(:completion:)var(function)tt(:)var(completer)tt(:)var(command)tt(:)var(argument)tt(:)tt(tag). These have the following meaning:
startitemize()
itemiz(\
The literal string tt(completion), saying that this style is used by
the completion system. This distinguishes the context from those used
by, for example, zle widgets and ZFTP functions.
)
itemiz(\
The var(function), if completion is called from a named widget rather
than through the normal completion system. Typically this is blank, but
it is set by special widgets such as tt(predict-on) and the various
functions in the tt(Widget) directory of the distribution to the name of
that function, often in an abbreviated form.
)
itemiz(\
The var(completer) currently active, the name of the function without the
leading underscore and with other underscores converted to hyphens. A
`completer' is in overall control of how completion is to be performed;
`tt(complete)' is the simplest, but other completers exist to perform
related tasks such as correction, or to modify the behaviour of a later
completer. See
ifzman(the section `Control Functions' below)\
ifnzman(noderef(Control Functions))
for more information.
)
itemiz(\
The var(command) or a special tt(-)var(context)tt(-), just at it appears
following the tt(#compdef) tag or the tt(compdef) function. Completion
functions for commands that have sub-commands usually modify this field
to contain the name of the command followed by a minus sign and the
sub-command. For example, the completion function for the tt(cvs)
command sets this field to tt(cvs-add) when completing arguments to
the tt(add) subcommand.
)
itemiz(\
The var(argument); this indicates which command line or option argument
we are completing. For command arguments this generally takes the form
tt(argument-)var(n), where var(n) is the number of the argument,
and for arguments to options the form tt(option-)var(opt)tt(-)var(n)
where var(n) is the number of the argument to option var(opt). However,
this is only the case if the command line is parsed with standard
UNIX-style options and arguments, so many completions do not set this.
)
itemiz(\
The var(tag). As described previously, tags are used to discriminate between
the types of matches a completion function can generate in a certain context.
Any completion function may use any tag name it likes, but a list of the
more common ones is given below.
)
enditemize()
The context is gradually put together as the functions are executed, starting
with the main entry point, which adds tt(:completion:) and the var(function)
element if necessary. The completer then adds the var(completer) element.
The contextual completion adds the var(command) and var(argument) options.
Finally, the var(tag) is added when the types of completion are known.
For example, the context name
example(tt(:completion::complete:dvips:option-o-1:files))
says that normal completion was attempted as the first argument to the
option tt(-o) of the command tt(dvips):
example(tt(dvips -o ...))
and the completion function will generate filenames.
Usually completion will be tried for all possible tags in an order given
by the completion function. However, this can be altered by using the
tt(tag-order) style. Completion is then restricted to the list of given
tags in the given order.
The tt(_complete_help) bindable command shows all the contexts and tags
available for completion at a particular point. This provides an easy
way of finding information for tt(tag-order) and other styles. It is
described in
ifzman(the section `Bindable Commands' below)\
ifnzman(noderef(Bindable Commands)).
Styles determine such things as how the matches are generated, similarly
to shell options but with much more control. They can have any number
of strings as their value. They are defined with the tt(zstyle) builtin
command (\
ifzman(see zmanref(zshmodules))\
ifnzman(noderef(The zsh/zutil Module))).
When looking up styles the completion system uses full context names,
including the tag. Looking up the value of a style therefore consists
of two things: the context, which may be matched as a pattern, and the
name of the style itself, which must be given exactly.
For example, many completion functions can generate matches in a
simple and a verbose form and use the tt(verbose) style to decide
which form should be used. To make all such functions use the verbose form,
put
example(zstyle ':completion:*' verbose yes)
in a startup file (probably tt(.zshrc)).
This gives the tt(verbose) style the value tt(yes) in every
context inside the completion system, unless that context has a more
specific definition. It is best to avoid giving the context as `tt(*)'
in case the style has some meaning outside the completion system.
Many such general purpose styles can be configured simply by using the
tt(compinstall) function.
A more specific example of the use of the tt(verbose) style is by the
completion for the tt(kill) builtin. If the style is set, the builtin
lists full job texts and process command lines; otherwise it shows the
bare job numbers and PIDs. To turn the style off for this use only:
example(zstyle ':completion:*:*:kill:*' verbose no)
For even more control, the style can use one of the tags `tt(jobs)' or
`tt(processes)'. To turn off verbose display only for jobs:
example(zstyle ':completion:*:*:kill:*:jobs' verbose no)
The tt(-e) option to tt(zstyle) even allows completion function code to
appear as the argument to a style; this requires some understanding of
the internals of completion functions (see
ifzman(see zmanref(zshcompwid))\
ifnzman(noderef(Completion Widgets)))\
). For example,
example(tt(zstyle -e ':completion:*' hosts 'reply=($myhosts)'))
This forces the value of the tt(hosts) style to be read from the
variable tt(myhosts) each time a host name is needed; this is useful
if the value of tt(myhosts) can change dynamically.
For another useful example, see the example in the description of the
tt(file-list) style below. This form can be
slow and should be avoided for commonly examined styles such
as tt(menu) and tt(list-rows-first).
Note that the order in which styles are em(defined) does not matter; the
style mechanism uses the most specific possible match for a particular
style to determine the set of values. More precisely, strings are
preferred over patterns (for example, `tt(:completion::complete:foo)' is
more specific than `tt(:completion::complete:*')), and longer patterns are
preferred over shorter patterns.
Style names like those of tags are arbitrary and depend on the completion
function. However, the following two sections list some of the most
common tags and styles.
subsect(Standard Tags)
cindex(completion system, tags)
Some of the following are only used when looking up particular styles
and do not refer to a type of match.
startitem()
kindex(accounts, completion tag)
item(tt(accounts))(
used to look up the tt(users-hosts) style
)
kindex(all-expansions, completion tag)
item(tt(all-expansions))(
used by the tt(_expand) completer when adding the single string containing
all possible expansions
)
kindex(all-files, completion tag)
item(tt(all-files))(
for the names of all files (as distinct from a particular subset, see the
tt(globbed-files) tag).
)
kindex(arguments, completion tag)
item(tt(arguments))(
for arguments to a command
)
kindex(arrays, completion tag)
item(tt(arrays))(
for names of array parameters
)
kindex(association-keys, completion tag)
item(tt(association-keys))(
for keys of associative arrays; used when completing inside a
subscript to a parameter of this type
)
kindex(bookmarks, completion tag)
item(tt(bookmarks))(
when completing bookmarks (e.g. for URLs and the tt(zftp) function suite)
)
kindex(builtins, completion tag)
item(tt(builtins))(
for names of builtin commands
)
kindex(characters, completion tag)
item(tt(characters))(
for single characters in arguments of commands such as tt(stty). Also used
when completing character classes after an opening bracket
)
kindex(colormapids, completion tag)
item(tt(colormapids))(
for X colormap ids
)
kindex(colors, completion tag)
item(tt(colors))(
for color names
)
kindex(commands, completion tag)
item(tt(commands))(
for names of external commands. Also used by complex commands such as
tt(cvs) when completing names subcommands.
)
kindex(contexts, completion tag)
item(tt(contexts))(
for contexts in arguments to the tt(zstyle) builtin command
)
kindex(corrections, completion tag)
item(tt(corrections))(
used by the tt(_approximate) and tt(_correct) completers for possible
corrections
)
kindex(cursors, completion tag)
item(tt(cursors))(
for cursor names used by X programs
)
kindex(default, completion tag)
item(tt(default))(
used in some contexts to provide a way of supplying a default when more
specific tags are also valid. Note that this tag is
used when only the var(function) field of the context name is set
)
kindex(descriptions, completion tag)
item(tt(descriptions))(
used when looking up the value of the tt(format) style to generate
descriptions for types of matches
)
kindex(devices, completion tag)
item(tt(devices))(
for names of device special files
)
kindex(directories, completion tag)
item(tt(directories))(
for names of directories
)
kindex(directory-stack, completion tag)
item(tt(directory-stack))(
for entries in the directory stack
)
kindex(displays, completion tag)
item(tt(displays))(
for X display names
)
kindex(domains, completion tag)
item(tt(domains))(
for network domains
)
kindex(expansions, completion tag)
item(tt(expansions))(
used by the tt(_expand) completer for individual words (as opposed to
the complete set of expansions) resulting from the expansion of a word
on the command line
)
kindex(extensions, completion tag)
item(tt(extensions))(
for X server extensions
)
kindex(file-descriptors, completion tag)
item(tt(file-descriptors))(
for numbers of open file descriptors
)
kindex(files, completion tag)
item(tt(files))(
the generic file-matching tag used by functions completing filenames
)
kindex(fonts, completion tag)
item(tt(fonts))(
for X font names
)
kindex(fstypes, completion tag)
item(tt(fstypes))(
for file system types (e.g. for the tt(mount) command)
)
kindex(functions, completion tag)
item(tt(functions))(
names of functions DASH()- normally shell functions, although certain
commands may understand other kinds of function
)
kindex(globbed-files, completion tag)
item(tt(globbed-files))(
for filenames when the name has been generated by pattern matching
)
kindex(groups, completion tag)
item(tt(groups))(
for names of user groups
)
kindex(history-words, completion tag)
item(tt(history-words))(
for words from the history
)
kindex(hosts, completion tag)
item(tt(hosts))(
for hostnames
)
kindex(indexes, completion tag)
item(tt(indexes))(
for array indexes
)
kindex(jobs, completion tag)
item(tt(jobs))(
for jobs (as listed by the `tt(jobs)' builtin)
)
kindex(interfaces, completion tag)
item(tt(interfaces))(
for network interfaces
)
kindex(keymaps, completion tag)
item(tt(keymaps))(
for names of zsh keymaps
)
kindex(keysyms, completion tag)
item(tt(keysyms))(
for names of X keysyms
)
kindex(libraries, completion tag)
item(tt(libraries))(
for names of system libraries
)
kindex(limits, completion tag)
item(tt(limits))(
for system limits
)
kindex(local-directories, completion tag)
item(tt(local-directories))(
for names of directories that are subdirectories of the current working
directory when completing arguments of tt(cd) and related builtin
commands (compare tt(path-directories))
)
kindex(manuals, completion tag)
item(tt(manuals))(
for names of manual pages
)
kindex(mailboxes, completion tag)
item(tt(mailboxes))(
for e-mail folders
)
kindex(maps, completion tag)
item(tt(maps))(
for map names (e.g. NIS maps)
)
kindex(messages, completion tag)
item(tt(messages))(
used to look up the tt(format) style for messages
)
kindex(modifiers, completion tag)
item(tt(modifiers))(
for names of X modifiers
)
kindex(modules, completion tag)
item(tt(modules))(
for modules (e.g. tt(zsh) modules)
)
kindex(my-accounts, completion tag)
item(tt(my-accounts))(
used to look up the tt(users-hosts) style
)
kindex(named-directories, completion tag)
item(tt(named-directories))(
for named directories (you wouldn't have guessed that, would you?)
)
kindex(names, completion tag)
item(tt(names))(
for all kinds of names
)
kindex(newsgroups, completion tag)
item(tt(newsgroups))(
for USENET groups
)
kindex(nicknames, completion tag)
item(tt(nicknames))(
for nicknames of NIS maps
)
kindex(options, completion tag)
item(tt(options))(
for command options
)
kindex(original, completion tag)
item(tt(original))(
used by the tt(_approximate), tt(_correct) and tt(_expand) completers when
offering the original string as a match
)
kindex(other-accounts, completion tag)
item(tt(other-accounts))(
used to look up the tt(users-hosts) style
)
kindex(packages, completion tag)
item(tt(packages))(
for packages (e.g. tt(rpm) or installed tt(Debian) packages)
)
kindex(parameters, completion tag)
item(tt(parameters))(
for names of parameters
)
kindex(path-directories, completion tag)
item(tt(path-directories))(
for names of directories found by searching the tt(cdpath) array when
completing arguments of tt(cd) and related builtin commands (compare
tt(local-directories))
)
kindex(paths, completion tag)
item(tt(paths))(
used to look up the values of the tt(expand), tt(ambiguous) and
tt(special-dirs) styles
)
kindex(pods, completion tag)
item(tt(pods))(
for perl pods (documentation files)
)
kindex(ports, completion tag)
item(tt(ports))(
for communication ports
)
kindex(prefixes, completion tag)
item(tt(prefixes))(
for prefixes (like those of a URL)
)
kindex(printers, completion tag)
item(tt(printers))(
for print queue names
)
kindex(processes, completion tag)
item(tt(processes))(
for process identifiers
)
kindex(processes-names, completion tag)
item(tt(processes-names))(
used to look up the tt(command) style when generating the names of
processes for tt(killall)
)
kindex(sequences, completion tag)
item(tt(sequences))(
for sequences (e.g. tt(mh) sequences)
)
kindex(sessions, completion tag)
item(tt(sessions))(
for sessions in the tt(zftp) function suite
)
kindex(signals, completion tag)
item(tt(signals))(
for signal names
)
kindex(strings, completion tag)
item(tt(strings))(
for strings (e.g. the replacement strings for the tt(cd) builtin
command)
)
kindex(styles, completion tag)
item(tt(styles))(
for styles used by the zstyle builtin command
)
kindex(suffixes, completion tag)
item(tt(suffixes))(
for filename extensions
)
kindex(tags, completion tag)
item(tt(tags))(
for tags (e.g. tt(rpm) tags)
)
kindex(targets, completion tag)
item(tt(targets))(
for makefile targets
)
kindex(time-zones, completion tag)
item(tt(time-zones))(
for time zones (e.g. when setting the tt(TZ) parameter)
)
kindex(types, completion tag)
item(tt(types))(
for types of whatever (e.g. address types for the tt(xhost) command)
)
kindex(urls, completion tag)
item(tt(urls))(
used to look up the tt(urls) and tt(local) styles when completing URLs
)
kindex(users, completion tag)
item(tt(users))(
for usernames
)
kindex(values, completion tag)
item(tt(values))(
for one of a set of values in certain lists
)
kindex(variant, completion tag)
item(tt(variant))(
used by tt(_pick_variant) to look up the command to run when determining
what program is installed for a particular command name.
)
kindex(visuals, completion tag)
item(tt(visuals))(
for X visuals
)
kindex(warnings, completion tag)
item(tt(warnings))(
used to look up the tt(format) style for warnings
)
kindex(widgets, completion tag)
item(tt(widgets))(
for zsh widget names
)
kindex(windows, completion tag)
item(tt(windows))(
for IDs of X windows
)
kindex(zsh-options, completion tag)
item(tt(zsh-options))(
for shell options
)
enditem()
subsect(Standard Styles)
cindex(completion system, styles)
Note that the values of several of these styles represent boolean
values. Any of the strings `tt(true)', `tt(on)',
`tt(yes)', and `tt(1)' can be used for the value `true' and
any of the strings `tt(false)', `tt(off)', `tt(no)', and `tt(0)' for
the value `false'. The behavior for any other value is undefined
except where explicitly mentioned. The default value may
be either true or false if the style is not set.
Some of these styles are tested first for every possible tag
corresponding to a type of match, and if no style was found, for the
tt(default) tag. The most notable styles of this type are tt(menu),
tt(list-colors) and styles controlling completion listing such as
tt(list-packed) and tt(last-prompt)). When tested for the tt(default)
tag, only the var(function) field of the context will be set so that
a style using the default tag will normally be defined along the lines of:
example(zstyle ':completion:*:default' menu ...)
startitem()
kindex(accept-exact, completion style)
item(tt(accept-exact))(
This is tested for the default tag in addition to the tags valid for
the current context. If it is set to `true' and any of the trial
matches is the same as the string on the command line, this match will
immediately be accepted (even if it would otherwise be considered
ambiguous).
When completing pathnames (where the tag used is `tt(paths)')
this style accepts any number of patterns as the value in addition to
the boolean values. Pathnames matching one of these
patterns will be accepted immediately even if the command line contains
some more partially typed pathname components and these match no file
under the directory accepted.
This style is also used by the tt(_expand) completer to decide if
words beginning with a tilde or parameter expansion should be
expanded. For example, if there are parameters
tt(foo) and tt(foobar), the string `tt($foo)' will only be expanded if
tt(accept-exact) is set to `true'; otherwise the completion system will
be allowed to complete tt($foo) to tt($foobar). If the style is set to
`continue', _expand will add the expansion as a match and the completion
system will also be allowed to continue.
)
kindex(add-space, completion style)
item(tt(add-space))(
This style is used by the tt(_expand) completer. If it is true (the
default), a space will be inserted after all words resulting from the
expansion, or a slash in the case of directory names. If the value
is `tt(file)', the completer will only add a space
to names of existing files. Either a boolean true or the value
`tt(file)' may be combined with `tt(subst)', in which case the completer
will not add a space to words generated from the expansion of a
substitution of the form `tt($LPAR()...RPAR())' or `tt(${...})'.
The tt(_prefix) completer uses this style as a simple boolean value
to decide if a space should be inserted before the suffix.
)
kindex(ambiguous, completion style)
item(tt(ambiguous))(
This applies when completing non-final components of filename paths, in
other words those with a trailing slash. If it is set, the cursor is
left after the first ambiguous component, even if menu completion is in
use. The style is always tested with the tt(paths) tag.
)
kindex(assign-list, completion style)
item(tt(assign-list))(
When completing after an equals sign that is being treated as an
assignment, the completion system normally completes only one filename.
In some cases the value may be a list of filenames separated by colons,
as with tt(PATH) and similar parameters. This style can be set to a
list of patterns matching the names of such parameters.
The default is to complete lists when the word on the line already
contains a colon.
)
kindex(auto-description, completion style)
item(tt(auto-description))(
If set, this style's value will be used as the description for options that
are not described by the completion functions, but that have exactly
one argument. The sequence `tt(%d)' in the value will be replaced by
the description for this argument. Depending on personal preferences,
it may be useful to set this style to something like `tt(specify: %d)'.
Note that this may not work for some commands.
)
kindex(avoid-completer, completion style)
item(tt(avoid-completer))(
This is used by the tt(_all_matches) completer to decide if the string
consisting of all matches should be added to the list currently being
generated. Its value is a list of names of completers. If any of
these is the name of the completer that generated the matches in this
completion, the string will not be added.
The default value for this style is `tt(_expand _old_list _correct
_approximate)', i.e. it contains the completers for which a string
with all matches will almost never be wanted.
)
kindex(cache-path, completion style)
item(tt(cache-path))(
This style defines the path where any cache files containing dumped
completion data are stored. It defaults to `tt($ZDOTDIR/.zcompcache)', or
`tt($HOME/.zcompcache)' if tt($ZDOTDIR) is not defined. The completion
cache will not be used unless the tt(use-cache) style is set.
)
kindex(cache-policy, completion style)
item(tt(cache-policy))(
This style defines the function that will be used to determine whether
a cache needs rebuilding. See the section on the tt(_cache_invalid)
function below.
)
kindex(call-command, completion style)
item(tt(call-command))(
This style is used in the function for commands such as tt(make) and
tt(ant) where calling the command directly to generate matches suffers
problems such as being slow or, as in the case of tt(make) can
potentially causes actions in the makefile to be executed. If it is set
to `true' the command is called to generate matches. The default value
of this style is `false'.
)
kindex(command, completion style)
item(tt(command))(
In many places, completion functions need to call external commands to
generate the list of completions. This style can be used to override the
command that is called in some such cases. The elements of the value are
joined with spaces to form a command line to execute. The value can also
start with a hyphen, in which case the usual command will be added to the
end; this is most useful for putting `tt(builtin)' or `tt(command)' in
front to make sure the appropriate version of a command is called, for
example to avoid calling a shell function with the same name as an external
command.
As an example, the completion function for process IDs uses this
style with the tt(processes) tag to generate the IDs to complete and
the list of processes to display (if the tt(verbose) style is `true').
The list produced by the command should look like the output of the
tt(ps) command. The first line is not displayed, but is searched for
the string `tt(PID)' (or `tt(pid)') to find the position of the
process IDs in the following lines. If the line does not contain
`tt(PID)', the first numbers in each of the other lines are taken as the
process IDs to complete.
Note that the completion function generally has to call the specified
command for each attempt to generate the completion list. Hence
care should be taken to specify only commands that take a short
time to run, and in particular to avoid any that may never terminate.
)
kindex(command-path, completion style)
item(tt(command-path))(
This is a list of directories to search for commands to complete. The
default for this style is the value of the special parameter tt(path).
)
kindex(commands, completion style)
item(tt(commands))(
This is used by the function completing sub-commands for the system
initialisation scripts (residing in tt(/etc/init.d) or somewhere not
too far away from that). Its values give the default commands to
complete for those commands for which the completion function isn't
able to find them out automatically. The default for this style are
the two strings `tt(start)' and `tt(stop)'.
)
kindex(complete, completion style)
item(tt(complete))(
This is used by the tt(_expand_alias) function when invoked as a
bindable command. If it set to `true' and the word on the command
line is not the name of an alias, matching alias names will be
completed.
)
kindex(completer, completion style)
item(tt(completer))(
The strings given as the value of this style provide the names of the
completer functions to use. The available completer functions are
described in
ifzman(the section `Control Functions' below)\
ifnzman(noderef(Control Functions))\
.
Each string may be either the name of a completer function or a string
of the form `var(function)tt(:)var(name)'. In the first case the
var(completer) field of the context will contain the name of the
completer without the leading underscore and with all other
underscores replaced by hyphens. In the second case the
var(function) is the name of the completer to call, but the context
will contain the user-defined var(name) in the var(completer) field of
the context. If the var(name) starts with a hyphen, the string for the
context will be build from the name of the completer function as in
the first case with the var(name) appended to it. For example:
example(zstyle ':completion:*' completer _complete _complete:-foo)
Here, completion will call the tt(_complete) completer twice, once
using `tt(complete)' and once using `tt(complete-foo)' in the
var(completer) field of the context. Normally, using the same
completer more than once only makes sense when used with the
`var(functions)tt(:)var(name)' form, because otherwise the context
name will be the same in all calls to the completer; possible
exceptions to this rule are the tt(_ignored) and tt(_prefix)
completers.
The default value for this style is `tt(_complete _ignored)':
only completion will be done, first using the tt(ignored-patterns) style
and the tt($fignore) array and then without ignoring matches.
)
kindex(condition, completion style)
item(tt(condition))(
This style is used by the tt(_list) completer function to decide if
insertion of matches should be delayed unconditionally. The default is
`true'.
)
kindex(disabled, completion style)
item(tt(disabled))(
If this is set to `true', the tt(_expand_alias) completer and bindable
command will try to expand disabled aliases, too. The default is
`tt(false)'.
)
kindex(disable-stat, completion style)
item(tt(disable-stat))(
This is used with an empty tag by the tt(_cvs) function
to decide whether the tt(zsh/stat) module should be used to
generate names of modified files in the appropriate places (this is its
only use). If the style is set, completion will use the tt(ls) command.
)
kindex(domains, completion style)
item(tt(domains))(
A list of names of network domains for completion.
If this is not set, domain names will be taken from
the file tt(/etc/resolv.conf).
)
kindex(expand, completion style)
item(tt(expand))(
This style is used when completing strings consisting of multiple
parts, such as path names.
If one of its values is the string `tt(prefix)', the partially typed
word from the line will be expanded as far as possible even if trailing
parts cannot be completed.
If one of its values is the string `tt(suffix)', matching names for
components after the first ambiguous one will also be added. This means
that the resulting string is the longest unambiguous string possible.
However, menu completion can be used to cycle through all matches.
)
kindex(fake, completion style)
item(tt(fake))(
This style may be set for any completion context. It
specifies additional strings that will always be completed in that
context. The form of each string is `var(value)tt(:)var(description)';
the colon and description may be omitted, but any literal colons in
var(value) must be quoted with a backslash. Any var(description)
provided is shown alongside the value in completion listings.
It is important to use a sufficiently restrictive context when specifying
fake strings. Note that the styles tt(fake-files) and tt(fake-parameters)
provide additional features when completing files or parameters.
)
kindex(fake-always, completion style)
item(tt(fake-always))(
This works identically to the tt(fake) style except that
the tt(ignored-patterns) style is not applied to it. This makes it
possible to override a set of matches completely by setting the
ignored patterns to `tt(*)'.
The following shows a way of supplementing any tag with arbitrary data, but
having it behave for display purposes like a separate tag. In this example
we use the features of the tt(tag-order) style to divide the
tt(named-directories) tag into two when performing completion with
the standard completer tt(complete) for arguments of tt(cd). The tag
tt(named-directories-normal) behaves as normal, but the tag
tt(named-directories-mine) contains a fixed set of directories.
This has the effect of adding the match group `tt(extra directories)' with
the given completions.
example(zstyle ':completion::complete:cd:*' tag-order \
'named-directories:-mine:extra\ directories
named-directories:-normal:named\ directories *'
zstyle ':completion::complete:cd:*:named-directories-mine' \
fake-always mydir1 mydir2
zstyle ':completion::complete:cd:*:named-directories-mine' \
ignored-patterns '*')
)
kindex(fake-files, completion style)
item(tt(fake-files))(
This style is used when completing files and looked up
without a tag. Its values are of the form
`var(dir)tt(:)var(names...)'. This will add the var(names) (strings
separated by spaces) as
possible matches when completing in the directory var(dir), even if no
such files really exist.
This can be useful on systems that support special filesystems whose
top-level pathnames can not be listed or generated with glob patterns.
It can also be used for directories for which one does not have read
permission.
)
kindex(fake-parameters, completion style)
item(tt(fake-parameters))(
This is used by the completion function for parameter names.
Its values are names of parameters that might not yet be
set but should be completed nonetheless. Each name may also be
followed by a colon and a string specifying the type of the parameter
(like `tt(scalar)', `tt(array)' or `tt(integer)'). If the type is
given, the name will only be completed if parameters of that type are
required in the particular context. Names for which no type is
specified will always be completed.
)
kindex(file-list, completion style)
item(tt(file-list))(
This style controls whether files completed using the standard builtin
mechanism are to be listed with a long list similar to tt(ls -l)
(although note that this feature actually uses the shell module
tt(zsh/stat) for file information; this loads the builtin tt(stat)
which will replace any external tt(stat) executable).
The style may either be set to a true value (or `tt(all)'), or
one of the values `tt(insert)' or `tt(list)', indicating that files
are to be listed in long format in all circumstances, or when
attempting to insert a file name, or when listing file names
without attempting to insert one.
More generally, the value may be an array of any of the above values,
optionally followed by tt(=)var(num). If var(num) is present it
gives the maximum number of matches for which long listing style
will be used. For example,
example(zstyle ':completion:*' file-list list=20 insert=10)
specifies that long format will be used when listing up to 20 files
or inserting a file with up to 10 matches (assuming a listing
is to be shown at all, for example on an ambiguous completion), else short
format will be used.
example(zstyle -e ':completion:*' file-list '(( ${+NUMERIC} )) && reply=(true)')
specifies that long format will be used any time a numeric argument is
supplied, else short format.
)
kindex(file-patterns, completion style)
item(tt(file-patterns))(
This is used by the standard function for completing filenames,
tt(_files). If the style is unset up to three tags are offered,
`tt(globbed-files)',`tt(directories)' and `tt(all-files)', depending on
the types of files expected by the caller of tt(_files). The first two
(`tt(globbed-files)' and `tt(directories)') are normally offered
together to make it easier to complete files in sub-directories.
The tt(file-patterns) style provides alternatives to the default tags,
which are not used. Its value consists of elements of the form
`var(pattern)tt(:)var(tag)'; each string may contain any number of
such specifications separated by spaces.
The var(pattern) is a pattern that is to be used to generate filenames.
Any occurrence of the sequence `tt(%p)' is replaced by any
pattern+LPAR()s+RPAR()
passed by the function calling tt(_files). Colons in the pattern must
be preceded by a backslash to make them distinguishable from the colon
before the var(tag). If more than one pattern is needed, the patterns
can be given inside braces, separated by commas.
The var(tag)s of all strings in the value will be offered by tt(_files)
and used when looking up other styles. Any var(tag)s in the same
word will be offered at the same time and before later words.
If no `tt(:)var(tag)' is given the `tt(files)' tag will be used.
The var(tag) may also be followed by an optional second colon and a
description, which will be used for the `tt(%d)' in the value of
the tt(format) style (if that is set) instead of the default
description supplied by the completion function. If the description
given here contains itself a `tt(%d)', that is replaced with the
description supplied by the completion function.
For example, to make the tt(rm) command first complete only names of
object files and then the names of all files if there is no matching
object file:
example(zstyle ':completion:*:*:rm:*' file-patterns \
'*.o:object-files' '%p:all-files')
To alter the default behaviour of file completion DASH()- offer files
matching a pattern and directories on the first attempt, then all files
DASH()- to offer only matching files on the first attempt, then directories,
and finally all files:
example(zstyle ':completion:*' file-patterns \
'%p:globbed-files' '*(-/):directories' '*:all-files')
This works even where there is no special pattern: tt(_files) matches
all files using the pattern `tt(*)' at the first step and stops when it
sees this pattern. Note also it will never try a pattern more than once
for a single completion attempt.
During the execution of completion functions, the tt(EXTENDED_GLOB)
option is in effect, so the characters `tt(#)', `tt(~)' and `tt(^)' have
special meanings in the patterns.
)
kindex(file-sort, completion style)
item(tt(file-sort))(
The standard filename completion function uses this style without a tag
to determine in which order the names should be listed; menu completion
will cycle through them in the same order. The possible
values are: `tt(size)' to sort by the size of the file;
`tt(links)' to sort by the number of links to the file;
`tt(modification)' (or `tt(time)' or `tt(date)') to sort by the last
modification time; `tt(access)' to sort by the last access time; and
`tt(inode)' (or `tt(change)') to sort by the last inode change
time. If the style is set to any other value, or is unset, files will be
sorted alphabetically by name. If the value contains the string
`tt(reverse)', sorting is done in the opposite order.
)
kindex(filter, completion style)
item(tt(filter))(
This is used by the LDAP plugin for e-mail address completion to specify
the attributes to match against when filtering entries. So for example, if
the style is set to `tt(sn)', matching is done against surnames. Standard
LDAP filtering is used so normal completion matching is bypassed. If this
style is not set, the LDAP plugin is skipped. You may also need to set the
tt(command) style to specify how to connect to your LDAP server.
)
kindex(force-list, completion style)
item(tt(force-list))(
This forces a list of completions to be shown at any point where listing is
done, even in cases where the list would usually be suppressed.
For example, normally the list is only shown if
there are at least two different matches. By setting this style to
`tt(always)', the list will always be shown, even if there is only a
single match that will immediately be accepted. The style may also
be set to a number. In this case the list will be shown if there are
at least that many matches, even if they would all insert the same
string.
This style is tested for the default tag as well as for each tag valid
for the current completion. Hence the listing can be forced only for
certain types of match.
)
kindex(format, completion style)
item(tt(format))(
If this is set for the tt(descriptions) tag, its value is used as a
string to display above matches in completion lists. The sequence
`tt(%d)' in this string will be replaced with a short description of
what these matches are. This string may also contain the sequences to
specify output attributes, such as `tt(%B)', `tt(%S)' and
`tt(%{)...tt(%})'.
The style is tested with each tag valid for the current completion
before it is tested for the tt(descriptions) tag. Hence different format
strings can be defined for different types of match.
Note also that some completer functions define additional
`tt(%)'-sequences. These are described for the completer functions that
make use of them.
Some completion functions display messages that may be customised by
setting this style for the tt(messages) tag. Here, the `tt(%d)' is
replaced with a message given by the completion function.
Finally, the format string is looked up with the tt(warnings) tag,
for use when no matches could be generated at all. In this case the
`tt(%d)' is replaced with the descriptions for the matches that were
expected separated by spaces. The sequence `tt(%D)' is replaced with
the same descriptions separated by newlines.
It is possible to use printf-style field width specifiers with `tt(%d)'
and similar escape sequences. This is handled by the tt(zformat)
builtin command from the tt(zsh/zutil) module, see
ifzman(zmanref(zshmodules))\
ifnzman(noderef(The zsh/zutil Module))\
.
)
kindex(glob, completion style)
item(tt(glob))(
This is used by the tt(_expand) completer. If
it is set to `true' (the default), globbing will be attempted on the
words resulting from a previous substitution (see the tt(substitute)
style) or else the original string from the line.
)
kindex(global, completion style)
item(tt(global))(
If this is set to `true' (the default), the tt(_expand_alias)
completer and bindable command will try to expand global aliases.
)
kindex(group-name, completion style)
item(tt(group-name))(
The completion system can group different types of matches, which appear
in separate lists. This style can be used to give the names of groups
for particular tags. For example, in command position the completion
system generates names of builtin and external commands, names of
aliases, shell functions and parameters and reserved words as possible
completions. To have the external commands and shell functions listed
separately:
example(zstyle ':completion:*:*:-command-:*:commands' group-name commands
zstyle ':completion:*:*:-command-:*:functions' group-name functions)
As a consequence, any match with the same tag will be displayed in the
same group.
If the name given is the empty string the name of the tag for
the matches will be used as the name of the group. So, to have all
different types of matches displayed separately, one can just set:
example(zstyle ':completion:*' group-name '')
All matches for which no group name is defined will be put in a group
named tt(-default-).
)
kindex(group-order, completion style)
item(tt(group-order))(
This style is additional to the tt(group-name) style to specify the
order for display of the groups defined by that style (compare tt(tag-order),
which determines which completions appear at all). The groups named
are shown in the given order; any other groups
are shown in the order defined by the completion function.
For example, to have names of builtin commands, shell functions and
external commands appear in that order when completing in command
position:
example(zstyle ':completion:*:*:-command-:*' group-order \
builtins functions commands)
)
kindex(groups, completion style)
item(tt(groups))(
A list of names of UNIX groups. If this is not set,
group names are taken from the YP database or the file `tt(/etc/group)'.
)
kindex(hidden, completion style)
item(tt(hidden))(
If this is set to true, matches for the given context
will not be listed, although
any description for the matches set with the tt(format) style will be
shown. If it is set to `tt(all)', not even the description will be
displayed.
Note that the matches will still be completed; they are just not shown
in the list. To avoid having matches considered as possible
completions at all, the tt(tag-order) style can be modified as described
below.
)
kindex(hosts, completion style)
item(tt(hosts))(
A list of names of hosts that should be completed. If this is not set,
hostnames are taken from the file `tt(/etc/hosts)'.
)
kindex(hosts-ports, completion style)
item(tt(hosts-ports))(
This style is used by commands that need or accept hostnames and
network ports. The strings in the value should be of the form
`var(host)tt(:)var(port)'. Valid ports are determined by the presence
of hostnames; multiple ports for the same host may appear.
)
kindex(ignore-line, completion style)
item(tt(ignore-line))(
This is tested for each tag valid for the current completion. If
it is set to `tt(true)', none of the words that are already on the line
will be considered as possible completions. If it is set to
`tt(current)', the word the cursor is on will not be considered as a
possible completion. The value `tt(current-shown)' is similar but only
applies if the list of completions is currently shown on the screen.
Finally, if the style is set to `tt(other)', no word apart from the
current one will be considered as a possible completion.
The values `tt(current)' and `tt(current-shown)' are a bit like the
opposite of the tt(accept-exact) style: only strings with
missing characters will be completed.
Note that you almost certainly don't want to set this to `true' or
`tt(other)' for a general
context such as `tt(:completion:*)'. This is because it would disallow
completion of, for example, options multiple times even if the command
in question accepts the option more than once.
)
kindex(ignore-parents, completion style)
item(tt(ignore-parents))(
The style is tested without a tag by the function completing pathnames
in order to determine whether to ignore
the names of directories already mentioned in the current word, or the
name of the current working directory. The value must include one or both
of the following strings:
startitem()
item(tt(parent))(
The name of any directory whose path is already contained in the word on
the line is ignored. For example, when completing after tt(foo/../), the
directory tt(foo) will not be considered a valid completion.
)
item(tt(pwd))(
The name of the current working directory will not be completed; hence,
for example, completion after tt(../) will not use the name of the current
directory.
)
enditem()
In addition, the value may include one or both of:
startitem()
item(tt(..))(
Ignore the specified directories only when the word on the line contains
the substring `tt(../)'.
)
item(tt(directory))(
Ignore the specified directories only when names of directories are
completed, not when completing names of files.
)
enditem()
Excluded values act in a similar fashion to values of the
tt(ignored-patterns) style, so they can be restored to consideration by
the tt(_ignored) completer.
)
kindex(ignored-patterns, completion style)
item(tt(ignored-patterns))(
A list of patterns; any trial completion matching one of the patterns
will be excluded from consideration. The
tt(_ignored) completer can appear in the list of completers to
restore the ignored matches. This is a more configurable
version of the shell parameter tt($fignore).
Note that the
tt(EXTENDED_GLOB) option is set during the execution of completion
functions, so the characters `tt(#)', `tt(~)' and `tt(^)' have special
meanings in the patterns.
)
kindex(insert, completion style)
item(tt(insert))(
This style is used by the tt(_all_matches) completer to decide whether to
insert the list of all matches unconditionally instead of adding the
list as another match.
)
kindex(insert-ids, completion style)
item(tt(insert-ids))(
When completing process IDs, for example as arguments to the tt(kill) and
tt(wait) builtins the name of a
command may be converted to the appropriate process ID. A problem
arises when the process name typed is not unique. By default (or if this
style is set explicitly to `tt(menu)') the name will be converted
immediately to a set of possible IDs, and menu completion will be started
to cycle through them.
If the value of the style is `tt(single)',
the shell will wait until the user has typed enough to make the command
unique before converting the name to an ID; attempts at completion will
be unsuccessful until that point. If the value is any other
string, menu completion will be started when the string typed by the
user is longer than the common prefix to the corresponding IDs.
)
kindex(insert-tab, completion style)
item(tt(insert-tab))(
If this is set to `true', the completion system will
insert a TAB character (assuming that was used to start completion) instead
of performing completion when there is no non-blank character to the left
of the cursor. If it is set to `false', completion will be done even there.
The value may also contain the substrings `tt(pending)' or
`tt(pending=)var(val)'. In this case, the typed character will be
inserted instead of staring completion when there is unprocessed input
pending. If a var(val) is given, completion will not be done if there
are at least that many characters of unprocessed input. This is often
useful when pasting characters into a terminal. Note
however, that it relies on the tt($PENDING) special parameter from the
tt(zsh/zle) module being set properly which is not guaranteed on all
platforms.
The default value of this style is `true' except for completion within
tt(vared) builtin command where it is `false'.
)
kindex(insert-unambiguous, completion style)
item(tt(insert-unambiguous))(
This is used by the tt(_match) and tt(_approximate) completers.
These completers are often used with menu completion since the word typed
may bear little resemblance to the final completion.
However, if this style is `true', the completer will start menu
completion only if it could find no unambiguous initial string at
least as long as the original string typed by the user.
In the case of the tt(_approximate) completer, the completer
field in the context will already have been set to one of
tt(correct-)var(num) or tt(approximate-)var(num), where var(num) is the
number of errors that were accepted.
In the case of the tt(_match) completer, the style may also be set to
the string `tt(pattern)'. Then the pattern on the line is left
unchanged if it does not match unambiguously.
)
kindex(keep-prefix, completion style)
item(tt(keep-prefix))(
This style is used by the tt(_expand) completer. If it is `true', the
completer will try to keep a prefix containing a tilde or parameter
expansion. Hence, for example, the string `tt(~/f*)' would be expanded to
`tt(~/foo)' instead of `tt(/home/user/foo)'. If the style is set to
`tt(changed)' (the default), the prefix will only be left unchanged if
there were other changes between the expanded words and the original
word from the command line. Any other value forces the prefix to be
expanded unconditionally.
The behaviour of expand when this style is true is to cause tt(_expand)
to give up when a single expansion with the restored prefix is the same
as the original; hence any remaining completers may be called.
)
kindex(last-prompt, completion style)
item(tt(last-prompt))(
This is a more flexible form of the tt(ALWAYS_LAST_PROMPT) option.
If it is true, the completion system will try to return the cursor to
the previous command line after displaying a completion list. It is
tested for all tags valid for the current completion, then the
tt(default) tag. The cursor will be moved back to the
previous line if this style is `true' for all types of match. Note
that unlike the tt(ALWAYS_LAST_PROMPT) option this is independent of the
numeric prefix argument.
)
kindex(known-hosts-files)
item(tt(known-hosts-files))(
This style should contain a list of files to search for host names and
(if the tt(use-ip) style is set) IP addresses in a format compatible with
ssh tt(known_hosts) files. If it is not set, the files
tt(/etc/ssh/ssh_known_hosts) and tt(~/.ssh/known_hosts) are used.
)
kindex(list, completion style)
item(tt(list))(
This style is used by the tt(_history_complete_word) bindable command.
If it is set to `true' it has no effect. If it is set to `false'
matches will not be listed. This overrides the setting of the options
controlling listing behaviour, in particular tt(AUTO_LIST). The context
always starts with `tt(:completion:history-words)'.
)
kindex(list-colors, completion style)
item(tt(list-colors))(
If the tt(zsh/complist) module is loaded, this style can be used to set
color specifications. This mechanism replaces the use of the
tt(ZLS_COLORS) and tt(ZLS_COLOURS) parameters described in
ifzman(the section `The zsh/complist Module' in zmanref(zshmodules))\
ifnzman(noderef(The zsh/complist Module))\
, but the syntax is the same.
If this style is set for the tt(default) tag, the strings in the value
are taken as specifications that are to be used everywhere. If it is
set for other tags, the specifications are used only for matches of
the type described by the tag. For this to work best, the tt(group-name)
style must be set to an empty string.
In addition to setting styles for specific tags, it is also possible to
use group names specified explicitly by the tt(group-name) tag together
with the `tt((group))' syntax allowed by the tt(ZLS_COLORS) and
tt(ZLS_COLOURS) parameters and simply using the tt(default) tag.
It is possible to use any color specifications already set up for the GNU
version of the tt(ls) command:
example(zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS})
The default colors are the same as for the GNU tt(ls) command and can be
obtained by setting the style to an empty string (i.e. tt('')).
)
kindex(list-grouped, completion style)
item(tt(list-grouped))(
If this style is `true' (the default), the completion system will try to
make certain completion listings more compact by grouping matches.
For example, options for commands that have the same description (shown
when the tt(verbose) style is set to `true') will appear as a single
entry. However, menu selection can be used to cycle through all the
matches.
)
kindex(list-packed, completion style)
item(tt(list-packed))(
This is tested for each tag valid in the current context as well as the
tt(default) tag. If it is set to `true', the corresponding matches
appear in listings as if the tt(LIST_PACKED) option were set. If it is
set to `false', they are listed normally.
)
kindex(list-prompt, completion style)
item(tt(list-prompt))(
If this style is set for the tt(default) tag,
completion lists that don't fit on the screen can be scrolled (see
ifzman(the description of the tt(zsh/complist) module in zmanref(zshmodules))\
ifnzman(noderef(The zsh/complist Module))\
). The value, if not the empty string, will be displayed after every
screenful and the shell will prompt for a key press; if the style is
set to the empty string,
a default prompt will be used.
The value may contain the escape sequences:
`tt(%l)' or `tt(%L)', which will be replaced by the number of the last line
displayed and the total number of lines; `tt(%m)' or `tt(%M)',
the number of the last match shown and the total number of
matches; and `tt(%p)' and `tt(%P)', `tt(Top)'
when at the beginning of the list, `tt(Bottom)' when at the end and the
position shown as a percentage of the total length otherwise. In each
case the form with the uppercase letter will be replaced by a string of fixed
width, padded to the right with spaces, while the lowercase form will
be replaced by a variable width string. As in other prompt strings, the
escape sequences `tt(%S)', `tt(%s)', `tt(%B)', `tt(%b)', `tt(%U)',
`tt(%u)' for entering and leaving the display modes
standout, bold and underline are also available, as is the form
`tt(%{)...tt(%})' for enclosing escape sequences which display with zero
width.
After deleting this prompt the variable tt(LISTPROMPT) should be unset for
the the removal to take effect.
)
kindex(list-rows-first, completion style)
item(tt(list-rows-first))(
This style is tested in the same way as the tt(list-packed) style and
determines whether matches are to be listed in a rows-first fashion as
if the tt(LIST_ROWS_FIRST) option were set.
)
kindex(list-suffixes, completion style)
item(tt(list-suffixes))(
This style is used by the function that completes filenames. If it is
true, and completion is attempted on a string containing multiple partially
typed pathname components, all ambiguous components will be shown.
Otherwise, completion stops at the first ambiguous component.
)
kindex(list-separator, completion style)
item(tt(list-separator))(
The value of this style is used in completion listing to separate the
string to complete from a description when possible (e.g. when
completing options). It defaults to `tt(-)tt(-)' (two hyphens).
)
kindex(local, completion style)
item(tt(local))(
This is for use with functions that complete URLs for which the
corresponding files are available directly from the filing system.
Its value should consist of three strings: a
hostname, the path to the default web pages for the server, and the
directory name used by a user placing web pages within their home
area.
For example:
example(zstyle ':completion:*' local toast \
/var/http/public/toast public_html)
Completion after `tt(http://toast/stuff/)' will look for files in the
directory tt(/var/http/public/toast/stuff), while completion after
`tt(http://toast/~yousir/)' will look for files in the directory
tt(~yousir/public_html).
)
kindex(mail-directory, completion style)
item(tt(mail-directory))(
If set, zsh will assume that mailbox files can be found in
the directory specified. It defaults to `tt(~/Mail)'.
)
kindex(match-original, completion style)
item(tt(match-original))(
This is used by the tt(_match) completer. If it is set to
tt(only), tt(_match) will try to generate matches without inserting a
`tt(*)' at the cursor position. If set to any other non-empty value,
it will first try to generate matches without inserting the `tt(*)'
and if that yields no matches, it will try again with the `tt(*)'
inserted. If it is unset or set to the empty string, matching will
only be performed with the `tt(*)' inserted.
)
kindex(matcher, completion style)
item(tt(matcher))(
This style is tested separately for each tag valid in the current
context. Its value is added to any match specifications given by the
tt(matcher-list) style. It should be in the form described in
ifzman(the section `Matching Control' in zmanref(zshcompwid))\
ifnzman(noderef(Matching Control))\
.
)
kindex(matcher-list, completion style)
item(tt(matcher-list))(
This style can be set to a list of match specifications that are to
be applied everywhere. Match specifications are described in
ifzman(the section `Matching Control' in zmanref(zshcompwid))\
ifnzman(noderef(Matching Control))\
.
The completion system will try them one after another for each completer
selected. For example, to try first simple completion and, if that
generates no matches, case-insensitive completion:
example(zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}')
By default each specification replaces the previous one; however, if a
specification is prefixed with tt(+), it is added to the existing list.
Hence it is possible to create increasingly general specifications
without repetition:
example(zstyle ':completion:*' matcher-list '' '+m{a-Z}={A-Z}' '+m{A-Z}={a-z}')
It is possible to create match specifications valid for particular
completers by using the third field of the context. For example, to
use the completers tt(_complete) and tt(_prefix) but only allow
case-insensitive completion with tt(_complete):
example(zstyle ':completion:*' completer _complete _prefix
zstyle ':completion:*:complete:*' matcher-list \
'' 'm:{a-zA-Z}={A-Za-z}')
User-defined names, as explained for the tt(completer) style, are
available. This makes it possible to try the same completer more than
once with different match specifications each time. For example, to try
normal completion without a match specification, then normal completion
with case-insensitive matching, then correction, and finally
partial-word completion:
example(zstyle ':completion:*' completer _complete _correct _complete:foo
zstyle ':completion:*:complete:*' matcher-list \
'' 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*:foo:*' matcher-list \
'm:{a-zA-Z}={A-Za-z} r:|[-_./]=* r:|=*')
If the style is unset in any context no match specification is applied.
Note also that some completers such as tt(_correct) and tt(_approximate)
do not use the match specifications at all, though these completers will
only ever called once even if the tt(matcher-list) contains more than
one element.
Where multiple specifications are useful, note that the em(entire)
completion is done for each element of tt(matcher-list), which can
quickly reduce the shell's performance. As a rough rule of thumb,
one to three strings will give acceptable performance. On the other
hand, putting multiple space-separated values into the same string does
not have an appreciable impact on performance.
)
kindex(max-errors, completion style)
item(tt(max-errors))(
This is used by the tt(_approximate) and tt(_correct) completer functions
to determine the maximum number of errors to allow. The completer will try
to generate completions by first allowing one error, then two errors, and
so on, until either a match or matches were found or the maximum number of
errors given by this style has been reached.
If the value for this style contains the string `tt(numeric)', the
completer function will take any numeric argument as the
maximum number of errors allowed. For example, with
example(zstyle ':completion:*:approximate:::' max-errors 2 numeric)
two errors are allowed if no numeric argument is given, but with
a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six
errors are accepted. Hence with a value of `tt(0 numeric)', no correcting
completion will be attempted unless a numeric argument is given.
If the value contains the string `tt(not-numeric)', the completer
will em(not) try to generate corrected
completions when given a numeric argument, so in this case the number given
should be greater than zero. For example, `tt(2 not-numeric)' specifies that
correcting completion with two errors will usually be performed, but if a
numeric argument is given, correcting completion will not be
performed.
The default value for this style is `tt(2 numeric)'.
)
kindex(max-matches-width, completion style)
item(tt(max-matches-width))(
This style is used to determine the trade off between the width of the
display used for matches and the width used for their descriptions when
the tt(verbose) style is in effect. The value gives the number of
display columns to reserve for the matches. The default is half the
width of the screen.
This has the most impact when several matches have the
same description and so will be grouped together. Increasing the style
will allow more matches to be grouped together; decreasing it will allow
more of the description to be visible.
)
kindex(menu, completion style)
item(tt(menu))(
If this is true in the context of any of the tags defined
for the current completion menu completion will be used. The value for
a specific tag will take precedence over that for the `tt(default)' tag.
If none of the values found in this way is true but at least
one is set to `tt(auto)', the shell behaves as if the tt(AUTO_MENU)
option is set.
If one of the values is explicitly set to false, menu
completion will be explicitly turned off, overriding the
tt(MENU_COMPLETE) option and other settings.
In the form `tt(yes=)var(num)', where `tt(yes)' may be any of the
true values (`tt(yes)', `tt(true)', `tt(on)' and `tt(1)'),
menu completion will be turned on if there are at least var(num) matches.
In the form `tt(yes=long)', menu completion will be turned on
if the list does not fit on the screen. This does not activate menu
completion if the widget normally only lists completions, but menu
completion can be activated in that case with the value `tt(yes=long-list)'
(Typically, the value `tt(select=long-list)' described later is more
useful as it provides control over scrolling.)
Similarly, with any of the `false' values (as in `tt(no=10)'), menu
completion will em(not) be used if there are var(num) or more matches.
The value of this widget also controls menu selection, as implemented by
the tt(zsh/complist) module. The following values may appear either
alongside or instead of the values above.
If the value contains the string `tt(select)', menu selection
will be started unconditionally.
In the form `tt(select=)var(num)', menu selection will only be started if
there are at least var(num) matches. If the values for more than one
tag provide a number, the smallest number is taken.
Menu selection can be turned off explicitly by defining a value
containing the string`tt(no-select)'.
It is also possible to start menu selection only if the list of
matches does not fit on the screen by using the value
`tt(select=long)'. To start menu selection even if the current widget
only performs listing, use the value `tt(select=long-list)'.
To turn on menu completion or menu selection when a there are a certain
number of matches em(or) the list of matches does not fit on the
screen, both of `tt(yes=)' and `tt(select=)' may be given twice, once
with a number and once with `tt(long)' or `tt(long-list)'.
Finally, it is possible to activate two special modes of menu selection.
The word `tt(interactive)' in the value causes interactive mode
to be entered immediately when menu selection is started; see
ifzman(the description of the tt(zsh/complist) module in zmanref(zshmodules))\
ifnzman(noderef(The zsh/complist Module))\
) for a description of interactive mode. Including the string
`tt(search)' does the same for incremental search mode. To select backward
incremental search, include the string `tt(search-backward)'.
)
kindex(muttrc, completion style)
item(tt(muttrc))(
If set, gives the location of the mutt configuration file. It defaults
to `tt(~/.muttrc)'.
)
kindex(numbers, completion style)
item(tt(numbers))(
This is used with the tt(jobs) tag. If it is `true', the shell will
complete job numbers instead of the shortest unambiguous prefix
of the job command text. If the value is a number, job numbers will
only be used if that many words from the job descriptions are required to
resolve ambiguities. For example, if the value is `tt(1)', strings will
only be used if all jobs differ in the first word on their command lines.
)
kindex(old-list, completion style)
item(tt(old-list))(
This is used by the tt(_oldlist) completer. If it is set to `tt(always)',
then standard widgets which perform listing will retain the current list of
matches, however they were generated; this can be turned off explicitly
with the value `tt(never)', giving the behaviour without the tt(_oldlist)
completer. If the style is unset, or any other value, then the existing
list of completions is displayed if it is not already; otherwise, the
standard completion list is generated; this is the default behaviour of
tt(_oldlist). However, if there is an old list and this style contains
the name of the completer function that generated the list, then the
old list will be used even if it was generated by a widget which does
not do listing.
For example, suppose you type tt(^Xc) to use the tt(_correct_word)
widget, which generates a list of corrections for the word under the
cursor. Usually, typing tt(^D) would generate a standard list of
completions for the word on the command line, and show that. With
tt(_oldlist), it will instead show the list of corrections already
generated.
As another example consider the tt(_match) completer: with the
tt(insert-unambiguous) style set to `true' it inserts only a common prefix
string, if there is any. However, this may remove parts of the original
pattern, so that further completion could produce more matches than on the
first attempt. By using the tt(_oldlist) completer and setting this style
to tt(_match), the list of matches generated on the first attempt will be
used again.
)
kindex(old-matches, completion style)
item(tt(old-matches))(
This is used by the tt(_all_matches) completer to decide if an old
list of matches should be used if one exists. This is selected by one of
the `true' values or by the string `tt(only)'. If
the value is `tt(only)', tt(_all_matches) will only use an old list
and won't have any effect on the list of matches currently being
generated.
If this style is set it is generally unwise to call the tt(_all_matches)
completer unconditionally. One possible use is for either this style or
the tt(completer) style to be defined with the tt(-e) option to
tt(zstyle) to make the style conditional.
)
kindex(old-menu, completion style)
item(tt(old-menu))(
This is used by the tt(_oldlist) completer. It controls how menu
completion behaves when a completion has already been inserted and the
user types a standard completion key such as tt(TAB). The default
behaviour of tt(_oldlist) is that menu completion always continues
with the existing list of completions. If this style is set to
`false', however, a new completion is started if the old list was
generated by a different completion command; this is the behaviour without
the tt(_oldlist) completer.
For example, suppose you type tt(^Xc) to generate a list of corrections,
and menu completion is started in one of the usual ways. Usually, or with
this style set to tt(false), typing tt(TAB) at this point would start
trying to complete the line as it now appears. With tt(_oldlist), it
instead continues to cycle through the list of corrections.
)
kindex(original, completion style)
item(tt(original))(
This is used by the tt(_approximate) and tt(_correct)
completers to decide if the original string should be added as
a possible completion. Normally, this is done only if there are
at least two possible corrections, but if this style is set to `true', it
is always added. Note that the style will be examined with the
completer field in the context name set to tt(correct-)var(num) or
tt(approximate-)var(num), where var(num) is the number of errors that
were accepted.
)
kindex(packageset, completion style)
item(tt(packageset))(
This style is used when completing arguments of the Debian `tt(dpkg)'
program. It contains an override for the default package set
for a given context. For example,
example(zstyle ':completion:*:complete:dpkg:option--status-1:*' \
packageset avail)
causes available packages, rather than only installed packages,
to be completed for `tt(dpkg -)tt(-status)'.
)
kindex(path, completion style)
item(tt(path))(
The function that completes color names uses this style with the
tt(colors) tag. The value should be the pathname of a file
containing color names in the format of an X11 tt(rgb.txt) file. If
the style is not set but this file is found in one of various standard
locations it will be used as the default.
)
kindex(pine-directory, completion style)
item(tt(pine-directory))(
If set, specifies the directory containing PINE mailbox files. There
is no default, since recursively searching this directory is inconvenient
for anyone who doesn't use PINE.
)
kindex(ports, completion style)
item(tt(ports))(
A list of Internet service names (network ports) to complete. If this is
not set, service names are taken from the file `tt(/etc/services)'.
)
kindex(prefix-hidden, completion style)
item(tt(prefix-hidden))(
This is used for certain completions which share a common prefix, for
example command options beginning with dashes. If it is `true', the
prefix will not be shown in the list of matches.
The default value for this style is `false'.
)
kindex(prefix-needed, completion style)
item(tt(prefix-needed))(
This, too, is used for matches with a common prefix. If it is set to
`true' this common prefix must be typed by the user to generate the
matches. In the case of command options, this means that the initial
`tt(-)', `tt(+)', or `tt(-)tt(-)' must be typed explicitly before option
names will be completed.
The default value for this style is `true'.
)
kindex(preserve-prefix, completion style)
item(tt(preserve-prefix))(
This style is used when completing path names. Its value should be a
pattern matching an initial prefix of the word to complete that should
be left unchanged under all circumstances. For example, on some Unices
an initial `tt(//)' (double slash) has a special meaning; setting
this style to the string `tt(//)' will preserve it. As another example,
setting this style to `tt(?:/)' under Cygwin would allow completion
after `tt(a:/...)' and so on.
)
kindex(range, completion style)
item(tt(range))(
This is used by the tt(_history) completer and the
tt(_history_complete_word) bindable command to decide which words
should be completed.
If it is a singe number, only the last var(N) words from the history
will be completed.
If it is a range of the form `var(max)tt(:)var(slice)',
the last var(slice) words will be completed; then if that
yields no matches, the var(slice) words before those will be tried and
so on. This process stops either when at least one match was been
found, or var(max) words have been tried.
The default is to complete all words from the history at once.
)
kindex(regular, completion style)
item(tt(regular))(
This style is used by the tt(_expand_alias) completer and bindable
command. If set to `tt(true)' (the default), regular aliases will be
expanded but only in command position. If it is set to `tt(false)',
regular aliases will never be expanded. If it is set to `tt(always)',
regular aliases will be expanded even if not in command position.
)
kindex(rehash, completion style)
item(tt(rehash))(
If this is set when completing external commands, the internal
list (hash) of commands will be updated for each search by issuing
the tt(rehash) command. There is a speed penalty for this which
is only likely to be noticeable when directories in the path have
slow file access.
)
kindex(remote-access, completion style)
item(tt(remote-access))(
If set to tt(false), certain commands will be prevented from making
Internet connections to retrieve remote information. This includes the
completion for the tt(CVS) command.
It is not always possible to know if connections are in fact to a remote
site, so some may be prevented unnecessarily.
)
kindex(remove-all-dups, completion style)
item(tt(remove-all-dups))(
The tt(_history_complete_word) bindable command and the tt(_history)
completer use this to decide if all duplicate matches should be
removed, rather than just consecutive duplicates.
)
kindex(select-prompt, completion style)
item(tt(select-prompt))(
If this is set for the tt(default) tag, its
value will be displayed during menu selection (see the tt(menu) style
above) when the completion list does not fit on the screen as a
whole. The same escapes as for the tt(list-prompt) style are
understood, except that the numbers refer to the match or line the mark is
on. A default prompt is used when the value is the empty string.
)
kindex(select-scroll, completion style)
item(tt(select-scroll))(
This style is tested for the tt(default) tag and determines how a
completion list is scrolled during a menu selection (see the tt(menu)
style above) when the completion list does not fit on the screen as a
whole. If the value is `tt(0)' (zero), the list is scrolled by
half-screenfuls; if it is a positive integer, the list is scrolled by the
given number of lines; if it is a negative number, the list is scrolled by a
screenful minus the absolute value of the given number of lines.
The default is to scroll by single lines.
)
kindex(separate-sections, completion style)
item(tt(separate-sections))(
This style is used with the tt(manuals) tag when completing names of
manual pages. If it is `true', entries for different sections are
added separately using tag names of the form `tt(manual.)var(X)',
where var(X) is the section number. When the tt(group-name) style is
also in effect, pages from different sections will appear separately.
This style is also used similarly with the tt(words) style when
completing words for the dict command. It allows words from different
dictionary databases to be added separately.
The default for this style is `false'.
)
kindex(show-completer, completion style)
item(tt(show-completer))(
Tested whenever a new completer is tried. If it is true, the completion
system outputs a progress message in the listing area showing what
completer is being tried. The message will be overwritten by any output
when completions are found and is removed after completion is finished.
)
kindex(single-ignored, completion style)
item(tt(single-ignored))(
This is used by the tt(_ignored) completer when there is only one match.
If its value is `tt(show)', the single match will be
displayed but not inserted. If the value is `tt(menu)', then the single
match and the original string are both added as matches and menu completion
is started, making it easy to select either of them.
)
kindex(sort, completion style)
item(tt(sort))(
Many completion widgets call tt(_description) at some point which
decides whether the matches are added sorted or unsorted (often
indirectly via tt(_wanted) or tt(_requested)). This style can be set
explicitly to one of the usual true or false values as an override.
If it is not set for the context, the standard behaviour of the
calling widget is used.
The style is tested first against the full context including the tag, and
if that fails to produce a value against the context without the tag.
If the calling widget explicitly requests unsorted matches, this is usually
honoured. However, the default (unsorted) behaviour of completion
for the command history may be overridden by setting the style to
tt(true).
In the tt(_expand) completer, if it is set to
`true', the expansions generated will always be sorted. If it is set
to `tt(menu)', then the expansions are only sorted when they are offered
as single strings but not in the string containing all possible
expansions.
)
kindex(special-dirs, completion style)
item(tt(special-dirs))(
Normally, the completion code will not produce the directory names
`tt(.)' and `tt(..)' as possible completions. If this style is set to
`true', it will add both `tt(.)' and `tt(..)' as possible completions;
if it is set to `tt(..)', only `tt(..)' will be added.
The following example sets tt(special-dirs) to `tt(..)' when the
current prefix is empty, is a single `tt(.)', or consists only of a path
beginning with `tt(../)'. Otherwise the value is `false'.
example(zstyle -e ':completion:*' special-dirs \
'[[ $PREFIX = LPAR()../RPAR()#LPAR()|.|..RPAR() ]] && reply=LPAR()..RPAR()')
)
kindex(squeeze-slashes, completion style)
item(tt(squeeze-slashes))(
If set to `true', sequences of slashes in filename paths (for example in
`tt(foo//bar)') will be treated as a single slash. This is the usual
behaviour of UNIX paths. However, by default the file completion
function behaves as if there were a `tt(*)' between the slashes.
)
kindex(stop, completion style)
item(tt(stop))(
If set to `true', the tt(_history_complete_word) bindable
command will stop once when reaching the beginning or end of the
history. Invoking tt(_history_complete_word) will then wrap around to
the opposite end of the history. If this style is set to `false' (the
default), tt(_history_complete_word) will loop immediately as in a
menu completion.
)
kindex(strip-comments, completion style)
item(tt(strip-comments))(
If set to `true', this style causes non-essential comment text to be
removed from completion matches. Currently it is only used when
completing e-mail addresses where it removes any display name from the
addresses, cutting them down to plain var(user@host) form.
)
kindex(subst-globs-only, completion style)
item(tt(subst-globs-only))(
This is used by the tt(_expand) completer. If it is set to `true',
the expansion will only be used if it resulted from globbing; hence,
if expansions resulted from the use of the tt(substitute) style
described below, but these were not further changed by globbing, the
expansions will be rejected.
The default for this style is `false'.
)
kindex(substitute, completion style)
item(tt(substitute))(
This boolean style controls whether the tt(_expand) completer will
first try to expand all substitutions in the string (such as
`tt($LPAR()...RPAR())' and `tt(${...})').
The default is `true'.
)
kindex(suffix, completion style)
item(tt(suffix))(
This is used by the tt(_expand) completer if the word starts with a
tilde or contains a parameter expansion. If it is set to `true', the
word will only be expanded if it doesn't have a suffix, i.e. if it is
something like `tt(~foo)' or `tt($foo)' rather than `tt(~foo/)' or
`tt($foo/bar)', unless that suffix itself contains characters eligible
for expansion. The default for this style is `true'.
)
kindex(tag-order, completion style)
item(tt(tag-order))(
This provides a mechanism for sorting how the tags available in a
particular context will be used.
The values for the style are sets of space-separated lists of tags.
The tags in each value will be tried at the same time; if no match is
found, the next value is used. (See the tt(file-patterns) style for
an exception to this behavior.)
For example:
example(zstyle ':completion:*:complete:-command-:*' tag-order \
'commands functions')
specifies that completion in command position first offers
external commands and shell functions. Remaining tags will be tried if
no completions are found.
In addition to tag names, each string in the value may take one of the
following forms:
startitem()
item(tt(-))(
If any value consists of only a hyphen,
then em(only) the tags specified in the other values are
generated. Normally all tags not explicitly selected are tried last
if the specified tags fail to generate any matches. This means
that a single value consisting only of a single hyphen
turns off completion.
)
item(tt(!) var(tags)...)(
A string starting with an exclamation mark
specifies names of tags that are em(not) to be used. The effect is
the same as if all other possible tags for the context had been
listed.
)
item(var(tag)tt(:)var(label) ...)(
Here, var(tag) is one of the standard tags and var(label) is an
arbitrary name. Matches are generated as normal but the name var(label)
is used in contexts instead of var(tag). This is not useful in words
starting with tt(!).
If the var(label) starts with a hyphen, the var(tag) is prepended to the
var(label) to form the name used for lookup. This can be
used to make the completion system try a certain tag more than once,
supplying different style settings for each attempt; see below for an
example.
)
item(var(tag)tt(:)var(label)tt(:)var(description))(
As before, but tt(description) will replace the `tt(%d)' in
the value of the tt(format) style instead of the default description
supplied by the completion function. Spaces in the description must
be quoted with a backslash. A `tt(%d)' appearing
in var(description) is replaced with the description given by the
completion function.
)
enditem()
In any of the forms above the tag may be a pattern or several
patterns in the form `tt({)var(pat1)tt(,)var(pat2...)tt(})'. In this
case all matching tags will be used except
for any given explicitly in the same string.
One use of these features is to try
one tag more than once, setting other styles differently on
each attempt, but still to use all the other tags without having to
repeat them all. For example, to make completion of function names in
command position ignore all the completion functions starting with an
underscore the first time completion is tried:
example(zstyle ':completion:*:*:-command-:*' tag-order \
'functions:-non-comp *' functions
zstyle ':completion:*:functions-non-comp' ignored-patterns '_*')
On the first attempt, all tags will be offered but the tt(functions) tag
will be replaced by tt(functions-non-comp). The tt(ignored-patterns) style
is set for this tag to exclude functions starting with an underscore.
If there are no matches, the second value of the
tt(tag-order) style is used which completes functions using the default
tag, this time presumably including all function names.
The matches for one tag can be split into different groups. For example:
example(zstyle ':completion:*' tag-order \
'options:-long:long\ options
options:-short:short\ options
options:-single-letter:single\ letter\ options'
zstyle ':completion:*:options-long' ignored-patterns '[-+](|-|[^-]*)'
zstyle ':completion:*:options-short' ignored-patterns '--*' '[-+]?'
zstyle ':completion:*:options-single-letter' ignored-patterns '???*')
With the tt(group-names) style set, options beginning with
`tt(-)tt(-)', options beginning with a single `tt(-)' or `tt(+)' but
containing multiple characters, and single-letter options will be
displayed in separate groups with different descriptions.
Another use of patterns is to
try multiple match specifications one after another. The
tt(matcher-list) style offers something similar, but it is tested very
early in the completion system and hence can't be set for single
commands nor for more specific contexts. Here is how to
try normal completion without any match specification and, if that
generates no matches, try again with case-insensitive matching, restricting
the effect to arguments of the command tt(foo):
example(zstyle ':completion:*:*:foo:*' tag-order '*' '*:-case'
zstyle ':completion:*-case' matcher 'm:{a-z}={A-Z}')
First, all the tags offered when completing after tt(foo) are tried using
the normal tag name. If that generates no matches, the second value of
tt(tag-order) is used, which tries all tags again except that this time
each has tt(-case) appended to its name for lookup of styles. Hence this
time the value for the tt(matcher) style from the second call to tt(zstyle)
in the example is used to make completion case-insensitive.
It is possible to use the tt(-e) option of the tt(zstyle) builtin
command to specify conditions for the use of particular tags. For
example:
example(zstyle -e '*:-command-:*' tag-order '
if [[ -n $PREFIX$SUFFIX ]]; then
reply=( )
else
reply=( - )
fi')
Completion in command position will be attempted only if the string
typed so far is not empty. This is tested using the tt(PREFIX)
special parameter; see
ifzman(zshcompwid)\
ifnzman(noderef(Completion Widgets))
for a description of parameters which are special inside completion widgets.
Setting tt(reply) to an empty array provides the default
behaviour of trying all tags at once; setting it to an
array containing only a hyphen disables the use of all tags and hence of
all completions.
If no tt(tag-order) style has been defined for a context, the strings
`tt((|*-)argument-* (|*-)option-* values)' and `tt(options)' plus all
tags offered by the completion function will be used to provide a
sensible default behavior that causes arguments (whether normal command
arguments or arguments of options) to be completed before option names for
most commands.
)
kindex(urls, completion style)
item(tt(urls))(
This is used together with the the tt(urls) tag by
functions completing URLs.
If the value consists of more than one string, or if the only string
does not name a file or directory, the strings are used as the URLs to
complete.
If the value contains only one string which is the name of a normal
file the URLs are taken from that file (where the URLs may be
separated by white space or newlines).
Finally, if the only string in the value names a directory, the
directory hierarchy rooted at this directory gives the completions. The
top level directory should be the file access method, such as
`tt(http)', `tt(ftp)', `tt(bookmark)' and so on. In many cases the next
level of directories will be a filename. The directory hierarchy can
descend as deep as necessary.
For example,
example(zstyle ':completion:*' urls ~/.urls
mkdir -p ~/.urls/ftp/ftp.zsh.org/pub/development
)
allows completion of all the components of the URL
tt(ftp://ftp.zsh.org/pub/development) after suitable commands such as
`tt(netscape)' or `tt(lynx)'. Note, however, that access methods and
files are completed separately, so if the tt(hosts) style is set hosts
can be completed without reference to the tt(urls) style.
See the description in the function tt(_urls) itself
for more information (e.g. `tt(more $^fpath/_urls+LPAR()N+RPAR())').
)
kindex(use-cache, completion style)
item(tt(use-cache))(
If this is set, the completion caching layer is activated for any completions
which use it (via the tt(_store_cache), tt(_retrieve_cache), and
tt(_cache_invalid) functions). The directory containing the cache
files can be changed with the tt(cache-path) style.
)
kindex(use-compctl, completion style)
item(tt(use-compctl))(
If this style is set to a string em(not) equal to tt(false), tt(0),
tt(no), and tt(off), the completion system may use any completion
specifications defined with the tt(compctl) builtin command. If the
style is unset, this is done only if the tt(zsh/compctl) module
is loaded. The string may also contain the substring `tt(first)' to
use completions defined with `tt(compctl -T)', and the substring
`tt(default)' to use the completion defined with `tt(compctl -D)'.
Note that this is only intended to smooth the transition from
tt(compctl) to the new completion system and may disappear in the
future.
Note also that the definitions from tt(compctl) will only be used if
there is no specific completion function for the command in question. For
example, if there is a function tt(_foo) to complete arguments to the
command tt(foo), tt(compctl) will never be invoked for tt(foo).
However, the tt(compctl) version will be tried if tt(foo) only uses
default completion.
)
kindex(use-ip, completion style)
item(tt(use-ip))(
By default, the function tt(_hosts) that completes host names strips
IP addresses from entries read from host databases such as NIS and
ssh files. If this style is true, the corresponding IP addresses
can be completed as well. This style is not use in any context
where the tt(hosts) style is set; note also it must be set before
the cache of host names is generated (typically the first completion
attempt).
)
kindex(use-perl, completion style)
item(tt(use-perl))(
Various parts of the function system use awk to extract words from
files or command output as this universally available. However, many
versions of awk have arbitrary limits on the size of input. If this
style is set, perl will be used instead. This is almost always
preferable if perl is available on your system.
Currently this is only used in completions for `make', but it may be
extended depending on authorial frustration.
)
kindex(users, completion style)
item(tt(users))(
This may be set to a list of usernames to be completed.
If it is not set or the string on the line
doesn't match any of the strings in this list, all usernames will be
completed.
)
kindex(users-hosts, completion style)
item(tt(users-hosts))(
The values of this style should be of the form
`var(user)tt(@)var(host)' or `var(user)tt(:)var(host)'. It is used for
commands that need pairs of
user- and hostnames. These commands will complete usernames from this
style (only), and will restrict subsequent hostname completion to hosts
paired with that user in one of the values of the style.
It is possible to group values for sets of commands which allow a remote
login, such as tt(rlogin) and tt(ssh), by using the tt(my-accounts) tag.
Similarly, values for sets of commands which usually refer to the
accounts of other people, such as tt(talk) and tt(finger), can be
grouped by using the tt(other-accounts) tag. More ambivalent commands
may use the tt(accounts) tag.
)
kindex(users-hosts-ports, completion style)
item(tt(users-hosts-ports))(
Like tt(users-hosts) but used for commands like tt(telnet) and
containing strings of the form `var(user)tt(@)var(host)tt(:)var(port)'.
)
kindex(verbose, completion style)
item(tt(verbose))(
If set, as it is by default, the completion listing is more verbose.
In particular many commands show descriptions for options if this
style is `true'.
)
kindex(word, completion style)
item(tt(word))(
This is used by the tt(_list) completer, which prevents the insertion of
completions until a second completion attempt when the line has not
changed. The normal way of finding out if the line has changed is to
compare its entire contents between the two occasions. If this style is
true, the comparison is instead performed only on the current word.
Hence if completion is performed on another word with the same contents,
completion will not be delayed.
)
enditem()
texinode(Control Functions)(Bindable Commands)(Completion System Configuration)(Completion System)
sect(Control Functions)
cindex(completion system, choosing completers)
The initialization script tt(compinit) redefines all the widgets
which perform completion to call the supplied widget function
tt(_main_complete). This function acts as a wrapper calling the
so-called `completer' functions that generate matches. If
tt(_main_complete) is called with arguments, these are taken as the
names of completer functions to be called in the order given. If no
arguments are given, the set of functions to try is taken from the
tt(completer) style. For example, to use normal completion and
correction if that doesn't generate any matches:
example(zstyle ':completion:*' completer _complete _correct)
after calling tt(compinit). The default value for this style is
`tt(_complete _ignored)', i.e. normally only ordinary completion is tried,
first with the effect of the tt(ignored-patterns) style and then without
it. The tt(_main_complete) function uses the return status of the completer
functions to decide if other completers should be called. If the return
status is zero, no other completers are tried and the tt(_main_complete)
function returns.
If the first argument to tt(_main_complete) is a single hyphen, the
arguments will not be taken as names of completers. Instead, the
second argument gives a name to use in the var(completer) field of the
context and the other arguments give a command name and arguments to
call to generate the matches.
The following completer functions are contained in the distribution,
although users may write their own. Note that in contexts the leading
underscore is stripped, for example basic completion is performed in the
context `tt(:completion::complete:)var(...)'.
cindex(completion system, completers)
startitem()
findex(_all_matches)
item(tt(_all_matches))(
This completer can be used to add a string consisting of all other
matches. As it influences later completers it must appear as the first
completer in the list. The list of all matches is affected by the
tt(avoid-completer) and tt(old-matches) styles described above.
It may be useful to use the tt(_generic) function described below
to bind tt(_all_matches) to its own keystroke, for example:
example(zle -C all-matches complete-word _generic
bindkey '^Xa' all-matches
zstyle ':completion:all-matches:*' old-matches only
zstyle ':completion:all-matches::::' completer _all_matches)
Note that this does not generate completions by itself. First use
any of the standard ways of generating a list of completions,
then use tt(^Xa) to show all matches.
)
findex(_approximate)
item(tt(_approximate))(
This is similar to the basic tt(_complete) completer but allows the
completions to undergo corrections. The maximum number of errors can be
specified by the tt(max-errors) style; see the description of
approximate matching in
ifzman(\
zmanref(zshexpn)
)\
ifnzman(\
noderef(Filename Generation)
)\
for how errors are counted. Normally this completer will only be tried
after the normal tt(_complete) completer:
example(zstyle ':completion:*' completer _complete _approximate)
This will give correcting completion if and only if
normal completion yields no possible completions. When
corrected completions are found, the completer will normally start
menu completion allowing you to cycle through these strings.
This completer uses the tags tt(corrections) and tt(original) when
generating the possible corrections and the original string. The
tt(format) style for the former may contain the additional sequences
`tt(%e)' and `tt(%o)' which will be replaced by the number of errors
accepted to generate the corrections and the original string,
respectively.
The completer progressively increases the number of errors allowed up to
the limit by the tt(max-errors) style, hence if a completion is found
with one error, no completions with two errors will be shown, and so on.
It modifies the completer name in the context to indicate the number of
errors being tried: on the first try the completer field contains
`tt(approximate-1)', on the second try `tt(approximate-2)', and so on.
When tt(_approximate) is called from another function, the number of
errors to accept may be passed with the tt(-a) option. The argument
is in the same format as the tt(max-errors) style, all in one string.
Note that this completer (and the tt(_correct) completer mentioned
below) can be quite expensive to call, especially when a large number
of errors are allowed. One way to avoid this is to set up the
tt(completer) style using the tt(-e) option to zstyle so that some
completers are only used when completion is attempted a second time on
the same string, e.g.:
example(zstyle -e ':completion:*' completer '
if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]]; then
_last_try="$HISTNO$BUFFER$CURSOR"
reply=(_complete _match _prefix)
else
reply=(_ignored _correct _approximate)
fi')
This uses the tt(HISTNO) parameter and the tt(BUFFER) and tt(CURSOR)
special parameters that are available inside zle and completion
widgets to find out if the command line hasn't changed since the last
time completion was tried. Only then are the tt(_ignored),
tt(_correct) and tt(_approximate) completers called.
)
findex(_complete)
item(tt(_complete))(
This completer generates all possible completions in a context-sensitive
manner, i.e. using the settings defined with the tt(compdef) function
explained above and the current settings of all special parameters.
This gives the normal completion behaviour.
To complete arguments of commands, tt(_complete) uses the utility function
tt(_normal), which is in turn responsible for finding the particular
function; it is described below. Various contexts of the form
tt(-)var(context)tt(-) are handled specifically. These are all
mentioned above as possible arguments to the tt(#compdef) tag.
Before trying to find a function for a specific context, tt(_complete)
checks if the parameter `tt(compcontext)' is set. Setting
`tt(compcontext)' allows the usual completion dispatching to be
overridden which is useful in places such as a function that uses
tt(vared) for input. If it is set to an array, the elements are taken
to be the possible matches which will be completed using the tag
`tt(values)' and the description `tt(value)'. If it is set to an
associative array, the keys are used as the possible completions and
the values (if non-empty) are used as descriptions for the matches. If
`tt(compcontext)' is set to a string containing colons, it should be of
the form `var(tag)tt(:)var(descr)tt(:)var(action)'. In this case the
var(tag) and var(descr) give the tag and description to use and the
var(action) indicates what should be completed in one of the forms
accepted by the tt(_arguments) utility function described below.
Finally, if `tt(compcontext)' is set to a string without colons, the
value is taken as the name of the context to use and the function
defined for that context will be called. For this purpose, there is a
special context named tt(-command-line-) that completes whole command
lines (commands and their arguments). This is not used by the completion
system itself but is nonetheless handled when explicitly called.
)
findex(_correct)
item(tt(_correct))(
Generate corrections, but not completions, for the current word; this is
similar to tt(_approximate) but will not allow any number of extra
characters at the cursor as that completer does. The effect is
similar to spell-checking. It is based on tt(_approximate), but the
completer field in the context name is tt(correct).
For example, with:
example(zstyle ':completion:::::' completer _complete _correct _approximate
zstyle ':completion:*:correct:::' max-errors 2 not-numeric
zstyle ':completion:*:approximate:::' max-errors 3 numeric)
correction will accept up to two errors. If a numeric argument is
given, correction will not be performed, but correcting completion
will be, and will accept as many errors as given by the numeric
argument. Without a numeric argument, first correction and then
correcting completion will be tried, with the first one accepting two
errors and the second one accepting three errors.
When tt(_correct) is called as a function, the number of errors to accept
may be given following the tt(-a) option. The argument is in the same
form a values to the tt(accept) style, all in one string.
This completer function is intended to be used without the
tt(_approximate) completer or, as in the example, just before
it. Using it after the tt(_approximate) completer is useless since
tt(_approximate) will at least generate the corrected strings
generated by the tt(_correct) completer DASH()- and probably more.
)
findex(_expand)
item(tt(_expand))(
This completer function does not really perform completion, but instead
checks if the word on the command line is eligible for expansion and,
if it is, gives detailed control over how this expansion is done. For
this to happen, the completion system needs to be invoked with
tt(complete-word), not tt(expand-or-complete) (the default binding for
tt(TAB)), as otherwise the string will be expanded by the shell's
internal mechanism before the completion system is started.
Note also this completer should be called before the tt(_complete)
completer function.
The tags used when generating expansions are tt(all-expansions) for the
string containing all possible expansions, tt(expansions) when adding
the possible expansions as single matches and tt(original) when adding
the original string from the line. The order in which these strings are
generated, if at all, can be controlled by the tt(group-order) and
tt(tag-order) styles, as usual.
The format string for tt(all-expansions) and for tt(expansions) may
contain the sequence `tt(%o)' which will be replaced by the original
string from the line.
The kind of expansion to be tried is controlled by the tt(substitute),
tt(glob) and tt(subst-globs-only) styles.
It is also possible to call tt(_expand) as a function, in which case the
different modes may be selected with options: tt(-s) for
tt(substitute), tt(-g) for tt(glob) and tt(-o) for tt(subst-globs-only).
)
findex(_expand_alias)
item(tt(_expand_alias))(
If the word the cursor is on is an alias, it is expanded and no other
completers are called. The types of aliases which are to be expanded can
be controlled with the styles tt(regular), tt(global) and tt(disabled).
This function is also a bindable command, see
ifzman(the section `Bindable Commands' below)\
ifnzman(noderef(Bindable Commands)).
)
findex(_history)
item(tt(_history))(
Complete words from the shell's command history. This completer
can be controlled by the tt(remove-all-dups), and tt(sort) styles as for the
tt(_history_complete_word) bindable command, see
ifzman(the section `Bindable Commands' below)\
ifnzman(noderef(Bindable Commands))
and
ifzman(the section `Completion System Configuration' above)\
ifnzman(noderef(Completion System Configuration)).
)
findex(_ignored)
item(tt(_ignored))(
The tt(ignored-patterns) style can be set to a list of patterns which are
compared against possible completions; matching ones are removed.
With this completer those matches can be reinstated, as
if no tt(ignored-patterns) style were set. The completer actually
generates its own list of matches; which completers are invoked
is determined in the same way as for the tt(_prefix) completer.
The tt(single-ignored) style is also available as described above.
)
findex(_list)
item(tt(_list))(
This completer allows the insertion of matches to be delayed until
completion is attempted a second time without the word on the line
being changed. On the first attempt, only the list of matches will be
shown. It is affected by the styles tt(condition) and tt(word), see
ifzman(the section `Completion System Configuration' above)\
ifnzman(noderef(Completion System Configuration)).
)
findex(_match)
item(tt(_match))(
This completer is intended to be used after the tt(_complete)
completer. It behaves similarly but the string on the command line may
be a pattern to match against trial completions. This gives the effect
of the tt(GLOB_COMPLETE) option.
Normally completion will be performed by taking the pattern from the line,
inserting a `tt(*)' at the cursor position and comparing the resulting
pattern with the possible completions generated. This can be modified
with the tt(match-original) style described above.
The generated matches will be offered in a menu completion unless the
tt(insert-unambiguous) style is set to `true'; see the description above
for other options for this style.
Note that matcher specifications defined globally or used by the
completion functions (the styles tt(matcher-list) and tt(matcher)) will
not be used.
)
findex(_menu)
item(tt(_menu))(
This completer was written as simple example function to show how menu
completion can be enabled in shell code. However, it has the notable
effect of disabling menu selection which can be useful with
tt(_generic) based widgets. It should be used as the first completer in
the list. Note that this is independent of the setting of the
tt(MENU_COMPLETE) option and does not work with the other menu
completion widgets such as tt(reverse-menu-complete), or
tt(accept-and-menu-complete).
)
findex(_oldlist)
item(tt(_oldlist))(
This completer controls how the standard completion widgets behave
when there is an existing list of completions which may have been
generated by a special completion (i.e. a separately-bound completion
command). It allows the ordinary completion keys to continue to use the
list of completions thus generated, instead of producing a new list of
ordinary contextual completions.
It should appear in the list of completers before any of
the widgets which generate matches. It uses two styles: tt(old-list) and
tt(old-menu), see
ifzman(the section `Completion System Configuration' above)\
ifnzman(noderef(Completion System Configuration)).
)
findex(_prefix)
item(tt(_prefix))(
This completer can be used to try completion with the suffix (everything
after the cursor) ignored. In other words, the suffix will not be
considered to be part of the word to complete. The effect is similar
to the tt(expand-or-complete-prefix) command.
The tt(completer) style is used to decide which other completers are to
be called to generate matches. If this style is unset, the list of
completers set for the current context is used DASH()- except, of course, the
tt(_prefix) completer itself. Furthermore, if this completer appears
more than once in the list of completers only those completers not
already tried by the last invocation of tt(_prefix) will be called.
For example, consider this global tt(completer) style:
example(zstyle ':completion:*' completer \
_complete _prefix _correct _prefix:foo)
Here, the tt(_prefix) completer tries normal completion but ignoring the
suffix. If that doesn't generate any matches, and neither does
the call to the tt(_correct) completer after it, tt(_prefix) will
be called a second time and, now only trying correction with the
suffix ignored. On the second invocation the completer part of the
context appears as `tt(foo)'.
To use tt(_prefix) as the last resort and try only normal completion
when it is invoked:
example(zstyle ':completion:*' completer _complete ... _prefix
zstyle ':completion::prefix:*' completer _complete)
The tt(add-space) style is also respected. If it is set to `true' then
tt(_prefix) will insert a space between the matches generated (if any)
and the suffix.
Note that this completer is only useful if the
tt(COMPLETE_IN_WORD) option is set; otherwise, the cursor will
be moved to the end of the current word before the completion code is
called and hence there will be no suffix.
)
findex(bashcompinit)
item(tt(bashcompinit))(
This function provides compatibility with bash's programmable completion
system. When run it will define the functions, tt(compgen) and
tt(complete) which correspond to the bash builtins with the same names.
It will then be possible to use completion specifications and functions
written for bash.
)
enditem()
texinode(Bindable Commands)(Completion Functions)(Control Functions)(Completion System)
sect(Bindable Commands)
cindex(completion system, bindable commands)
In addition to the context-dependent completions provided, which are
expected to work in an intuitively obvious way, there are a few widgets
implementing special behaviour which can be bound separately to keys. The
following is a list of these and their default bindings.
startitem()
findex(_bash_completions)
item(tt(_bash_completions))(
This function is used by two widgets, tt(_bash_complete-word) and
tt(_bash_list-choices). It exists to provide compatibility with
completion bindings in bash. The last character of the binding determines
what is completed: `tt(!)', command names; `tt($)', environment variables;
`tt(@)', host names; `tt(/)', file names; `tt(~)' user names. In bash, the
binding preceded by `tt(\e)' gives completion, and preceded by `tt(^X)'
lists options. As some of these bindings clash with standard zsh
bindings, only `tt(\e~)' and `tt(^X~)' are bound by default. To add the
rest, the following should be added to tt(.zshrc) after tt(compinit) has
been run:
example(for key in '!' '$' '@' '/' '~'; do
bindkey "\e$key" _bash_complete-word
bindkey "^X$key" _bash_list-choices
done)
This includes the bindings for `tt(~)' in case they were already bound to
something else; the completion code does not override user bindings.
)
findex(_correct_filename (^XC))
item(tt(_correct_filename (^XC)))(
Correct the filename path at the cursor position. Allows up to six errors
in the name. Can also be called with an argument to correct
a filename path, independently of zle; the correction is printed on
standard output.
)
findex(_correct_word) (^Xc)
item(tt(_correct_word) (^Xc))(
Performs correction of the current argument using the usual contextual
completions as possible choices. This stores the string
`tt(correct-word)' in the var(function) field of the context name and
then calls the tt(_correct) completer.
)
findex(_expand_alias (^Xa))
item(tt(_expand_alias (^Xa)))(
This function can be used as a completer and as a bindable command.
It expands the word the cursor is on if it is an alias. The types of
alias expanded can be controlled with the styles tt(regular), tt(global)
and tt(disabled).
When used as a bindable command there is one additional feature that
can be selected by setting the tt(complete) style to `true'. In this
case, if the word is not the name of an alias, tt(_expand_alias) tries
to complete the word to a full alias name without expanding it. It
leaves the cursor directly after the completed word so that invoking
tt(_expand_alias) once more will expand the now-complete alias name.
)
findex(_expand_word (^Xe))
item(tt(_expand_word (^Xe)))(
Performs expansion on the current word: equivalent to the standard
tt(expand-word) command, but using the tt(_expand) completer. Before
calling it, the var(function) field of the context is set to
`tt(expand-word)'.
)
findex(_generic)
item(tt(_generic))(
This function is not defined as a widget and not bound by
default. However, it can be used to define a widget and will then
store the name of the widget in the var(function) field of the context
and call the completion system. This allows custom completion widgets
with their own set of style settings to be defined easily. For example,
to define a widget that performs normal completion and starts
menu selection:
example(zle -C foo complete-word _generic
bindkey '...' foo
zstyle ':completion:foo:*' menu yes select=1)
Note in particular that the tt(completer) style may be set for the context
in order to change the set of functions used to generate possible matches.
If tt(_generic) is called with arguments, those are passed through to
tt(_main_complete) as the list of completers in place of those defined by
the tt(completer) style.
)
findex(_history_complete_word (\e/))
item(tt(_history_complete_word) (\e/))(
Complete words from the shell's command history. This uses the
tt(list), tt(remove-all-dups), tt(sort), and tt(stop) styles.
)
findex(_most_recent_file (^Xm))
item(tt(_most_recent_file (^Xm)))(
Complete the name of the most recently modified file matching the pattern
on the command line (which may be blank). If given a numeric argument
var(N), complete the var(N)th most recently modified file. Note the
completion, if any, is always unique.
)
findex(_next_tags (^Xn))
item(tt(_next_tags) (^Xn))(
This command alters the set of matches used to that for the next tag, or
set of tags, either as given by the tt(tag-order) style or as set by
default; these matches would otherwise not be available.
Successive invocations of the command cycle through all possible sets of
tags.
)
findex(_read_comp (^X^R))
item(tt(_read_comp (^X^R)))(
Prompt the user for a string, and use that to perform completion on the
current word. There are two possibilities for the string. First, it can
be a set of words beginning `tt(_)', for example `tt(_files -/)', in which
case the function with any arguments will be called to generate the
completions. Unambiguous parts of the function name will be completed
automatically (normal completion is not available at this point) until a
space is typed.
Second, any other string will be passed as a set of arguments to
tt(compadd) and should hence be an expression specifying what should
be completed.
A very restricted set of editing commands is available when reading the
string: `tt(DEL)' and `tt(^H)' delete the last character; `tt(^U)' deletes
the line, and `tt(^C)' and `tt(^G)' abort the function, while `tt(RET)'
accepts the completion. Note the string is used verbatim as a command
line, so arguments must be quoted in accordance with standard shell rules.
Once a string has been read, the next call to tt(_read_comp) will use the
existing string instead of reading a new one. To force a new string to be
read, call tt(_read_comp) with a numeric argument.
)
findex(_complete_debug (^X?))
item(tt(_complete_debug (^X?)))(
This widget performs ordinary completion, but captures in a temporary file
a trace of the shell commands executed by the completion system. Each
completion attempt gets its own file. A command to view each of these
files is pushed onto the editor buffer stack.
)
findex(_complete_help (^Xh))
item(tt(_complete_help (^Xh)))(
This widget displays information about the context names,
the tags, and the completion functions used
when completing at the current cursor position. If given a numeric
argument other than tt(1) (as in `tt(ESC-2 ^Xh)'), then the styles
used and the contexts for which they are used will be shown, too.
Note that the information about styles may be incomplete; it depends on the
information available from the completion functions called, which in turn
is determined by the user's own styles and other settings.
)
findex(_complete_tag (^Xt))
item(tt(_complete_tag (^Xt)))(
This widget completes symbol tags created by the tt(etags) or tt(ctags)
programmes (note there is no connection with the completion system's tags)
stored in a file tt(TAGS), in the format used by tt(etags), or tt(tags), in the
format created by tt(ctags). It will look back up the path hierarchy for
the first occurrence of either file; if both exist, the file tt(TAGS) is
preferred. You can specify the full path to a tt(TAGS) or tt(tags) file by
setting the parameter tt($TAGSFILE) or tt($tagsfile) respectively.
The corresponding completion tags used are tt(etags) and tt(vtags), after
emacs and vi respectively.
)
enditem()
texinode(Completion Functions)(Completion Directories)(Bindable Commands)(Completion System)
sect(Utility Functions)
cindex(completion system, utility functions)
Descriptions follow for utility functions that may be
useful when writing completion functions. If functions are installed in
subdirectories, most of these reside in the
tt(Base) subdirectory. Like the example
functions for commands in the distribution, the utility functions
generating matches all follow the convention of returning status zero if they
generated completions and non-zero if no matching completions could be
added.
Two more features are offered by the tt(_main_complete) function. The
arrays tt(compprefuncs) and tt(comppostfuncs) may contain
names of functions that are to be called immediately before or after
completion has been tried. A function will only be called once unless
it explicitly reinserts itself into the array.
startitem()
findex(_all_labels)
item(tt(_all_labels) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])(
This is a convenient interface to the tt(_next_label) function below,
implementing the loop shown in the tt(_next_label) example. The
var(command) and its arguments are called to generate the matches. The
options stored in the parameter var(name) will automatically be inserted
into the var(args) passed to the var(command). Normally, they are put
directly after the var(command), but if one of the var(args) is a single
hyphen, they are inserted directly before that. If the hyphen is the last
argument, it will be removed from the argument list before the
var(command) is called. This allows tt(_all_labels) to be used in almost all
cases where the matches can be generated by a single call to the
tt(compadd) builtin command or by a call to one of the utility functions.
For example:
example(local expl
...
if _requested foo; then
...
_all_labels foo expl '...' compadd ... - $matches
fi)
Will complete the strings from the tt(matches) parameter, using
tt(compadd) with additional options which will take precedence over
those generated by tt(_all_labels).
)
findex(_alternative)
item(tt(_alternative) [ tt(-C) var(name) ] var(spec) ...)(
This function is useful in simple cases where multiple tags are available.
Essentially it implements a loop like the one described for the tt(_tags)
function below.
The tags to use and the action to perform if a tag is requested are
described using the var(spec)s which are of the form:
`var(tag)tt(:)var(descr)tt(:)var(action)'. The var(tag)s are offered using
tt(_tags) and if the tag is requested, the var(action) is executed with the
given description var(descr). The var(action)s are those accepted
by the tt(_arguments) function (described below), excluding the
`tt(->)var(state)' and `tt(=)var(...)' forms.
For example, the var(action) may be a simple function call:
example(_alternative \
'users:user:_users' \
'hosts:host:_hosts')
offers usernames and hostnames as possible matches,
generated by the tt(_users) and tt(_hosts) functions respectively.
Like tt(_arguments), this functions uses tt(_all_labels) to execute
the actions, which will loop over all sets of tags. Special handling is
only required if there is an additional valid tag, for example inside a
function called from tt(_alternative).
Like tt(_tags) this function supports the tt(-C) option to give a
different name for the argument context field.
)
findex(_arguments)
item(tt(_arguments) [ tt(-nswWACRS) ] [ tt(-O) var(name) ] [ tt(-M) var(matchspec) ] [ tt(:) ] var(spec) ...)(
This function can be used to give a complete specification for
completion for a command whose arguments follow standard UNIX option and
argument conventions. The following forms specify individual sets of
options and arguments; to avoid ambiguity, these may be separated from the
options to tt(_arguments) itself by a single colon. Options to
tt(_arguments) itself must be in separate words, i.e. tt(-s -w), not
tt(-sw).
With the option tt(-n), tt(_arguments) sets the parameter tt(NORMARG)
to the position of the first normal argument in the tt($words) array,
i.e. the position after the end of the options. If that argument
has not been reached, tt(NORMARG) is set to tt(-1). The caller
should declare `tt(integer NORMARG)' if the tt(-n) option is passed;
otherwise the parameter is not used.
startitem()
xitem(var(n)tt(:)var(message)tt(:)var(action))
item(var(n)tt(::)var(message)tt(:)var(action))(
This describes the var(n)'th normal argument. The var(message) will be
printed above the matches generated and the var(action) indicates what can
be completed in this position (see below). If there are two colons
before the var(message) the argument is optional. If the
var(message) contains only white space, nothing will be printed above
the matches unless the action adds an explanation string itself.
)
xitem(tt(:)var(message)tt(:)var(action))
item(tt(::)var(message)tt(:)var(action))(
Similar, but describes the em(next) argument, whatever number that
happens to be. If all arguments are specified in this form in the
correct order the numbers are unnecessary.
)
xitem(tt(*:)var(message)tt(:)var(action))
xitem(tt(*::)var(message)tt(:)var(action))
item(tt(*:::)var(message)tt(:)var(action))(
This describes how arguments (usually non-option arguments, those not
beginning with tt(-) or tt(+)) are to be completed when neither
of the first two forms was provided. Any number of arguments can
be completed in this fashion.
With two colons before the var(message), the tt(words) special array and
the tt(CURRENT) special parameter are modified to refer only to the
normal arguments when the var(action) is executed or evaluated. With
three colons before the var(message) they are modified to refer only to
the normal arguments covered by this description.
)
xitem(var(optspec))
item(var(optspec):var(...))(
This describes an option. The colon indicates handling for one or more
arguments to the option; if it is not present, the option is assumed to
take no arguments.
By default, options are multi-character name, one `tt(-)var(word)' per
option. With tt(-s), options may be single characters, with more than
one option per word, although words starting with two hyphens, such as
`tt(-)tt(-prefix)', are still considered complete option names. This is
suitable for standard GNU options.
The combination of tt(-s) with tt(-w) allows single-letter options to be
combined in a single word even if one or more of the options take
arguments. For example, if tt(-a) takes an argument, with no
tt(-s) `tt(-ab)' is considered as a single (unhandled) option; with
tt(-s) tt(-ab) is an option with the argument `tt(b)'; with both tt(-s)
and tt(-w), tt(-ab) may be the option tt(-a) and the option tt(-b) with
arguments still to come.
The option tt(-W) takes this a stage further: it is possible to
complete single-letter options even after an argument that occurs in the
same word. However, it depends on the action performed whether options
will really be completed at this point. For more control, use a
utility function like tt(_guard) as part of the action.
The following forms are available for the initial var(optspec), whether
or not the option has arguments.
startitem()
item(tt(*)var(optspec))(
Here var(optspec) is one of the remaining forms below. This indicates
the following var(optspec) may be repeated. Otherwise if the
corresponding option is already present on the command line to the left
of the cursor it will not be offered again.
)
xitem(tt(-)var(optname))
item(tt(+)var(optname))(
In the simplest form the var(optspec) is just the option name beginning
with a minus or a plus sign, such as `tt(-foo)'. The first argument for
the option (if any) must follow as a em(separate) word directly after the
option.
Either of `tt(-+)var(optname)' and `tt(+-)var(optname)' can be used to
specify that tt(-)var(optname) and tt(+)var(optname) are both valid.
In all the remaining forms, the leading `tt(-)' may be replaced by or
paired with `tt(+)' in this way.
)
item(tt(-)var(optname)tt(-))(
The first argument of the option must come directly after the option name
em(in the same word). For example, `tt(-foo-:)var(...)' specifies that
the completed option and argument will look like `tt(-foo)var(arg)'.
)
item(tt(-)var(optname)tt(+))(
The first argument may appear immediately after var(optname) in the same
word, or may appear as a separate word after the option. For example,
`tt(-foo+:)var(...)' specifies that the completed option and argument
will look like either `tt(-foo)var(arg)' or `tt(-foo) var(arg)'.
)
item(tt(-)var(optname)tt(=))(
The argument may appear as the next word, or in same word as the option
name provided that it is separated from it by an equals sign, for
example `tt(-foo=)var(arg)' or `tt(-foo) var(arg)'.
)
item(tt(-)var(optname)tt(=-))(
The argument to the option must appear after an equals sign in the same
word, and may not be given in the next argument.
)
item(var(optspec)tt([)var(explanation)tt(]))(
An explanation string may be appended to any of the preceding forms of
var(optspec) by enclosing it in brackets, as in `tt(-q[query operation])'.
The tt(verbose) style is used to decide whether the explanation strings
are displayed with the option in a completion listing.
If no bracketed explanation string is given but the tt(auto-description)
style is set and only one argument is described for this var(optspec), the
value of the style is displayed, with any appearance of the sequence
`tt(%d)' in it replaced by the var(message) of the first var(optarg)
that follows the var(optspec); see below.
)
enditem()
It is possible for options with a literal `PLUS()' or `tt(=)' to
appear, but that character must be quoted, for example `tt(-\+)'.
Each var(optarg) following an var(optspec) must take one of the
following forms:
startitem()
xitem(tt(:)var(message)tt(:)var(action))
item(tt(::)var(message)tt(:)var(action))(
An argument to the option; var(message) and var(action) are treated as
for ordinary arguments. In the first form, the argument is mandatory,
and in the second form it is optional.
This group may be repeated for options which take multiple arguments.
In other words,
tt(:)var(message1)tt(:)var(action1)tt(:)var(message2)tt(:)var(action2)
specifies that the option takes two arguments.
)
xitem(tt(:*)var(pattern)tt(:)var(message)tt(:)var(action))
xitem(tt(:*)var(pattern)tt(::)var(message)tt(:)var(action))
item(tt(:*)var(pattern)tt(:::)var(message)tt(:)var(action))(
This describes multiple arguments. Only the last var(optarg) for
an option taking multiple arguments may be
given in this form. If the var(pattern) is empty (i.e., tt(:*:)), all
the remaining words on the line are to be completed as described by the
var(action); otherwise, all the words up to and including a word matching
the var(pattern) are to be completed using the var(action).
Multiple colons are treated as for the `tt(*:)var(...)' forms for
ordinary arguments: when the var(message) is preceded by two colons,
the tt(words) special array and the tt(CURRENT) special parameter are
modified during the execution or evaluation of the var(action) to refer
only to the words after the option. When preceded by three colons, they
are modified to refer only to the words covered by this description.
)
enditem()
)
enditem()
Any literal colon in an var(optname), var(message), or var(action)
must be preceded by a backslash, `tt(\:)'.
Each of the forms above may be preceded by a list in parentheses
of option names and argument numbers. If the given option is on
the command line, the options and arguments indicated in parentheses
will not be offered. For example,
`tt((-two -three 1)-one:...)' completes the option `tt(-one)'; if this
appears on the command line, the options tt(-two) and tt(-three) and the
first ordinary argument will not be completed after it.
`tt((-foo):)var(...)' specifies an ordinary argument completion;
tt(-foo) will not be completed if that argument is already present.
Other items may appear in the list of excluded options to indicate
various other items that should not be applied when the current
specification is matched: a single star (tt(*)) for the rest arguments
(i.e. a specification of the form `tt(*:...)'); a colon (tt(:))
for all normal (non-option-) arguments; and a hyphen (tt(-)) for all
options. For example, if `tt((*))' appears before an option and the
option appears on the command line, the list of remaining arguments
(those shown in the above table beginning with `tt(*:)') will not be
completed.
To aid in reuse of specifications, it is possible to precede any of the
forms above with `tt(!)'; then the form will no longer be completed,
although if the option or argument appears on the command line they will
be skipped as normal. The main use for this is when the arguments are
given by an array, and tt(_arguments) is called repeatedly for more
specific contexts: on the first call `tt(_arguments $global_options)' is
used, and on subsequent calls `tt(_arguments !$^global_options)'.
In each of the forms above the var(action) determines how
completions should be generated. Except for the `tt(->)var(string)'
form below, the var(action) will be executed by calling the
tt(_all_labels) function to process all tag labels. No special handling
of tags is needed unless a function call introduces a new one.
The forms for var(action) are as follows.
startitem()
item(tt( ) (single unquoted space))(
This is useful where an argument is required but it is not possible or
desirable to generate matches for it. The
var(message) will be displayed but no completions listed. Note
that even in this case the colon at the end of the var(message) is
needed; it may only be omitted when neither a var(message)
nor an var(action) is given.
)
item(tt(LPAR())var(item1) var(item2) var(...)tt(RPAR()))(
One of a list of possible matches, for example:
example(tt(:foo:LPAR()foo bar baz)tt(RPAR()))
)
item(tt(((var(item1)\:var(desc1) var(...)))))(
Similar to the above, but with descriptions for each possible match.
Note the backslash before the colon. For example,
example(tt(:foo:LPAR()LPAR()a\:bar b\:baz)tt(RPAR()RPAR()))
The matches will be listed together with their descriptions if the
tt(description) style is set with the tt(values) tag in the context.
)
item(tt(->)var(string))(
vindex(context, use of)
vindex(line, use of)
vindex(opt_args, use of)
In this form, tt(_arguments) processes the arguments and options and then
returns control to the calling function with parameters set to indicate the
state of processing; the calling function then makes its own arrangements
for generating completions. For example, functions that implement a state
machine can use this type of action.
Where tt(_arguments) encounters a `tt(->)var(string)', it will strip
all leading and trailing whitespace from var(string) and set the array
tt(state) to the set of all var(strings)s for which an action is to be
performed.
By default and in common with all other well behaved completion
functions, _arguments returns status zero if it was able to add matches and
non-zero otherwise. However, if the tt(-R) option is given,
tt(_arguments) will instead return a status of 300 to indicate that
tt($state) is to be handled.
In addition to tt($state), tt(_arguments) also sets the global
parameters `tt(context)', `tt(line)' and `tt(opt_args)' as described
below, and does not reset any changes made to the special parameters
such as tt(PREFIX) and tt(words). This gives the calling function the
choice of resetting these parameters or propagating changes in them.
A function calling tt(_arguments) with at least
one action containing a `tt(->)var(string)' therefore must declare
appropriate local parameters:
example(local context state line
typeset -A opt_args)
to avoid tt(_arguments) from altering the global environment.
)
item(tt({)var(eval-string)tt(}))(
vindex(expl, use of)
A string in braces is evaluated as shell code to generate matches. If the
var(eval-string) itself does not begin with an opening parenthesis or
brace it is split into separate words before execution.
)
item(tt(= )var(action))(
If the var(action) starts with `tt(= )' (an equals sign followed by a
space), tt(_arguments) will insert the contents of the var(argument)
field of the current context as the new first element in the tt(words)
special array and increment the value of the tt(CURRENT) special
parameter. This has the effect of inserting a dummy word onto the
completion command line while not changing the point at which completion is
taking place.
This is most useful with one of the specifiers that restrict the words on
the command line on which the var(action) is to operate (the two- and
three-colon forms above). One particular use is when an var(action) itself
causes tt(_arguments) on a restricted range; it is necessary to use this
trick to insert an appropriate command name into the range for the second
call to tt(_arguments) to be able to parse the line.
)
xitem( var(word...))
item(var(word...))(
This covers all forms other than those above. If the var(action)
starts with a space, the remaining list of words will be invoked unchanged.
Otherwise it will be invoked with some extra strings placed after the
first word; these are to be passed down as options to the tt(compadd)
builtin. They ensure that the state specified by tt(_arguments), in
particular the descriptions of options and arguments, is correctly passed
to the completion command. These additional arguments
are taken from the array parameter `tt(expl)'; this will be set up
before executing the var(action) and hence may be referred to inside it,
typically in an expansion of the form `tt($expl[@])' which preserves empty
elements of the array.
)
enditem()
During the performance of the action the array `tt(line)'
will be set to the command name and normal arguments from the command
line, i.e. the words from the command line excluding all options
and their arguments. Options are stored in the associative array
`tt(opt_args)' with option names as keys and their arguments as
the values. For options that have more than one argument these are
given as one string, separated by colons. All colons in the original
arguments are preceded with backslashes.
The parameter `tt(context)' is set when returning to the calling function
to perform an action of the form `tt(->)var(string)'. It is set to an
array of elements corresponding to the elements of tt($state). Each
element is a suitable name for the argument field of the context: either a
string of the form `tt(option)var(-opt)tt(-)var(n)' for the var(n)'th
argument of the option var(-opt), or a string of the form
`tt(argument-)var(n)' for the var(n)'th argument. For `rest' arguments,
that is those in the list at the end not handled by position, var(n) is the
string `tt(rest)'. For example, when completing the argument of the tt(-o)
option, the name is `tt(option-o-1)', while for the second normal
(non-option-) argument it is `tt(argument-2)'.
Furthermore, during the evaluation of the var(action) the context name in
the tt(curcontext) parameter is altered to append the same string that is
stored in the tt(context) parameter.
It is possible to specify multiple sets of options and
arguments with the sets separated by single hyphens. The specifications
before the first hyphen (if any) are shared by all the remaining sets.
The first word in every other set provides a name for the
set which may appear in exclusion lists in specifications,
either alone or before one of the possible values described above.
In the second case a `tt(-)' should appear between this name and the
remainder.
For example:
example(_arguments \
-a \
- set1 \
-c \
- set2 \
-d \
':arg:(x2 y2)')
This defines two sets. When the command line contains the option
`tt(-c)', the `tt(-d)' option and the argument will not be considered
possible completions. When it contains `tt(-d)' or an argument, the
option `tt(-c)' will not be considered. However, after `tt(-a)'
both sets will still be considered valid.
If the name given for one of the mutually exclusive sets is of the form
`tt(LPAR())var(name)tt(RPAR())' then only one value from each set will ever
be completed; more formally, all specifications are mutually
exclusive to all other specifications in the same set. This is
useful for defining multiple sets of options which are mutually
exclusive and in which the options are aliases for each other. For
example:
example(_arguments \
-a -b \
- '(compress)' \
{-c,--compress}'[compress]' \
- '(uncompress)' \
{-d,--decompress}'[decompress]')
As the completion code has to parse the command line separately for each
set this form of argument is slow and should only be used when necessary.
A useful alternative is often an option specification with rest-arguments
(as in `tt(-foo:*:...)'); here the option tt(-foo) swallows up all
remaining arguments as described by the var(optarg) definitions.
The options tt(-S) and tt(-A) are available to simplify the specifications
for commands with standard option parsing. With tt(-S), no option will be
completed after a `tt(-)tt(-)' appearing on its own on the line; this
argument will otherwise be ignored; hence in the line
example(foobar -a -- -b)
the `tt(-a)' is considered an option but the `tt(-b)' is considered an
argument, while the `tt(-)tt(-)' is considered to be neither.
With tt(-A), no options will be completed after the first non-option
argument on the line. The tt(-A) must be followed by a pattern matching
all strings which are not to be taken as arguments. For example, to make
tt(_arguments) stop completing options after the first normal argument, but
ignoring all strings starting with a hyphen even if they are not described
by one of the var(optspec)s, the form is `tt(-A "-*")'.
The option `tt(-O) var(name)' specifies the name of an array whose elements
will be passed as arguments to functions called to execute var(actions).
For example, this can be used to pass the same set of options for the
tt(compadd) builtin to all var(action)s.
The option `tt(-M) var(spec)' sets a match specification to use to
completion option names and values. It must appear before the first
argument specification. The default is `tt(r:|[_-]=* r:|=*)': this allows
partial word completion after `tt(_)' and `tt(-)', for example `-f-b'
can be completed to `tt(-foo-bar)'.
The option tt(-C) tells tt(_arguments) to modify
the tt(curcontext) parameter for an action of the form
`tt(->)var(state)'. This is the standard parameter used to keep track of
the current context. Here it (and not the tt(context) array) should be
made local to the calling function
to avoid passing back the modified value and should be initialised to the
current value at the start of the function:
example(local curcontext="$curcontext")
This is useful where it is not possible for multiple states to be valid
together.
The option `tt(-)tt(-)' allows tt(_arguments) to work out the names of long
options that support the `tt(-)tt(-help)' option which is standard in many
GNU commands. The command word is called with the argument
`tt(-)tt(-help)' and the output examined for option names. Clearly, it can
be dangerous to pass this to commands which may not support this option as
the behaviour of the command is unspecified.
In addition to options, `tt(_arguments -)tt(-)' will try to deduce the
types of arguments available for options when the form
`tt(-)tt(-)var(opt)=var(val)' is valid. It is also possible to provide
hints by examining the help text of the command and adding specifiers of
the form `var(pattern)tt(:)var(message)tt(:)var(action)'; note that normal
tt(_arguments) specifiers are not used. The var(pattern) is matched
against the help text for an option, and if it matches the var(message) and
var(action) are used as for other argument specifiers. For example:
example(_arguments -- '*\*:toggle:(yes no)' \
'*=FILE*:file:_files' \
'*=DIR*:directory:_files -/' \
'*=PATH*:directory:_files -/')
Here, `tt(yes)' and `tt(no)' will be completed as the argument of
options whose description ends in a star; file names will be completed for
options that contain the substring `tt(=FILE)' in the description; and
directories will be completed for options whose description contains
`tt(=DIR)' or `tt(=PATH)'. The last three are in fact the default and so
need not be given explicitly, although it is possible to override the use
of these patterns. A typical help text which uses this feature is:
example( -C, --directory=DIR change to directory DIR)
so that the above specifications will cause directories to be completed
after `tt(-)tt(-directory)', though not after `tt(-C)'.
Note also that tt(_arguments) tries to find out automatically if the
argument for an option is optional. This can be specified explicitly by
doubling the colon before the var(message).
If the var(pattern) ends in `tt((-))', this will removed from the
pattern and the var(action) will be used only directly after the
`tt(=)', not in the next word. This is the behaviour of a normal
specification defined with the form `tt(=-)'.
The `tt(_arguments -)tt(-)' can be followed by the option `tt(-i)
var(patterns)' to give patterns for options which are not to be
completed. The patterns can be given as the name of an array parameter
or as a literal list in parentheses. For example,
example(_arguments -- -i \
"LPAR()-tt(-(en|dis)able-FEATURE*RPAR()"))
will cause completion to ignore the options
`tt(-)tt(-enable-FEATURE)' and `tt(-)tt(-disable-FEATURE)' (this example is
useful with GNU tt(configure)).
The `tt(_arguments -)tt(-)' form can also be followed by the option `tt(-s)
var(pair)' to describe option aliases. Each var(pair) consists of a
pattern and a replacement. For example, some tt(configure)-scripts
describe options only as `tt(-)tt(-enable-foo)', but also accept
`tt(-)tt(-disable-foo)'. To allow completion of the second form:
example(_arguments -- -s "LPAR()#-tt(-enable- -)tt(-disable-RPAR()"))
Here is a more general example of the use of tt(_arguments):
example(_arguments '-l+:left border:' \
'-format:paper size:(letter A4)' \
'*-copy:output file:_files::resolution:(300 600)' \
':postscript file:_files -g \*.\(ps\|eps\)' \
'*:page number:')
This describes three options: `tt(-l)', `tt(-format)', and
`tt(-copy)'. The first takes one argument described as `var(left
border)' for which no completion will be offered because of the empty
action. Its argument may come directly after the `tt(-l)' or it may be
given as the next word on the line.
The `tt(-format)' option takes one
argument in the next word, described as `var(paper size)' for which
only the strings `tt(letter)' and `tt(A4)' will be completed.
The `tt(-copy)' option may appear more than once on the command line and
takes two arguments. The first is mandatory and will be completed as a
filename. The second is optional (because of the second colon before
the description `var(resolution)') and will be completed from the strings
`tt(300)' and `tt(600)'.
The last two descriptions say what should be completed as
arguments. The first describes the first argument as a
`var(postscript file)' and makes files ending in `tt(ps)' or `tt(eps)'
be completed. The last description gives all other arguments the
description `var(page numbers)' but does not offer completions.
)
findex(_cache_invalid)
item(tt(_cache_invalid) var(cache_identifier))(
This function returns status zero if the completions cache corresponding to
the given cache identifier needs rebuilding. It determines this by
looking up the tt(cache-policy) style for the current context.
This should provide a function name which is run with the full path to the
relevant cache file as the only argument.
Example:
example(_example_caching_policy () {
# rebuild if cache is more than a week old
oldp=( "$1"(Nmw+1) )
(( $#oldp ))
})
)
findex(_call_function)
item(tt(_call_function) var(return) var(name) [ var(args) ... ])(
If a function var(name) exists, it is called with the arguments
var(args). The var(return) argument gives the name of a parameter in which
the return status from the function var(name); if var(return) is empty or a
single hyphen it is ignored.
The return status of tt(_call_function) itself is zero if the function
var(name) exists and was called and non-zero otherwise.
)
findex(_call_program)
item(tt(_call_program) var(tag) var(string) ...)(
This function provides a mechanism for the user to override the use of an
external command. It looks up the tt(command) style with the supplied
var(tag). If the style is set, its value is used as the command to
execute. The var(string)s from the call to tt(_call_program), or from the
style if set, are concatenated with spaces between them and the resulting
string is evaluated. The return status is the return status of the command
called.
)
findex(_combination)
item(tt(_combination) [ tt(-s) var(pattern) ] var(tag) var(style) var(spec) ... var(field) var(opts) ...)(
This function is used to complete combinations of values, for example
pairs of hostnames and usernames. The var(style) argument gives the style
which defines the pairs; it is looked up in a context with the var(tag)
specified.
The style name consists of field names separated by hyphens, for example
`tt(users-hosts-ports)'. For each field for a value is already known, a
var(spec) of the form `var(field)tt(=)var(pattern)' is given. For example,
if the command line so far specifies a user `tt(pws)', the argument
`tt(users=pws)' should appear.
The next argument with no equals sign is taken as the name of the field
for which completions should be generated (presumably not one of the
var(field)s for which the value is known).
The matches generated will be taken from the value of the style. These
should contain the possible values for the combinations in the appropriate
order (users, hosts, ports in the example above). The different fields
the values for the different fields are separated by colons. This
can be altered with the option tt(-s) to tt(_combination) which specifies a
pattern. Typically this is a character class, as for example
`tt(-s "[:@]")' in the case of the tt(users-hosts) style. Each
`var(field)tt(=)var(pattern)' specification restricts the
completions which apply to elements of the style with appropriately
matching fields.
If no style with the given name is defined for the given tag,
or if none of the strings in style's value match, but a
function name of the required field preceded by an
underscore is defined, that function will be called to generate the
matches. For example, if there is no `tt(users-hosts-ports)' or no
matching hostname when a host is required, the function `tt(_hosts)' will
automatically be called.
If the same name is used for more than one field, in both the
`var(field)tt(=)var(pattern)' and the argument that gives the name of the
field to be completed, the number of the field (starting with one) may
be given after the fieldname, separated from it by a colon.
All arguments after the required field name are passed to
tt(compadd) when generating matches from the style value, or to
the functions for the fields if they are called.
)
findex(_describe)
item(tt(_describe) [ tt(-oO) | tt(-t) var(tag) ] var(descr) var(name1) [ var(name2) ] var(opts) ... tt(-)tt(-) ...)(
This function associates completions with descriptions.
Multiple groups separated by tt(-)tt(-) can be supplied, potentially with
different completion options var(opts).
The var(descr) is taken as a string to display above the matches if the
tt(format) style for the tt(descriptions) tag is set. This is followed by
one or two names of arrays followed by options to pass to tt(compadd). The
first array contains the possible completions with their descriptions in
the form `var(completion)tt(:)var(description)'. If a second array is
given, it should have the same number of elements as the first; in this
case the corresponding elements are added as possible completions instead
of the var(completion) strings from the first array. The completion list
will retain the descriptions from the first array. Finally, a set of
completion options can appear.
If the option `tt(-o)' appears before the first argument, the matches added
will be treated as names of command options (N.B. not shell options),
typically following a `tt(-)', `tt(-)tt(-)' or `tt(+)' on the command
line. In this case tt(_describe) uses the tt(prefix-hidden),
tt(prefix-needed) and tt(verbose) styles to find out if the strings should
be added as completions and if the descriptions should be shown. Without
the `tt(-o)' option, only the tt(verbose) style is used to decide how
descriptions are shown. If `tt(-O)' is used instead of `tt(-O)', command
options are completed as above but tt(_describe) will not handle the
tt(prefix-needed) style.
With the tt(-t) option a var(tag) can be specified. The default is
`tt(values)' or, if the tt(-o) option is given, `tt(options)'.
If selected by the tt(list-grouped) style, strings with the same
description will appear together in the list.
tt(_describe) uses the tt(_all_labels) function to generate the matches, so
it does not need to appear inside a loop over tag labels.
)
findex(_description)
item(tt(_description) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(spec) ... ])(
This function is not to be confused with the previous one; it is used as
a helper function for creating options to tt(compadd). It is buried
inside many of the higher level completion functions and so often does
not need to be called directly.
The styles listed below are tested in the current context using the
given var(tag). The resulting options for tt(compadd) are put into the
array named var(name) (this is traditionally `tt(expl)', but this
convention is not enforced). The description for the corresponding set
of matches is passed to the function in var(descr).
The styles tested are: tt(format), tt(hidden), tt(matcher),
tt(ignored-patterns) and tt(group-name). The tt(format) style is first
tested for the given var(tag) and then for the tt(descriptions) tag if
no value was found, while the remainder are only tested for the tag
given as the first argument. The function also calls tt(_setup)
which tests some more styles.
The string returned by the tt(format) style (if any) will be modified so
that the sequence `tt(%d)' is replaced by the var(descr) given as the third
argument without any leading or trailing white space. If, after
removing the white space, the var(descr) is the empty string, the format
style will not be used and the options put into the var(name) array will
not contain an explanation string to be displayed above the matches.
If tt(_description) is called with more than three arguments,
the additional var(spec)s should be of the form `var(char)tt(:)var(str)'.
These supply escape sequence replacements for the tt(format) style:
every appearance of `tt(%)var(char)' will be
replaced by var(string).
If the tt(-x) option is given, the description will be passed to
tt(compadd) using the tt(-x) option instead of the default tt(-X). This
means that the description will be displayed even if there are no
corresponding matches.
The options placed in the array var(name) take account of the
tt(group-name) style, so matches are placed in a separate group where
necessary. The group normally has its elements sorted (by passing the
option tt(-J) to tt(compadd)), but if an option starting with `tt(-V)',
`tt(-J)', `tt(-1)', or `tt(-2)' is passed to tt(_description), that
option will be included in the array. Hence it is possible for the
completion group to be unsorted by giving the option `tt(-V)',
`tt(-1V)', or `tt(-2V)'.
In most cases, the function will be used like this:
example(local expl
_description files expl file
compadd "$expl[@]" - "$files[@]")
Note the use of the parameter tt(expl), the hyphen, and the list of
matches. Almost all calls to tt(compadd) within the completion system use
a similar format; this ensures that user-specified styles are correctly
passed down to the builtins which implement the internals of completion.
)
findex(_dispatch)
item(tt(_dispatch) var(context string ...))(
This sets the current context to var(context) and looks for completion
functions to handle this context by hunting through the list of command
names or special contexts (as described above for tt(compdef))
given as var(string ...). The first completion function to be defined
for one of the contexts in the list is used to generate matches.
Typically, the last var(string) is tt(-default-) to cause the function
for default completion to be used as a fallback.
The function sets the parameter
tt($service) to the var(string) being tried, and sets
the var(context/command) field (the fourth) of the tt($curcontext)
parameter to the var(context) given as the first argument.
)
findex(_files)
item(tt(_files))(
The function tt(_files) calls tt(_path_files) with all the arguments it
was passed except for tt(-g) and tt(-/). The use of these two options
depends on the setting of the tt(file-patterns) style.
This function accepts the full set of options allowed by
tt(_path_files), described below.
)
findex(_gnu_generic)
item(tt(_gnu_generic))(
This function is a simple wrapper around the tt(_arguments) function
described above. It can be used to determine automatically the long
options understood by commands that produce a list when passed the
option `tt(-)tt(-help)'. It is intended to be used as a top-level
completion function in its own right. For example, to enable option
completion for the commands tt(foo) and tt(bar), use
example(compdef _gnu_generic foo bar)
after the call to tt(compinit).
The completion system as supplied is conservative in its use of this
function, since it is important to be sure the command understands the
option `tt(-)tt(-help)'.
)
findex(_guard)
item(tt(_guard) [ var(options) ] var(pattern descr))(
This function is intended to be used in the var(action) for
the specifications passed to tt(_arguments) and similar functions. It
returns immediately with a non-zero return status if
the string to be completed does not match the var(pattern). If the
pattern matches, the var(descr) is displayed; the function then returns
status zero if the word to complete is not empty, non-zero otherwise.
The var(pattern) may be preceded by any of the options understood by
tt(compadd) that are passed down from tt(_description), namely tt(-M),
tt(-J), tt(-V), tt(-1), tt(-2), tt(-n), tt(-F) and tt(-X). All of these
options will be ignored. This fits in conveniently with the
argument-passing conventions of actions for tt(_arguments).
As an example, consider a command taking the options tt(-n) and
tt(-none), where tt(-n) must be followed by a numeric value in the
same word. By using:
example(_arguments '-n-: :_guard "[0-9]#" "numeric value"' '-none')
tt(_arguments) can be made to both display the message `tt(numeric
value)' and complete options after `tt(-n<TAB>)'. If the `tt(-n)' is
already followed by one or more digits (the pattern passed to
tt(_guard)) only the message will be displayed; if the `tt(-n)' is
followed by another character, only options are completed.
)
findex(_message)
xitem(tt(_message) [ tt(-r12) ] [ tt(-VJ) var(group) ] var(descr))
item(tt(_message -e) [ var(tag) ] var(descr))(
The var(descr) is used in the same way as the third
argument to the tt(_description) function, except that the resulting
string will always be shown whether or not matches were
generated. This is useful for displaying a help message in places where
no completions can be generated.
The tt(format) style is examined with the tt(messages) tag to find a
message; the usual tag, tt(descriptions), is used only if the style is
not set with the former.
If the tt(-r) option is given, no style is used; the var(descr) is
taken literally as the string to display. This is most useful
when the var(descr) comes from a pre-processed argument list
which already contains an expanded description.
The tt(-12VJ) options and the var(group) are passed to tt(compadd) and
hence determine the group the message string is added to.
The second form gives a description for completions with the tag
var(tag) to be shown even if there are no matches for that tag. The tag
can be omitted and if so the tag is taken from the parameter
tt($curtag); this is maintained by the completion system and so is
usually correct.
)
findex(_multi_parts)
item(tt(_multi_parts) var(sep) var(array))(
The argument var(sep) is a separator character.
The var(array) may be either the
name of an array parameter or a literal array in the form
`tt(LPAR()foo bar)tt(RPAR())', a parenthesised list of words separated
by whitespace. The possible completions are the
strings from the array. However, each chunk delimited by var(sep) will be
completed separately. For example, the tt(_tar) function uses
`tt(_multi_parts) tt(/) var(patharray)' to complete partial file paths
from the given array of complete file paths.
The tt(-i) option causes tt(_multi_parts) to insert a unique match even
if that requires multiple separators to be inserted. This is not usually
the expected behaviour with filenames, but certain other types of
completion, for example those with a fixed set of possibilities, may be
more suited to this form.
Like other utility functions, this function accepts the `tt(-V)',
`tt(-J)', `tt(-1)', `tt(-2)', `tt(-n)', `tt(-f)', `tt(-X)', `tt(-M)',
`tt(-P)', `tt(-S)', `tt(-r)', `tt(-R)', and `tt(-q)' options and passes
them to the tt(compadd) builtin.
)
findex(_next_label)
item(tt(_next_label) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])(
This function is used to implement the loop over different tag
labels for a particular tag as described above for the tt(tag-order)
style. On each call it checks to see if there are any more tag labels; if
there is it returns status zero, otherwise non-zero.
As this function requires a current tag to be set, it must always follow
a call to tt(_tags) or tt(_requested).
The tt(-x12VJ) options and the first three arguments are passed to the
tt(_description) function. Where appropriate the var(tag) will be
replaced by a tag label in this call. Any description given in
the tt(tag-order) style is preferred to the var(descr) passed to
tt(_next_label).
The var(options) given after the var(descr)
are set in the parameter given by var(name), and hence are to be passed
to tt(compadd) or whatever function is called to add the matches.
Here is a typical use of this function for the tag tt(foo). The call to
tt(_requested) determines if tag tt(foo) is required at all; the loop
over tt(_next_label) handles any labels defined for the tag in the
tt(tag-order) style.
example(local expl ret=1
...
if _requested foo; then
...
while _next_label foo expl '...'; do
compadd "$expl[@]" ... && ret=0
done
...
fi
return ret)
)
findex(_normal)
item(tt(_normal))(
This is the standard function called to handle completion outside
any special var(-context-). It is called both to complete the command
word and also the arguments for a command. In the second case,
tt(_normal) looks for a special completion for that command, and if
there is none it uses the completion for the tt(-default-) context.
A second use is to reexamine the command line specified by the tt($words)
array and the tt($CURRENT) parameter after those have been modified.
For example, the function tt(_precommand), which
completes after pre-command specifiers such as tt(nohup), removes the
first word from the tt(words) array, decrements the tt(CURRENT) parameter,
then calls tt(_normal) again. The effect is that `tt(nohup) var(cmd ...)'
is treated in the same way as `var(cmd ...)'.
If the command name matches one of the patterns given by one of the
options tt(-p) or tt(-P) to tt(compdef), the corresponding completion
function is called and then the parameter tt(_compskip) is
checked. If it is set completion is terminated at that point even if
no matches have been found. This is the same effect as in the
tt(-first-) context.
)
findex(_options)
item(tt(_options))(
This can be used to complete the names of shell options. It provides a
matcher specification that ignores a leading `tt(no)', ignores
underscores and allows upper-case letters to
match their lower-case counterparts (for example, `tt(glob)',
`tt(noglob)', `tt(NO_GLOB)' are all completed). Any arguments
are propagated to the tt(compadd) builtin.
)
findex(_options_set)
findex(_options_unset)
item(tt(_options_set) and tt(_options_unset))(
These functions complete only set or unset options, with the same
matching specification used in the tt(_options) function.
Note that you need to uncomment a few lines in the tt(_main_complete)
function for these functions to work properly. The lines in question
are used to store the option settings in effect before the completion
widget locally sets the options it needs. Hence these functions are not
generally used by the completion system.
)
findex(_parameters)
item(tt(_parameters))(
This is used to complete the names of shell parameters.
The option `tt(-g var(pattern))' limits the completion to parameters
whose type matches the var(pattern). The type of a parameter is that
shown by `tt(print ${(t))var(param)tt(})', hence judicious use of
`tt(*)' in var(pattern) is probably necessary.
All other arguments are passed to the tt(compadd) builtin.
)
findex(_path_files)
item(tt(_path_files))(
This function is used throughout the completion system
to complete filenames. It allows completion of partial paths. For
example, the string `tt(/u/i/s/sig)' may be completed to
`tt(/usr/include/sys/signal.h)'.
The options accepted by both tt(_path_files) and tt(_files) are:
startitem()
item(tt(-f))(
Complete all filenames. This is the default.
)
item(tt(-/))(
Specifies that only directories should be completed.
)
item(tt(-g) var(pattern))(
Specifies that only files matching the var(pattern) should be completed.
)
item(tt(-W) var(paths))(
Specifies path prefixes that are to be prepended to the string from the
command line to generate the filenames but that should not be inserted
as completions nor shown in completion listings. Here, var(paths) may be
the name of an array parameter, a literal list of paths enclosed in
parentheses or an absolute pathname.
)
item(tt(-F) var(ignored-files))(
This behaves as for the corresponding option to the tt(compadd) builtin.
It gives direct control over which
filenames should be ignored. If the option is not present, the
tt(ignored-patterns) style is used.
)
enditem()
Both tt(_path_files) and tt(_files) also accept the following options
which are passed to tt(compadd): `tt(-J)', `tt(-V)',
`tt(-1)', `tt(-2)', `tt(-n)', `tt(-X)', `tt(-M)', `tt(-P)', `tt(-S)',
`tt(-q)', `tt(-r)', and `tt(-R)'.
Finally, the tt(_path_files) function uses the styles tt(expand),
tt(ambiguous), tt(special-dirs), tt(list-suffixes) and tt(file-sort)
described above.
)
findex(_pick_variant)
item(tt(_pick_variant [ tt(-c) var(command) ] [ tt(-r) var(name) ] var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ]))(
This function is used to resolve situations where a single command name
requires more than one type of handling, either because it
has more than one variant or because there is a name clash between two
different commands.
The command to run is taken from the first element of the array
tt(words) unless this is overridden by the option tt(-c). This command
is run and its output is compared with a series of patterns. Arguments
to be passed to the command can be specified at the end after all the
other arguments. The patterns to try in order are given by the arguments
var(label)tt(=)var(pattern); if the output of `var(command) var(args)
tt(...)' contains var(pattern), then tt(label) is selected as the label
for the command variant. If none of the patterns match, the final
command label is selected and status 1 is returned.
If the `tt(-r) var(name)' is given, the var(label) picked is stored in
the parameter named var(name).
The results are also cached in the var(_cmd_variant) associative array
indexed by the name of the command run.
)
findex(_regex_arguments)
item(tt(_regex_arguments) var(name) var(spec) ...)(
This function generates a completion function var(name) which matches
the specifications var(spec) tt(...), a set of regular expressions as
described below. After running tt(_regex_arguments), the function
var(name) should be called at the appropriate point.
The pattern to be matched is given by the contents of
the tt(words) array up to the current cursor position joined together
with null characters; no quotation is applied.
The arguments are grouped as sets of alternatives separated by `tt(|)',
which are tried one after the other until one matches. Each alternative
consists of a one or more specifications which are tried left to right,
with each pattern matched being stripped in turn from the command line
being tested, until all of the group succeeds or until one fails; in the
latter case, the next alternative is tried. This structure can be
repeated to arbitrary depth by using parentheses; matching proceeds from
inside to outside.
COMMENT(I think I've got this wrong, but I can't think what else it
could mean. Actually, it still doesn't mean very much.)\
A special procedure is applied if no test succeeds but the remaining
command line string contains no null character (implying the remaining
word is the one for which completions are to be generated). The
completion target is restricted to the remaining word and any
var(action)s for the corresponding patterns are executed. In this case,
nothing is stripped from the command line string. The order of
evaluation of the var(action)s can be determined by the tt(tag-order)
style; the various formats supported by tt(_alternative) can be used
in var(action). The var(descr) is used for setting up the array
parameter tt(expl).
Specification arguments take one of following forms, in which
metacharacters such as `tt(LPAR())', `tt(RPAR())', `tt(#)' and `tt(|)'
should be quoted.
startitem()
item(tt(/)var(pattern)tt(/) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(tag)tt(:)var(descr)tt(:)var(action)])(
This is a single primitive component.
The function tests whether the combined pattern
`tt((#b)LPAR()(#B))var(pattern)tt(RPAR())var(lookahead)tt(*)' matches
the command line string. If so, `var(guard)' is evaluated and
its return status is examined to determine if the test has succeeded.
The var(pattern) string `tt([])' is guaranteed never to match.
The var(lookahead) is not stripped from the command line before the next
pattern is examined.
)
item(tt(/)var(pattern)tt(/+) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(tag)tt(:)var(descr)tt(:)var(action)])(
This is similar to `tt(/)var(pattern)tt(/) ...' but the left part of the
command line string (i.e. the part already matched by previous patterns)
is also considered part of the completion target.
)
item(tt(/)var(pattern)tt(/-) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(tag)tt(:)var(descr)tt(:)var(action)])(
This is similar to `tt(/)var(pattern)tt(/) ...' but the var(action)s of the
current and previously matched patterns are ignored even if the
following `var(pattern)' matches the empty string.
)
item(tt(LPAR()) var(spec) tt(RPAR()))(
Parentheses may be used to groups var(spec)s; note each parenthesis
is a single argument to tt(_regex_arguments).
)
item(var(spec) tt(#))(
This allows any number of repetitions of var(spec).
)
item(var(spec) var(spec))(
The two var(spec)s are to be matched one after the other as described
above.
)
item(var(spec) tt(|) var(spec))(
Either of the two var(spec)s can be matched.
)
enditem()
)
findex(_requested)
item(tt(_requested) [ tt(-x) ] [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])(
This function is called to decide whether a tag already registered by a
call to tt(_tags) (see below) has been requested by the user and hence
completion should be performed for it. It returns status zero if the
tag is requested and non-zero otherwise. The function is typically used
as part of a loop over different tags as follows:
example(_tags foo bar baz
while _tags; do
if _requested foo; then
... # perform completion for foo
fi
... # test the tags bar and baz in the same way
... # exit loop if matches were generated
done)
Note that the test for whether matches were generated is not performed
until the end of the tt(_tags) loop. This is so that the user can set
the tt(tag-order) style to specify a set of tags to be completed at the
same time.
If var(name) and var(descr) are given, tt(_requested) calls the
tt(_description) function with these arguments together with the options
passed to tt(_requested).
If var(command) is given, the tt(_all_labels) function will be called
immediately with the same arguments. In simple cases this makes it
possible to perform the test for the tag and the matching in one go.
For example:
example(local expl ret=1
_tags foo bar baz
while _tags; do
_requested foo expl 'description' \
compadd foobar foobaz && ret=0
...
(( ret )) || break
done)
If the var(command) is not tt(compadd), it must nevertheless be prepared
to handle the same options.
)
findex(_retrieve_cache)
item(tt(_retrieve_cache) var(cache_identifier))(
This function retrieves completion information from the file given by
var(cache_identifier), stored in a directory specified by the
tt(cache-path) style which defaults to tt(~/.zcompcache). The return status
is zero if retrieval was successful. It will only attempt retrieval
if the tt(use-cache) style is set, so you can call this function
without worrying about whether the user wanted to use the caching
layer.
See tt(_store_cache) below for more details.
)
findex(_sep_parts)
item(tt(_sep_parts))(
This function is passed alternating arrays and separators as arguments.
The arrays specify completions for parts of strings to be separated by the
separators. The arrays may be the names of array parameters or
a quoted list of words in parentheses. For example, with the array
`tt(hosts=(ftp news))' the call `tt(_sep_parts '(foo bar)' @ hosts)' will
complete the string `tt(f)' to `tt(foo)' and the string `tt(b@n)' to
`tt(bar@news)'.
This function accepts the tt(compadd) options `tt(-V)', `tt(-J)',
`tt(-1)', `tt(-2)', `tt(-n)', `tt(-X)', `tt(-M)', `tt(-P)', `tt(-S)',
`tt(-r)', `tt(-R)', and `tt(-q)' and passes them on to the tt(compadd)
builtin used to add the matches.
)
findex(_setup)
item(tt(_setup) var(tag) [ var(group) ])(
This function sets up the special
parameters used by the completion system appropriately for the var(tag)
given as the first argument. It uses the styles tt(list-colors),
tt(list-packed), tt(list-rows-first), tt(last-prompt), tt(accept-exact),
tt(menu) and tt(force-list).
The optional var(group) supplies the name of the group in which the
matches will be placed. If it is not given, the var(tag) is used as
the group name.
This function is called automatically from tt(_description)
and hence is not normally called explicitly.
)
findex(_store_cache)
item(tt(_store_cache) var(cache_identifier) var(params) ...)(
This function, together with tt(_retrieve_cache) and
tt(_cache_invalid), implements a caching layer which can be used
in any completion function. Data obtained by
costly operations are stored in parameters;
this function then dumps the values of those parameters to a file. The
data can then be retrieved quickly from that file via tt(_retrieve_cache),
even in different instances of the shell.
The var(cache_identifier) specifies the file which the data should be
dumped to. The file is stored in a directory specified by the
tt(cache-path) style which defaults to tt(~/.zcompcache). The remaining
var(params) arguments are the parameters to dump to the file.
The return status is zero if storage was successful. The function will
only attempt storage if the tt(use-cache) style is set, so you can
call this function without worrying about whether the user wanted to
use the caching layer.
The completion function may avoid calling tt(_retrieve_cache) when it
already has the completion data available as parameters.
However, in that case it should
call tt(_cache_invalid) to check whether the data in the parameters and
in the cache are still valid.
See the _perl_modules completion function for a simple example of
the usage of the caching layer.
)
findex(_tags)
item(tt(_tags) [ [ tt(-C) var(name) ] var(tags) ... ])(
If called with arguments, these are taken to be the names of tags
valid for completions in the current context. These tags are stored
internally and sorted by using the tt(tag-order) style.
Next, tt(_tags) is called repeatedly without arguments from the same
completion function. This successively selects the first, second,
etc. set of tags requested by the user. The return status is zero if at
least one of the tags is requested and non-zero otherwise. To test if a
particular tag is to be tried, the tt(_requested) function should be
called (see above).
If `tt(-C) var(name)' is given, var(name) is temporarily stored in the
argument field (the fifth) of the context in the tt(curcontext) parameter
during the call to tt(_tags); the field is restored on exit. This
allows tt(_tags) to use a more
specific context without having to change and reset the
tt(curcontext) parameter (which has the same effect).
)
findex(_values)
item(tt(_values) [ tt(-O) var(name) ] [ tt(-s) var(sep) ] [ tt(-S) var(sep) ] [ tt(-wC) ] var(desc) var(spec) ...)(
This is used to complete arbitrary keywords (values) and their arguments,
or lists of such combinations.
If the first argument is the option `tt(-O) var(name)', it will be used
in the same way as by the tt(_arguments) function. In other words, the
elements of the var(name) array will be passed to tt(compadd)
when executing an action.
If the first argument (or the first argument after `tt(-O) var(name)')
is `tt(-s)', the next argument is used as the character that separates
multiple values. This character is automatically added after each value
in an auto-removable fashion (see below); all values completed by
`tt(_values -s)' appear in the same word on the command line, unlike
completion using tt(_arguments). If this option is not present, only a
single value will be completed per word.
Normally, tt(_values) will only use the current word to determine
which values are already present on the command line and hence are not
to be completed again. If the tt(-w) option is given, other arguments
are examined as well.
The first non-option argument is used as a string to print as a
description before listing the values.
All other arguments describe the possible values and their
arguments in the same format used for the description of options by
the tt(_arguments) function (see above). The only differences are that
no minus or plus sign is required at the beginning,
values can have only one argument, and the forms of action
beginning with an equal sign are not supported.
The character separating a value from its argument can be set using the
option tt(-S) (like tt(-s), followed by the character to use as the
separator in the next argument). By default the equals
sign will be used as the separator between values and arguments.
Example:
example(_values -s , 'description' \
'*foo[bar]' \
'(two)*one[number]:first count:' \
'two[another number]::second count:(1 2 3)')
This describes three possible values: `tt(foo)', `tt(one)', and
`tt(two)'. The first is described as `tt(bar)', takes no argument
and may appear more than once. The second is described as
`tt(number)', may appear more than once, and takes one mandatory
argument described as `tt(first count)'; no action is
specified, so it will not be completed. The
`tt((two))' at the beginning says that if the value `tt(one)' is on
the line, the value `tt(two)' will no longer be considered a possible
completion. Finally, the last value (`tt(two)') is described
as `tt(another number)' and takes an optional argument described as
`tt(second count)' for which the completions (to appear after an
`tt(=)') are `tt(1)', `tt(2)', and `tt(3)'. The tt(_values) function
will complete lists of these values separated by commas.
Like tt(_arguments), this function temporarily adds another context name
component to the arguments element (the fifth) of the current context
while executing the var(action). Here this name is just the name of the
value for which the argument is completed.
The style tt(verbose) is used to decide if the descriptions for the
values (but not those for the arguments) should be printed.
The associative array tt(val_args) is used to report values and their
arguments; this works similarly to the tt(opt_args) associative array
used by tt(_arguments). Hence the function calling tt(_values) should
declare the local parameters tt(state), tt(line), tt(context) and
tt(val_args):
example(local context state line
typeset -A val_args)
when using an action of the form `tt(->)var(string)'. With this
function the tt(context) parameter will be set to the name of the
value whose argument is to be completed.
Note also that tt(_values) normally adds the character used as the
separator between values as an auto-removable suffix (similar to a
`tt(/)' after a directory). However, this is not possible for a
`tt(->)var(string)' action as the matches for the argument are
generated by the calling function. To get the usual behaviour, the
the calling function can add the separator var(x) as a suffix by
passing the options `tt(-qS) var(x)' either directly or indirectly to
tt(compadd).
The option tt(-C) is treated in the same way as it is by tt(_arguments).
In that case the parameter tt(curcontext) should be made local instead
of tt(context) (as described above).
)
findex(_wanted)
item(tt(_wanted) [ tt(-x) ] [ tt(-C) var(name) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) var(command) var(args) ...)(
In many contexts, completion can only generate one particular set of
matches, usually corresponding to a single tag. However, it is
still necessary to decide whether the user requires matches of this type.
This function is useful in such a case.
The arguments to tt(_wanted) are the same as those to tt(_requested),
i.e. arguments to be passed to tt(_description). However, in this case
the var(command) is not optional; all the processing of tags, including
the loop over both tags and tag labels and the generation of matches,
is carried out automatically by tt(_wanted).
Hence to offer only one tag and immediately add the corresponding
matches with the given description:
example(local expl
_wanted tag expl 'description' \
compadd matches...)
Note that, as for tt(_requested), the var(command) must be able to
accept options to be passed down to tt(compadd).
Like tt(_tags) this function supports the tt(-C) option to give a
different name for the argument context field. The tt(-x) option has
the same meaning as for tt(_description).
)
enditem()
texinode(Completion Directories)()(Completion Functions)(Completion System)
sect(Completion Directories)
cindex(completion system, directory structure)
In the source distribution, the files are contained in various
subdirectories of the tt(Completion) directory. They may have been
installed in the same structure, or into one single function directory.
The following is a description of the files found in the original directory
structure. If you wish to alter an installed file, you will need to copy
it to some directory which appears earlier in your tt(fpath) than the
standard directory where it appears.
startitem()
item(tt(Base))(
The core functions and special completion widgets automatically bound
to keys. You will certainly need most of these, though will
probably not need to alter them. Many of these are documented above.
)
item(tt(Zsh))(
Functions for completing arguments of shell builtin commands and
utility functions for this. Some of these are also used by functions from
the tt(Unix) directory.
)
item(tt(Unix))(
Functions for completing arguments of external commands and suites of
commands. They may need modifying for your system, although in many cases
some attempt is made to decide which version of a command is present. For
example, completion for the tt(mount) command tries to determine the system
it is running on, while completion for many other utilities try to decide
whether the GNU version of the command is in use, and hence whether the
tt(-)tt(-help) option is supported.
)
item(tt(X), tt(AIX), tt(BSD), ...)(
Completion and utility function for commands available only on some systems.
These are not arranged hierarchically, so, for example, both the
tt(Linux) and tt(Debian) directories, as well as the tt(X) directory,
may be useful on your system.
)
enditem()
|