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
|
.TH "ZSHCONTRIB" "1" "March 7, 2006" "zsh 4\&.3\&.2-dev-1"
.SH "NAME"
zshcontrib \- user contributions to zsh
.\" Yodl file: Zsh/contrib.yo
.SH "DESCRIPTION"
.PP
The Zsh source distribution includes a number of items contributed by the
user community\&. These are not inherently a part of the shell, and some
may not be available in every zsh installation\&. The most significant of
these are documented here\&. For documentation on other contributed items
such as shell functions, look for comments in the function source files\&.
.PP
.PP
.SH "UTILITIES"
.PP
.SS "Accessing On\-Line Help"
.PP
The key sequence \fBESC h\fP is normally bound by ZLE to execute the
\fBrun\-help\fP widget (see
\fIzshzle\fP(1))\&. This invokes the \fBrun\-help\fP command with the command word from the
current input line as its argument\&. By default, \fBrun\-help\fP is an alias
for the \fBman\fP command, so this often fails when the command word is a
shell builtin or a user\-defined function\&. By redefining the \fBrun\-help\fP
alias, one can improve the on\-line help provided by the shell\&.
.PP
The \fBhelpfiles\fP utility, found in the \fBUtil\fP directory of the
distribution, is a Perl program that can be used to process the zsh manual
to produce a separate help file for each shell builtin and for many other
shell features as well\&. The autoloadable \fBrun\-help\fP function, found in
\fBFunctions/Misc\fP, searches for these helpfiles and performs several
other tests to produce the most complete help possible for the command\&.
.PP
There may already be a directory of help files on your system; look in
\fB/usr/share/zsh\fP or \fB/usr/local/share/zsh\fP and subdirectories below
those, or ask your system administrator\&.
.PP
To create your own help files with \fBhelpfiles\fP, choose or create a
directory where the individual command help files will reside\&. For
example, you might choose \fB~/zsh_help\fP\&. If you unpacked the zsh
distribution in your home directory, you would use the commands:
.PP
.RS
.nf
\fBmkdir ~/zsh_help
cd ~/zsh_help
man zshall | colcrt \- | \e
perl ~/zsh\-4\&.3\&.2\-dev\-1/Util/helpfiles\fP
.fi
.RE
.PP
Next, to use the \fBrun\-help\fP function, you need to add lines something
like the following to your \fB\&.zshrc\fP or equivalent startup file:
.PP
.RS
.nf
\fBunalias run\-help
autoload run\-help
HELPDIR=~/zsh_help\fP
.fi
.RE
.PP
The \fBHELPDIR\fP parameter tells \fBrun\-help\fP where to look for the help
files\&. If your system already has a help file directory installed, set
\fBHELPDIR\fP to the path of that directory instead\&.
.PP
Note that in order for `\fBautoload run\-help\fP\&' to work, the \fBrun\-help\fP
file must be in one of the directories named in your \fBfpath\fP array (see
\fIzshparam\fP(1))\&. This should already be the case if you have a standard zsh
installation; if it is not, copy \fBFunctions/Misc/run\-help\fP to an
appropriate directory\&.
.PP
.SS "Recompiling Functions"
.PP
If you frequently edit your zsh functions, or periodically update your zsh
installation to track the latest developments, you may find that function
digests compiled with the \fBzcompile\fP builtin are frequently out of date
with respect to the function source files\&. This is not usually a problem,
because zsh always looks for the newest file when loading a function, but
it may cause slower shell startup and function loading\&. Also, if a digest
file is explicitly used as an element of \fBfpath\fP, zsh won\&'t check whether
any of its source files has changed\&.
.PP
The \fBzrecompile\fP autoloadable function, found in \fBFunctions/Misc\fP, can
be used to keep function digests up to date\&.
.PP
.PD 0
.TP
.PD 0
\fBzrecompile\fP [ \fB\-qt\fP ] [ \fIname\fP \&.\&.\&. ]
.TP
.PD
\fBzrecompile\fP [ \fB\-qt\fP ] \fB\-p\fP \fIargs\fP [ \fB\-\fP\fB\-\fP \fIargs\fP \&.\&.\&. ]
This tries to find \fB*\&.zwc\fP files and automatically re\-compile them if at
least one of the original files is newer than the compiled file\&. This
works only if the names stored in the compiled files are full paths or are
relative to the directory that contains the \fB\&.zwc\fP file\&.
.RS
.PP
In the first form, each \fIname\fP is the name of a compiled file or a
directory containing \fB*\&.zwc\fP files that should be checked\&. If no
arguments are given, the directories and \fB*\&.zwc\fP files in \fBfpath\fP are
used\&.
.PP
When \fB\-t\fP is given, no compilation is performed, but a return status of
zero (true) is set if there are files that need to be re\-compiled and
non\-zero (false) otherwise\&. The \fB\-q\fP option quiets the chatty output
that describes what \fBzrecompile\fP is doing\&.
.PP
Without the \fB\-t\fP option, the return status is zero if all files that
needed re\-compilation could be compiled and non\-zero if compilation for at
least one of the files failed\&.
.PP
If the \fB\-p\fP option is given, the \fIargs\fP are interpreted as one
or more sets of arguments for \fBzcompile\fP, separated by `\fB\-\fP\fB\-\fP\&'\&.
For example:
.PP
.RS
.nf
\fBzrecompile \-p \e
\-R ~/\&.zshrc \-\- \e
\-M ~/\&.zcompdump \-\- \e
~/zsh/comp\&.zwc ~/zsh/Completion/*/_*\fP
.fi
.RE
.PP
This compiles \fB~/\&.zshrc\fP into \fB~/\&.zshrc\&.zwc\fP if that doesn\&'t exist or
if it is older than \fB~/\&.zshrc\fP\&. The compiled file will be marked for
reading instead of mapping\&. The same is done for \fB~/\&.zcompdump\fP and
\fB~/\&.zcompdump\&.zwc\fP, but this compiled file is marked for mapping\&. The
last line re\-creates the file \fB~/zsh/comp\&.zwc\fP if any of the files
matching the given pattern is newer than it\&.
.PP
Without the \fB\-p\fP option, \fBzrecompile\fP does not create function digests
that do not already exist, nor does it add new functions to the digest\&.
.RE
.RE
.PP
The following shell loop is an example of a method for creating function
digests for all functions in your \fBfpath\fP, assuming that you have write
permission to the directories:
.PP
.RS
.nf
\fBfor ((i=1; i <= $#fpath; ++i)); do
dir=$fpath[i]
zwc=${dir:t}\&.zwc
if [[ $dir == (\&.|\&.\&.) || $dir == (\&.|\&.\&.)/* ]]; then
continue
fi
files=($dir/*(N\-\&.))
if [[ \-w $dir:h && \-n $files ]]; then
files=(${${(M)files%/*/*}#/})
if ( cd $dir:h &&
zrecompile \-p \-U \-z $zwc $files ); then
fpath[i]=$fpath[i]\&.zwc
fi
fi
done\fP
.fi
.RE
.PP
The \fB\-U\fP and \fB\-z\fP options are appropriate for functions in the default
zsh installation \fBfpath\fP; you may need to use different options for your
personal function directories\&.
.PP
Once the digests have been created and your \fBfpath\fP modified to refer to
them, you can keep them up to date by running \fBzrecompile\fP with no
arguments\&.
.PP
.SS "Keyboard Definition"
.PP
The large number of possible combinations of keyboards, workstations,
terminals, emulators, and window systems makes it impossible for zsh to
have built\-in key bindings for every situation\&. The \fBzkbd\fP utility,
found in Functions/Misc, can help you quickly create key bindings for your
configuration\&.
.PP
Run \fBzkbd\fP either as an autoloaded function, or as a shell script:
.PP
.RS
.nf
\fBzsh \-f ~/zsh\-4\&.3\&.2\-dev\-1/Functions/Misc/zkbd\fP
.fi
.RE
.PP
When you run \fBzkbd\fP, it first asks you to enter your terminal type; if
the default it offers is correct, just press return\&. It then asks you to
press a number of different keys to determine characteristics of your
keyboard and terminal; \fBzkbd\fP warns you if it finds anything out of the
ordinary, such as a Delete key that sends neither \fB^H\fP nor \fB^?\fP\&.
.PP
The keystrokes read by \fBzkbd\fP are recorded as a definition for an
associative array named \fBkey\fP, written to a file in the subdirectory
\fB\&.zkbd\fP within either your \fBHOME\fP or \fBZDOTDIR\fP directory\&. The name
of the file is composed from the \fBTERM\fP, \fBVENDOR\fP and \fBOSTYPE\fP
parameters, joined by hyphens\&.
.PP
You may read this file into your \fB\&.zshrc\fP or another startup file with
the "source" or "\&." commands, then reference the \fBkey\fP parameter in
bindkey commands, like this:
.PP
.RS
.nf
\fBsource ${ZDOTDIR:\-$HOME}/\&.zkbd/$TERM\-$VENDOR\-$OSTYPE
[[ \-n ${key[Left]} ]] && bindkey "${key[Left]}" backward\-char
[[ \-n ${key[Right]} ]] && bindkey "${key[Right]}" forward\-char
# etc\&.\fP
.fi
.RE
.PP
Note that in order for `\fBautoload zkbd\fP\&' to work, the \fBzkdb\fP file must
be in one of the directories named in your \fBfpath\fP array (see
\fIzshparam\fP(1))\&. This should already be the case if you have a standard zsh
installation; if it is not, copy \fBFunctions/Misc/zkbd\fP to an
appropriate directory\&.
.PP
.SS "Dumping Shell State"
.PP
Occasionally you may encounter what appears to be a bug in the shell,
particularly if you are using a beta version of zsh or a development
release\&. Usually it is sufficient to send a description of the
problem to one of the zsh mailing lists (see
\fIzsh\fP(1)), but sometimes one of the zsh developers will need to recreate your
environment in order to track the problem down\&.
.PP
The script named \fBreporter\fP, found in the \fBUtil\fP directory of the
distribution, is provided for this purpose\&. (It is also possible to
\fBautoload reporter\fP, but \fBreporter\fP is not installed in \fBfpath\fP
by default\&.) This script outputs a detailed dump of the shell state,
in the form of another script that can be read with `\fBzsh \-f\fP\&' to
recreate that state\&.
.PP
To use \fBreporter\fP, read the script into your shell with the `\fB\&.\fP\&'
command and redirect the output into a file:
.PP
.RS
.nf
\fB\&. ~/zsh\-4\&.3\&.2\-dev\-1/Util/reporter > zsh\&.report\fP
.fi
.RE
.PP
You should check the \fBzsh\&.report\fP file for any sensitive information
such as passwords and delete them by hand before sending the script to the
developers\&. Also, as the output can be voluminous, it\&'s best to wait for
the developers to ask for this information before sending it\&.
.PP
You can also use \fBreporter\fP to dump only a subset of the shell state\&.
This is sometimes useful for creating startup files for the first time\&.
Most of the output from reporter is far more detailed than usually is
necessary for a startup file, but the \fBaliases\fP, \fBoptions\fP, and
\fBzstyles\fP states may be useful because they include only changes from
the defaults\&. The \fBbindings\fP state may be useful if you have created
any of your own keymaps, because \fBreporter\fP arranges to dump the keymap
creation commands as well as the bindings for every keymap\&.
.PP
As is usual with automated tools, if you create a startup file with
\fBreporter\fP, you should edit the results to remove unnecessary commands\&.
Note that if you\&'re using the new completion system, you should \fInot\fP
dump the \fBfunctions\fP state to your startup files with \fBreporter\fP; use
the \fBcompdump\fP function instead (see
\fIzshcompsys\fP(1))\&.
.PP
.PD 0
.TP
.PD
\fBreporter\fP [ \fIstate\fP \&.\&.\&. ]
Print to standard output the indicated subset of the current shell state\&.
The \fIstate\fP arguments may be one or more of:
.RS
.PP
.PD 0
.TP
\fBall\fP
Output everything listed below\&.
.TP
\fBaliases\fP
Output alias definitions\&.
.TP
\fBbindings\fP
Output ZLE key maps and bindings\&.
.TP
\fBcompletion\fP
Output old\-style \fBcompctl\fP commands\&.
New completion is covered by \fBfunctions\fP and \fBzstyles\fP\&.
.TP
\fBfunctions\fP
Output autoloads and function definitions\&.
.TP
\fBlimits\fP
Output \fBlimit\fP commands\&.
.TP
\fBoptions\fP
Output \fBsetopt\fP commands\&.
.TP
\fBstyles\fP
Same as \fBzstyles\fP\&.
.TP
\fBvariables\fP
Output shell parameter assignments, plus \fBexport\fP
commands for any environment variables\&.
.TP
\fBzstyles\fP
Output \fBzstyle\fP commands\&.
.PD
.PP
If the \fIstate\fP is omitted, \fBall\fP is assumed\&.
.RE
.PP
With the exception of `\fBall\fP\&', every \fIstate\fP can be abbreviated by
any prefix, even a single letter; thus \fBa\fP is the same as \fBaliases\fP,
\fBz\fP is the same as \fBzstyles\fP, etc\&.
.RE
.PP
.SH "PROMPT THEMES"
.PP
.SS "Installation"
.PP
You should make sure all the functions from the \fBFunctions/Prompts\fP
directory of the source distribution are available; they all begin with
the string `\fBprompt_\fP\&' except for the special function`\fBpromptinit\fP'\&.
You also need the `\fBcolors\fP\&' function from \fBFunctions/Misc\fP\&. All of
these functions may already have been installed on your system; if not,
you will need to find them and copy them\&. The directory should appear as
one of the elements of the \fBfpath\fP array (this should already be the
case if they were installed), and at least the function \fBpromptinit\fP
should be autoloaded; it will autoload the rest\&. Finally, to initialize
the use of the system you need to call the \fBpromptinit\fP function\&. The
following code in your \fB\&.zshrc\fP will arrange for this; assume the
functions are stored in the directory \fB~/myfns\fP:
.PP
.RS
.nf
\fBfpath=(~/myfns $fpath)
autoload \-U promptinit
promptinit\fP
.fi
.RE
.PP
.SS "Theme Selection"
.PP
Use the \fBprompt\fP command to select your preferred theme\&. This command
may be added to your \fB\&.zshrc\fP following the call to \fBpromptinit\fP in
order to start zsh with a theme already selected\&.
.PP
.PD 0
.TP
.PD 0
\fBprompt\fP [ \fB\-c\fP | \fB\-l\fP ]
.TP
.PD 0
\fBprompt\fP [ \fB\-p\fP | \fB\-h\fP ] [ \fItheme\fP \&.\&.\&. ]
.TP
.PD
\fBprompt\fP [ \fB\-s\fP ] \fItheme\fP [ \fIarg\fP \&.\&.\&. ]
Set or examine the prompt theme\&. With no options and a \fItheme\fP
argument, the theme with that name is set as the current theme\&. The
available themes are determined at run time; use the \fB\-l\fP option to see
a list\&. The special \fItheme\fP `\fBrandom\fP\&' selects at random one of the
available themes and sets your prompt to that\&.
.RS
.PP
In some cases the \fItheme\fP may be modified by one or more arguments,
which should be given after the theme name\&. See the help for each theme
for descriptions of these arguments\&.
.PP
Options are:
.PP
.PD 0
.TP
\fB\-c\fP
Show the currently selected theme and its parameters, if any\&.
.TP
\fB\-l\fP
List all available prompt themes\&.
.TP
\fB\-p\fP
Preview the theme named by \fItheme\fP, or all themes if no
\fItheme\fP is given\&.
.TP
\fB\-h\fP
Show help for the theme named by \fItheme\fP, or for the
\fBprompt\fP function if no \fItheme\fP is given\&.
.TP
\fB\-s\fP
Set \fItheme\fP as the current theme and save state\&.
.PD
.RE
.TP
\fBprompt_\fP\fItheme\fP\fB_setup\fP
Each available \fItheme\fP has a setup function which is called by the
\fBprompt\fP function to install that theme\&. This function may define
other functions as necessary to maintain the prompt, including functions
used to preview the prompt or provide help for its use\&. You should not
normally call a theme\&'s setup function directly\&.
.PP
.SH "ZLE FUNCTIONS"
.PP
.SS "Widgets"
.PP
These functions all implement user\-defined ZLE widgets (see
\fIzshzle\fP(1)) which can be bound to keystrokes in interactive shells\&. To use them,
your \fB\&.zshrc\fP should contain lines of the form
.PP
.RS
.nf
\fBautoload \fIfunction\fP
zle \-N \fIfunction\fP\fP
.fi
.RE
.PP
followed by an appropriate \fBbindkey\fP command to associate the function
with a key sequence\&. Suggested bindings are described below\&.
.PP
.PD 0
.TP
.PD
bash\-style word functions
If you are looking for functions to implement moving over and editing
words in the manner of bash, where only alphanumeric characters are
considered word characters, you can use the functions described in
the next section\&. The following is sufficient:
.RS
.PP
.RS
.nf
\fBautoload \-U select\-word\-style
select\-word\-style bash\fP
.fi
.RE
.PP
.RE
.TP
.PD 0
\fBforward\-word\-match\fP, \fBbackward\-word\-match\fP
.TP
.PD 0
\fBkill\-word\-match\fP, \fBbackward\-kill\-word\-match\fP
.TP
.PD 0
\fBtranspose\-words\-match\fP, \fBcapitalize\-word\-match\fP
.TP
.PD 0
\fBup\-case\-word\-match\fP, \fBdown\-case\-word\-match\fP
.TP
.PD
\fBselect\-word\-style\fP, \fBmatch\-word\-context\fP, \fBmatch\-words\-by\-style\fP
The eight `\fB\-match\fP\&' functions are drop\-in replacements for the
builtin widgets without the suffix\&. By default they behave in a similar
way\&. However, by the use of styles and the function \fBselect\-word\-style\fP,
the way words are matched can be altered\&.
.RS
.PP
The simplest way of configuring the functions is to use
\fBselect\-word\-style\fP, which can either be called as a normal function with
the appropriate argument, or invoked as a user\-defined widget that will
prompt for the first character of the word style to be used\&. The first
time it is invoked, the eight \fB\-match\fP functions will automatically
replace the builtin versions, so they do not need to be loaded explicitly\&.
.PP
The word styles available are as follows\&. Only the first character
is examined\&.
.PP
.PD 0
.TP
.PD
\fBbash\fP
Word characters are alphanumeric characters only\&.
.TP
\fBnormal\fP
As in normal shell operation: word characters are alphanumeric characters
plus any characters present in the string given by the parameter
\fB$WORDCHARS\fP\&.
.TP
\fBshell\fP
Words are complete shell command arguments, possibly including complete
quoted strings, or any tokens special to the shell\&.
.TP
\fBwhitespace\fP
Words are any set of characters delimited by whitespace\&.
.TP
\fBdefault\fP
Restore the default settings; this is usually the same as `\fBnormal\fP\&'\&.
.PP
More control can be obtained using the \fBzstyle\fP command, as described in
\fIzshmodules\fP(1)\&. Each style is looked up in the
context \fB:zle:\fP\fIwidget\fP where \fIwidget\fP is the name of the
user\-defined widget, not the name of the function implementing it, so in
the case of the definitions supplied by \fBselect\-word\-style\fP the
appropriate contexts are \fB:zle:forward\-word\fP, and so on\&. The function
\fBselect\-word\-style\fP itself always defines styles for the context
`\fB:zle:*\fP\&' which can be overridden by more specific (longer) patterns as
well as explicit contexts\&.
.PP
The style \fBword\-style\fP specifies the rules to use\&. This may have the
following values\&.
.PP
.PD 0
.TP
.PD
\fBnormal\fP
Use the standard shell rules, i\&.e\&. alphanumerics and \fB$WORDCHARS\fP, unless
overridden by the styles \fBword\-chars\fP or \fBword\-class\fP\&.
.TP
\fBspecified\fP
Similar to \fBnormal\fP, but \fIonly\fP the specified characters, and not also
alphanumerics, are considered word characters\&.
.TP
\fBunspecified\fP
The negation of specified\&. The given characters are those which will
\fInot\fP be considered part of a word\&.
.TP
\fBshell\fP
Words are obtained by using the syntactic rules for generating shell
command arguments\&. In addition, special tokens which are never command
arguments such as `\fB()\fP\&' are also treated as words\&.
.TP
\fBwhitespace\fP
Words are whitespace\-delimited strings of characters\&.
.PP
The first three of those rules usually use \fB$WORDCHARS\fP, but the value
in the parameter can be overridden by the style \fBword\-chars\fP, which works
in exactly the same way as \fB$WORDCHARS\fP\&. In addition, the style
\fBword\-class\fP uses character class syntax to group characters and takes
precedence over \fBword\-chars\fP if both are set\&. The \fBword\-class\fP style
does not include the surrounding brackets of the character class; for
example, `\fB\-:[:alnum:]\fP\&' is a valid \fBword\-class\fP to include all
alphanumerics plus the characters `\fB\-\fP\&' and `\fB:\fP'\&. Be careful
including `\fB]\fP\&', `\fB^\fP' and `\fB\-\fP' as these are special inside
character classes\&.
.PP
The style \fBskip\-chars\fP is mostly useful for
\fBtranspose\-words\fP and similar functions\&. If set, it gives a count of
characters starting at the cursor position which will not be considered
part of the word and are treated as space, regardless of what they actually
are\&. For example, if
.PP
.RS
.nf
\fBzstyle \&':zle:transpose\-words' skip\-chars 1\fP
.fi
.RE
.PP
has been set, and \fBtranspose\-words\-match\fP is called with the cursor on
the \fIX\fP of \fBfoo\fP\fIX\fP\fBbar\fP, where \fIX\fP can be any character, then
the resulting expression is \fBbar\fP\fIX\fP\fBfoo\fP\&.
.PP
Finer grained control can be obtained by setting the style \fBword\-context\fP
to an array of pairs of entries\&. Each pair of entries consists of a
\fIpattern\fP and a \fIsubcontext\fP\&. The shell argument the cursor is on is
matched against each \fIpattern\fP in turn until one matches; if it does,
the context is extended by a colon and the corresponding \fIsubcontext\fP\&.
Note that the test is made against the original word on the line, with no
stripping of quotes\&. If the cursor is at the end of the line the test is
performed against an empty string; if it is on whitespace between words the
test is made against a single space\&. Some examples are given below\&.
.PP
Here are some examples of use of the styles, actually taken from the
simplified interface in \fBselect\-word\-style\fP:
.PP
.RS
.nf
\fBzstyle \&':zle:*' word\-style standard
zstyle \&':zle:*' word\-chars ''\fP
.fi
.RE
.PP
Implements bash\-style word handling for all widgets, i\&.e\&. only
alphanumerics are word characters; equivalent to setting
the parameter \fBWORDCHARS\fP empty for the given context\&.
.PP
.RS
.nf
\fBstyle \&':zle:*kill*' word\-style space\fP
.fi
.RE
.PP
Uses space\-delimited words for widgets with the word `kill\&' in the name\&.
Neither of the styles \fBword\-chars\fP nor \fBword\-class\fP is used in this case\&.
.PP
Here are some examples of use of the \fBword\-context\fP style to extend
the context\&.
.PP
.RS
.nf
\fBzstyle \&':zle:*' word\-context "*/*" file "[[:space:]]" whitespace
zstyle \&':zle:transpose\-words:whitespace' word\-style shell
zstyle \&':zle:transpose\-words:filename' word\-style normal
zstyle \&':zle:transpose\-words:filename' word\-chars ''\fP
.fi
.RE
.PP
This provides two different ways of using \fBtranspose\-words\fP depending on
whether the cursor is on whitespace between words or on a filename, here
any word containing a \fB/\fP\&. On whitespace, complete arguments as defined
by standard shell rules will be transposed\&. In a filename, only
alphanumerics will be transposed\&. Elsewhere, words will be transposed
using the default style for \fB:zle:transpose\-words\fP\&.
.PP
The word matching and all the handling of \fBzstyle\fP settings is actually
implemented by the function \fBmatch\-words\-by\-style\fP\&. This can be used to
create new user\-defined widgets\&. The calling function should set the local
parameter \fBcurcontext\fP to \fB:zle:\fP\fIwidget\fP, create the local
parameter \fBmatched_words\fP and call \fBmatch\-words\-by\-style\fP with no
arguments\&. On return, \fBmatched_words\fP will be set to an array with the
elements: (1) the start of the line (2) the word before the cursor (3) any
non\-word characters between that word and the cursor (4) any non\-word
character at the cursor position plus any remaining non\-word characters
before the next word, including all characters specified by the
\fBskip\-chars\fP style, (5) the word at or following the cursor (6) any
non\-word characters following that word (7) the remainder of the line\&. Any
of the elements may be an empty string; the calling function should test
for this to decide whether it can perform its function\&.
.PP
It is possible to pass options with arguments to \fBmatch\-words\-by\-style\fP
to override the use of styles\&. The options are:
.PD 0
.TP
\fB\-w\fP
\fIword\-style\fP
.TP
\fB\-s\fP
\fIskip\-chars\fP
.TP
\fB\-c\fP
\fIword\-class\fP
.TP
\fB\-C\fP
\fIword\-chars\fP
.PD
.PP
For example, \fBmatch\-words\-by\-style \-w shell \-c 0\fP may be used to
extract the command argument around the cursor\&.
.PP
The \fBword\-context\fP style is implemented by the function
\fBmatch\-word\-context\fP\&. This should not usually need to be called
directly\&.
.RE
.TP
\fBdelete\-whole\-word\-match\fP
This is another function which works like the \fB\-match\fP functions
described immediately above, i\&.e\&. using styles to decide the word
boundaries\&. However, it is not a replacement for any existing function\&.
.RS
.PP
The basic behaviour is to delete the word around the cursor\&. There is no
numeric prefix handling; only the single word around the cursor is
considered\&. If the widget contains the string \fBkill\fP, the removed text
will be placed in the cutbuffer for future yanking\&. This can be obtained
by defining \fBkill\-whole\-word\-match\fP as follows:
.PP
.RS
.nf
\fBzle \-N kill\-whole\-word\-match delete\-whole\-word\-match\fP
.fi
.RE
.PP
and then binding the widget \fBkill\-whole\-word\-match\fP\&.
.RE
.TP
\fBcopy\-earlier\-word\fP
This widget works like a combination of \fBinsert\-last\-word\fP and
\fBcopy\-prev\-shell\-word\fP\&. Repeated invocations of the widget retrieve
earlier words on the relevant history line\&. With a numeric argument
\fIN\fP, insert the \fIN\fPth word from the history line; \fIN\fP may be
negative to count from the end of the line\&.
.RS
.PP
If \fBinsert\-last\-word\fP has been used to retrieve the last word on a
previous history line, repeated invocations will replace that word with
earlier words from the same line\&.
.PP
Otherwise, the widget applies to words on the line currently being edited\&.
The \fBwidget\fP style can be set to the name of another widget that should
be called to retrieve words\&. This widget must accept the same three
arguments as \fBinsert\-last\-word\fP\&.
.RE
.TP
\fBcycle\-completion\-positions\fP
After inserting an unambiguous string into the command line, the new
function based completion system may know about multiple places in
this string where characters are missing or differ from at least one
of the possible matches\&. It will then place the cursor on the
position it considers to be the most interesting one, i\&.e\&. the one
where one can disambiguate between as many matches as possible with as
little typing as possible\&.
.RS
.PP
This widget allows the cursor to be easily moved to the other interesting
spots\&. It can be invoked repeatedly to cycle between all positions
reported by the completion system\&.
.RE
.TP
\fBedit\-command\-line\fP
Edit the command line using your visual editor, as in \fBksh\fP\&.
.RS
.PP
.RS
.nf
\fBbindkey \-M vicmd v edit\-command\-line\fP
.fi
.RE
.RE
.TP
\fBhistory\-search\-end\fP
This function implements the widgets
\fBhistory\-beginning\-search\-backward\-end\fP and
\fBhistory\-beginning\-search\-forward\-end\fP\&. These commands work by first
calling the corresponding builtin widget (see
`History Control\&' in \fIzshzle\fP(1)) and then moving the cursor to the end of the line\&. The original cursor
position is remembered and restored before calling the builtin widget a
second time, so that the same search is repeated to look farther through
the history\&.
.RS
.PP
Although you \fBautoload\fP only one function, the commands to use it are
slightly different because it implements two widgets\&.
.PP
.RS
.nf
\fBzle \-N history\-beginning\-search\-backward\-end \e
history\-search\-end
zle \-N history\-beginning\-search\-forward\-end \e
history\-search\-end
bindkey \&'\ee^P' history\-beginning\-search\-backward\-end
bindkey \&'\ee^N' history\-beginning\-search\-forward\-end\fP
.fi
.RE
.RE
.TP
\fBhistory\-beginning\-search\-menu\fP
This function implements yet another form of history searching\&. The
text before the cursor is used to select lines from the history,
as for \fBhistory\-beginning\-search\-backward\fP except that all matches are
shown in a numbered menu\&. Typing the appropriate digits inserts the
full history line\&. Note that leading zeroes must be typed (they are only
shown when necessary for removing ambiguity)\&. The entire history is
searched; there is no distinction between forwards and backwards\&.
.RS
.PP
With a prefix argument, the search is not anchored to the start of
the line; the string typed by the use may appear anywhere in the line
in the history\&.
.PP
If the widget name contains `\fB\-end\fP\&' the cursor is moved to the end of
the line inserted\&. If the widget name contains `\fB\-space\fP\&' any space
in the text typed is treated as a wildcard and can match anything (hence
a leading space is equivalent to giving a prefix argument)\&. Both
forms can be combined, for example:
.PP
.RS
.nf
\fBzle \-N history\-beginning\-search\-menu\-space\-end \e
history\-beginning\-search\-menu\fP
.fi
.RE
.RE
.TP
\fBhistory\-pattern\-search\fP
The function \fBhistory\-pattern\-search\fP implements widgets which prompt
for a pattern with which to search the history backwards or forwards\&. The
pattern is in the usual zsh format, however the first character may be
\fB^\fP to anchor the search to the start of the line, and the last character
may be \fB$\fP to anchor the search to the end of the line\&. If the
search was not anchored to the end of the line the cursor is positioned
just after the pattern found\&.
.RS
.PP
The commands to create bindable widgets are similar to those in the
example immediately above:
.PP
.RS
.nf
\fBautoload \-U history\-pattern\-search
zle \-N history\-pattern\-search\-backward history\-pattern\-search
zle \-N history\-pattern\-search\-forward history\-pattern\-search\fP
.fi
.RE
.RE
.TP
\fBup\-line\-or\-beginning\-search\fP, \fBdown\-line\-or\-beginning\-search\fP
These widgets are similar to the builtin functions \fBup\-line\-or\-search\fP
and \fBdown\-line\-or\-search\fP: if in a multiline buffer they move up or
down within the buffer, otherwise they search for a history line matching
the start of the current line\&. In this case, however, they search for
a line which matches the current line up to the current cursor position, in
the manner of \fBhistory\-beginning\-search\-backward\fP and \fB\-forward\fP, rather
than the first word on the line\&.
.TP
\fBincarg\fP
Typing the keystrokes for this widget with the cursor placed on or to the
left of an integer causes that integer to be incremented by one\&. With a
numeric prefix argument, the number is incremented by the amount of the
argument (decremented if the prefix argument is negative)\&. The shell
parameter \fBincarg\fP may be set to change the default increment to
something other than one\&.
.RS
.PP
.RS
.nf
\fBbindkey \&'^X+' incarg\fP
.fi
.RE
.RE
.TP
\fBincremental\-complete\-word\fP
This allows incremental completion of a word\&. After starting this
command, a list of completion choices can be shown after every character
you type, which you can delete with \fB^H\fP or \fBDEL\fP\&. Pressing return
accepts the completion so far and returns you to normal editing (that is,
the command line is \fInot\fP immediately executed)\&. You can hit \fBTAB\fP to
do normal completion, \fB^G\fP to abort back to the state when you started,
and \fB^D\fP to list the matches\&.
.RS
.PP
This works only with the new function based completion system\&.
.PP
.RS
.nf
\fBbindkey \&'^Xi' incremental\-complete\-word\fP
.fi
.RE
.RE
.TP
\fBinsert\-composed\-char\fP
This function allows you to compose characters that don\&'t appear on the
keyboard to be inserted into the command line\&. The command is followed by
two keys corresponding to ASCII characters (there is no prompt)\&. For
accented characters, the two keys are a base character followed by a code
for the accent, while for other special characters the two characters
together form a mnemonic for the character to be inserted\&. The
two\-character codes are a subset of those given by RFC 1345 (see for
example \fBhttp://www\&.faqs\&.org/rfcs/rfc1345\&.html\fP)\&.
.RS
.PP
The function may optionally be followed by up to two characters which
replace one or both of the characters read from the keyboard; if both
characters are supplied, no input is read\&. For example,
\fBinsert\-composed\-char a:\fP can be used within a widget to insert an a with
umlaut into the command line\&. This has the advantages over use of a
literal character that it is more portable\&.
.PP
For best results zsh should have been built with support for multibyte
characters (configured with \fB\-\-enable\-multibyte\fP); however, the function
works for the limited range of characters available in single\-byte
character sets such as ISO\-8859\-1\&.
.PP
The character is converted into the local representation and
inserted into the command line at the cursor position\&.
(The conversion is done within the shell, using whatever facilities
the C library provides\&.) With a numeric argument, the character and its
code are previewed in the status line
.PP
The function may be run outside zle in which case it prints the character
(together with a newline) to standard output\&. Input is still read from
keystrokes\&.
.PP
See \fBinsert\-unicode\-char\fP for an alternative way of inserting Unicode
characters using their hexadecimal character number\&.
.PP
The set of accented characters is reasonably complete up to Unicode
character U+0180, the set of special characters less so\&. However, it it
is very sporadic from that point\&. Adding new characters is easy,
however; see the function \fBdefine\-composed\-chars\fP\&. Please send any
additions to \fBzsh\-workers@sunsite\&.dk\fP\&.
.PP
The codes for the second character when used to accent the first are as
follows\&. Note that not every character can take every accent\&.
.PD 0
.TP
\fB!\fP
Grave\&.
.TP
\fB\&'\fP
Acute\&.
.TP
\fB>\fP
Circumflex\&.
.TP
\fB?\fP
Tilde\&. (This is not \fB~\fP as RFC 1345 does not assume that
character is present on the keyboard\&.)
.TP
\fB\-\fP
Macron\&. (A horizonal bar over the base character\&.)
.TP
\fB(\fP
Breve\&. (A shallow dish shape over the base character\&.)
.TP
\fB\&.\fP
Dot above the base character, or in the case of \fBi\fP no dot,
or in the case of \fBL\fP and \fBl\fP a centered dot\&.
.TP
\fB:\fP
Diaeresis (Umlaut)\&.
.TP
\fBc\fP
Cedilla\&.
.TP
\fB_\fP
Underline, however there are currently no underlined characters\&.
.TP
\fB/\fP
Stroke through the base character\&.
.TP
\fB"\fP
Double acute (only supported on a few letters)\&.
.TP
\fB;\fP
Ogonek\&. (A little forward facing hook at the bottom right
of the character\&.)
.TP
\fB<\fP
Caron\&. (A little v over the letter\&.)
.TP
\fB0\fP
Circle over the base character\&.
.TP
\fB2\fP
Hook over the base character\&.
.TP
\fB9\fP
Horn over the base character\&.
.PD
.PP
The most common characters from the Arabic, Cyrillic, Greek and Hebrew
alphabets are available; consult RFC 1345 for the appropriate sequences\&.
In addition, a set of two letter codes not in RFC 1345 are available for
the double\-width characters corresponding to ASCII characters from \fB!\fP
to \fB~\fP (0x21 to 0x7e) by preceeding the character with \fB^\fP, for
example \fB^A\fP for a double\-width \fBA\fP\&.
.PP
The following other two\-character sequences are understood\&.
.PP
.PD 0
.TP
.PD
ASCII characters
These are already present on most keyboards:
.PD 0
.TP
\fB<(\fP
Left square bracket
.TP
\fB//\fP
Backslash (solidus)
.TP
\fB)>\fP
Right square bracket
.TP
\fB(!\fP
Left brace (curly bracket)
.TP
\fB!!\fP
Vertical bar (pipe symbol)
.TP
\fB!)\fP
Right brace (curly bracket)
.TP
\fB\&'?\fP
Tilde
.PD
.TP
Special letters
Characters found in various variants of the Latin alphabet:
.PD 0
.TP
\fBss\fP
Eszett (scafes S)
.TP
\fBD\-\fP, \fBd\-\fP
Eth
.TP
\fBTH\fP, \fBth\fP
Thorn
.TP
\fBkk\fP
Kra
.TP
\fB\&'n\fP
\&'n
.TP
\fBNG\fP, \fBng\fP
Ng
.TP
\fBOI\fP, \fBoi\fP
Oi
.TP
\fByr\fP
yr
.TP
\fBED\fP
ezh
.PD
.TP
Currency symbols
.PD 0
.TP
\fBCt\fP
Cent
.TP
\fBPd\fP
Pound sterling (also lira and others)
.TP
\fBCu\fP
Currency
.TP
\fBYe\fP
Yen
.TP
\fBEu\fP
Euro (N\&.B\&. not in RFC 1345)
.PD
.TP
Punctuation characters
References to "right" quotes indicate the shape (like a 9 rather than 6)
rather than their grammatical use\&. (For example, a "right" low double
quote is used to open quotations in German\&.)
.PD 0
.TP
\fB!I\fP
Inverted exclamation mark
.TP
\fBBB\fP
Broken vertical bar
.TP
\fBSE\fP
Section
.TP
\fBCo\fP
Copyright
.TP
\fB\-a\fP
Spanish feminine ordinal indicator
.TP
\fB<<\fP
Left guillemet
.TP
\fB\-\-\fP
Soft hyphen
.TP
\fBRg\fP
Registered trade mark
.TP
\fBPI\fP
Pilcrow (paragraph)
.TP
\fB\-o\fP
Spanish masculine ordinal indicator
.TP
\fB>>\fP
Right guillemet
.TP
\fB?I\fP
Inverted question mark
.TP
\fB\-1\fP
Hyphen
.TP
\fB\-N\fP
En dash
.TP
\fB\-M\fP
Em dash
.TP
\fB\-3\fP
Horizontal bar
.TP
\fB:3\fP
Vertical ellipsis
.TP
\fB\&.3\fP
Horizontal midline ellipsis
.TP
\fB!2\fP
Double vertical line
.TP
\fB=2\fP
Double low line
.TP
\fB\&'6\fP
Left single quote
.TP
\fB\&'9\fP
Right single quote
.TP
\fB\&.9\fP
"Right" low quote
.TP
\fB9\&'\fP
Reversed "right" quote
.TP
\fB"6\fP
Left double quote
.TP
\fB"9\fP
Right double quote
.TP
\fB:9\fP
"Right" low double quote
.TP
\fB9"\fP
Reversed "right" double quote
.TP
\fB/\-\fP
Dagger
.TP
\fB/=\fP
Double dagger
.PD
.TP
Mathematical symbols
.PD 0
.TP
\fBDG\fP
Degree
.TP
\fB\-2\fP, \fB+\-\fP, \fB\-+\fP
\- sign, +/\- sign, \-/+ sign
.TP
\fB2S\fP
Superscript 2
.TP
\fB3S\fP
Superscript 3
.TP
\fB1S\fP
Superscript 1
.TP
\fBMy\fP
Micro
.TP
\fB\&.M\fP
Middle dot
.TP
\fB14\fP
Quarter
.TP
\fB12\fP
Half
.TP
\fB34\fP
Three quarters
.TP
\fB*X\fP
Multiplication
.TP
\fB\-:\fP
Division
.TP
\fB%0\fP
Per mille
.TP
\fBFA\fP, \fBTE\fP, \fB/0\fP
For all, there exists, empty set
.TP
\fBdP\fP, \fBDE\fP, \fBNB\fP
Partial derivative, delta (increment), del
(nabla)
.TP
\fB(\-\fP, \fB\-)\fP
Element of, contains
.TP
\fB*P\fP, \fB+Z\fP
Product, sum
.TP
\fB*\-\fP, \fBOb\fP, \fBSb\fP
Asterisk, ring, bullet
.TP
\fBRT\fP, \fB0(\fP, \fB00\fP
Root sign, proportional to, infinity
.PD
.TP
Other symbols
.PD 0
.TP
\fBcS\fP, \fBcH\fP, \fBcD\fP, \fBcC\fP
Card suits: spades, hearts, diamonds,
clubs
.TP
\fBMd\fP, \fBM8\fP, \fBM2\fP, \fBMb\fP, \fBMx\fP, \fBMX\fP
Musical notation:
crotchet (quarter note), quaver (eighth note), semiquavers (sixteenth
notes), flag sign, natural signa, sharp sign
.TP
\fBFm\fP, \fBMl\fP
Female, male
.PD
.TP
Accents on their own
.PD 0
.TP
\fB\&'>\fP
Circumflex (same as caret, \fB^\fP)
.TP
\fB\&'!\fP
Grave (same as backtick, \fB`\fP)
.TP
\fB\&',\fP
Cedilla
.TP
\fB\&':\fP
Diaeresis (Umlaut)
.TP
\fB\&'m\fP
Macron
.TP
\fB\&''\fP
Acute
.PD
.RE
.TP
\fBinsert\-files\fP
This function allows you type a file pattern, and see the results of the
expansion at each step\&. When you hit return, all expansions are inserted
into the command line\&.
.RS
.PP
.RS
.nf
\fBbindkey \&'^Xf' insert\-files\fP
.fi
.RE
.RE
.TP
.PD 0
\fBnarrow\-to\-region [ \-p\fP \fIpre\fP \fB] [ \-P\fP \fIpost\fP \fB]\fP
.TP
.PD 0
\fB[ \-S\fP \fIstatepm\fP \fB| \-R\fP \fIstatepm\fP \fB] [ \-n ] [\fP \fIstart\fP \fIend\fP \fB]\fP)
.TP
.PD
\fBnarrow\-to\-region\-invisible\fP
Narrow the editable portion of the buffer to the region between the cursor
and the mark, which may be in either order\&. The region may not be empty\&.
.RS
.PP
\fBnarrow\-to\-region\fP may be used as a widget or called as a function from a
user\-defined widget; by default, the text outside the editable area remains
visible\&. A \fBrecursive\-edit\fP is performed and the original widening
status is then restored\&. Various options and arguments are available when
it is called as a function\&.
.PP
The options \fB\-p\fP \fIpretext\fP and \fB\-P\fP \fIposttext\fP may be
used to replace the text before and after the display for the duration of
the function; either or both may be an empty string\&.
.PP
If the option \fB\-n\fP is also given, \fIpretext\fP or \fIposttext\fP will only
be inserted if there is text before or after the region respectively which
will be made invisible\&.
.PP
Two numeric arguments may be given which will be used instead of the cursor
and mark positions\&.
.PP
The option \fB\-S\fP \fIstatepm\fP is used to narrow according to the other
options while saving the original state in the parameter with name
\fIstatepm\fP, while the option \fB\-R\fP \fIstatepm\fP is used to restore the
state from the parameter; note in both cases the \fIname\fP of the parameter
is required\&. In the second case, other options and arguments are
irrelevant\&. When this method is used, no \fBrecursive\-edit\fP is performed;
the calling widget should call this function with the option \fB\-S\fP,
perform its own editing on the command line or pass control to the user
via `\fBzle recursive\-edit\fP\&', then call this function with the option
\fB\-R\fP\&. The argument \fIstatepm\fP must be a suitable name for an ordinary
parameter, except that parameters beginning with the prefix \fB_ntr_\fP are
reserved for use within \fBnarrow\-to\-region\fP\&. Typically the parameter will
be local to the calling function\&.
.PP
\fBnarrow\-to\-region\-invisible\fP is a simple widget which calls
\fBnarrow\-to\-region\fP with arguments which replace any text outside the
region with `\fB\&.\&.\&.\fP\&'\&.
.PP
The display is restored (and the widget returns) upon any zle command
which would usually cause the line to be accepted or aborted\&. Hence an
additional such command is required to accept or abort the current line\&.
.PP
The return status of both widgets is zero if the line was accepted, else
non\-zero\&.
.PP
Here is a trivial example of a widget using this feature\&.
.RS
.nf
\fBlocal state
narrow\-to\-region \-p $\&'Editing restricted region\en' \e
\-P \&'' \-S state
zle recursive\-edit
narrow\-to\-region \-R state\fP
.fi
.RE
.RE
.TP
\fBinsert\-unicode\-char\fP
When first executed, the user inputs a set of hexadecimal digits\&.
This is terminated with another call to \fBinsert\-unicode\-char\fP\&.
The digits are then turned into the corresponding Unicode character\&.
For example, if the widget is bound to \fB^XU\fP, the character sequence
`\fB^XU 4 c ^XU\fP\&' inserts \fBL\fP (Unicode U+004c)\&.
.RS
.PP
See \fBinsert\-composed\-char\fP for a way of inserting characters
using a two\-character mnemonic\&.
.RE
.TP
\fBpredict\-on\fP
This set of functions implements predictive typing using history search\&.
After \fBpredict\-on\fP, typing characters causes the editor to look backward
in the history for the first line beginning with what you have typed so
far\&. After \fBpredict\-off\fP, editing returns to normal for the line found\&.
In fact, you often don\&'t even need to use \fBpredict\-off\fP, because if the
line doesn\&'t match something in the history, adding a key performs
standard completion, and then inserts itself if no completions were found\&.
However, editing in the middle of a line is liable to confuse prediction;
see the \fBtoggle\fP style below\&.
.RS
.PP
With the function based completion system (which is needed for this), you
should be able to type \fBTAB\fP at almost any point to advance the cursor
to the next ``interesting\&'' character position (usually the end of the
current word, but sometimes somewhere in the middle of the word)\&. And of
course as soon as the entire line is what you want, you can accept with
return, without needing to move the cursor to the end first\&.
.PP
The first time \fBpredict\-on\fP is used, it creates several additional
widget functions:
.PP
.PD 0
.TP
\fBdelete\-backward\-and\-predict\fP
Replaces the \fBbackward\-delete\-char\fP
widget\&. You do not need to bind this yourself\&.
.TP
\fBinsert\-and\-predict\fP
Implements predictive typing by replacing the
\fBself\-insert\fP widget\&. You do not need to bind this yourself\&.
.TP
\fBpredict\-off\fP
Turns off predictive typing\&.
.PD
.PP
Although you \fBautoload\fP only the \fBpredict\-on\fP function, it is
necessary to create a keybinding for \fBpredict\-off\fP as well\&.
.PP
.RS
.nf
\fBzle \-N predict\-on
zle \-N predict\-off
bindkey \&'^X^Z' predict\-on
bindkey \&'^Z' predict\-off\fP
.fi
.RE
.RE
.TP
\fBread\-from\-minibuffer\fP
This is most useful when called as a function from inside a widget, but will
work correctly as a widget in its own right\&. It prompts for a value
below the current command line; a value may be input using all of the
standard zle operations (and not merely the restricted set available
when executing, for example, \fBexecute\-named\-cmd\fP)\&. The value is then
returned to the calling function in the parameter \fB$REPLY\fP and the
editing buffer restored to its previous state\&. If the read was aborted
by a keyboard break (typically \fB^G\fP), the function returns status 1
and \fB$REPLY\fP is not set\&.
.RS
.PP
If one argument is supplied to the function it is taken as a prompt,
otherwise `\fB? \fP\&' is used\&. If two arguments are supplied, they are the
prompt and the initial value of \fB$LBUFFER\fP, and if a third argument is
given it is the initial value of \fB$RBUFFER\fP\&. This provides a default
value and starting cursor placement\&. Upon return the entire buffer is the
value of \fB$REPLY\fP\&.
.PP
One option is available: `\fB\-k\fP \fInum\fP\&' specifies that \fInum\fP
characters are to be read instead of a whole line\&. The line editor is not
invoked recursively in this case, so depending on the terminal settings
the input may not be visible, and only the input keys are placed in
\fB$REPLY\fP, not the entire buffer\&. Note that unlike the \fBread\fP builtin
\fInum\fP must be given; there is no default\&.
.PP
The name is a slight misnomer, as in fact the shell\&'s own minibuffer is
not used\&. Hence it is still possible to call \fBexecuted\-named\-cmd\fP and
similar functions while reading a value\&.
.RE
.TP
.PD 0
\fBreplace\-string\fP, \fBreplace\-pattern\fP
.TP
.PD
\fBreplace\-string\-again\fP, \fBreplace\-pattern\-again\fP
The function \fBreplace\-string\fP implements two widgets\&.
If defined under the same name as the function, it prompts for two
strings; the first (source) string will be replaced by the second
everywhere it occurs in the line editing buffer\&.
.RS
.PP
If the widget name contains the word `\fBpattern\fP\&', for example by
defining the widget using the command `\fBzle \-N replace\-pattern
replace\-string\fP\&', then the replacement is done by pattern matching\&. All
zsh extended globbing patterns can be used in the source string; note
that unlike filename generation the pattern does not need to match an
entire word, nor do glob qualifiers have any effect\&. In addition, the
replacement string can contain parameter or command substitutions\&.
Furthermore, a `\fB&\fP\&' in the replacement string will be replaced with
the matched source string, and a backquoted digit `\fB\e\fP\fIN\fP\&' will be
replaced by the \fIN\fPth parenthesised expression matched\&. The form
`\fB\e{\fP\fIN\fP\fB}\fP\&' may be used to protect the digit from following
digits\&.
.PP
By default the previous source or replacement string will not be offered
for editing\&. However, this feature can be activated by setting the style
\fBedit\-previous\fP in the context \fB:zle:\fP\fIwidget\fP (for example,
\fB:zle:replace\-string\fP) to \fBtrue\fP\&. In addition, a positive
numeric argument forces the previous values to be offered, a negative or
zero argument forces them not to be\&.
.PP
The function \fBreplace\-string\-again\fP can be used to repeat the
previous replacement; no prompting is done\&. As with \fBreplace\-string\fP, if
the name of the widget contains the word `\fBpattern\fP\&', pattern matching
is performed, else a literal string replacement\&. Note that the
previous source and replacement text are the same whether pattern or string
matching is used\&.
.PP
For example, starting from the line:
.PP
.RS
.nf
\fBprint This line contains fan and fond\fP
.fi
.RE
.PP
and invoking \fBreplace\-pattern\fP with the source string
`\fBf(?)n\fP\&' and
the replacment string `\fBc\e1r\fP\&' produces the not very useful line:
.PP
.RS
.nf
\fBprint This line contains car and cord\fP
.fi
.RE
.PP
The range of the replacement string can be limited by using the
\fBnarrow\-to\-region\-invisible\fP widget\&. One limitation of the current
version is that \fBundo\fP will cycle through changes to the replacement
and source strings before undoing the replacement itself\&.
.RE
.TP
\fBsmart\-insert\-last\-word\fP
This function may replace the \fBinsert\-last\-word\fP widget, like so:
.RS
.PP
.RS
.nf
\fBzle \-N insert\-last\-word smart\-insert\-last\-word\fP
.fi
.RE
.PP
With a numeric prefix, or when passed command line arguments in a call
from another widget, it behaves like \fBinsert\-last\-word\fP, except that
words in comments are ignored when \fBINTERACTIVE_COMMENTS\fP is set\&.
.PP
Otherwise, the rightmost ``interesting\&'' word from the previous command is
found and inserted\&. The default definition of ``interesting\&'' is that the
word contains at least one alphabetic character, slash, or backslash\&.
This definition may be overridden by use of the \fBmatch\fP style\&. The
context used to look up the style is the widget name, so usually the
context is \fB:insert\-last\-word\fP\&. However, you can bind this function to
different widgets to use different patterns:
.PP
.RS
.nf
\fBzle \-N insert\-last\-assignment smart\-insert\-last\-word
zstyle :insert\-last\-assignment match \&'[[:alpha:]][][[:alnum:]]#=*'
bindkey \&'\ee=' insert\-last\-assignment\fP
.fi
.RE
.RE
.TP
\fBwhich\-command\fP
This function is a drop\-in replacement for the builtin widget
\fBwhich\-command\fP\&. It has enhanced behaviour, in that it correctly
detects whether or not the command word needs to be expanded as an
alias; if so, it continues tracing the command word from the expanded
alias until it reaches the command that will be executed\&.
.RS
.PP
The style \fBwhence\fP is available in the context \fB:zle:$WIDGET\fP; this
may be set to an array to give the command and options that will be used to
investigate the command word found\&. The default is \fBwhence \-c\fP\&.
.RE
.RE
.PP
.SS "Styles"
.PP
The behavior of several of the above widgets can be controlled by the use
of the \fBzstyle\fP mechanism\&. In particular, widgets that interact with
the completion system pass along their context to any completions that
they invoke\&.
.PP
.PD 0
.TP
.PD
\fBbreak\-keys\fP
This style is used by the \fBincremental\-complete\-word\fP widget\&. Its value
should be a pattern, and all keys matching this pattern will cause the
widget to stop incremental completion without the key having any further
effect\&. Like all styles used directly by
\fBincremental\-complete\-word\fP, this style is looked up using the
context `\fB:incremental\fP\&'\&.
.TP
\fBcompleter\fP
The \fBincremental\-complete\-word\fP and \fBinsert\-and\-predict\fP widgets set
up their top\-level context name before calling completion\&. This allows
one to define different sets of completer functions for normal completion
and for these widgets\&. For example, to use completion, approximation and
correction for normal completion, completion and correction for
incremental completion and only completion for prediction one could use:
.RS
.PP
.RS
.nf
\fBzstyle \&':completion:*' completer \e
_complete _correct _approximate
zstyle \&':completion:incremental:*' completer \e
_complete _correct
zstyle \&':completion:predict:*' completer \e
_complete\fP
.fi
.RE
.PP
It is a good idea to restrict the completers used in prediction, because
they may be automatically invoked as you type\&. The \fB_list\fP and
\fB_menu\fP completers should never be used with prediction\&. The
\fB_approximate\fP, \fB_correct\fP, \fB_expand\fP, and \fB_match\fP completers may
be used, but be aware that they may change characters anywhere in the word
behind the cursor, so you need to watch carefully that the result is what
you intended\&.
.RE
.TP
\fBcursor\fP
The \fBinsert\-and\-predict\fP widget uses this style, in the context
`\fB:predict\fP\&', to decide where to place the cursor after completion has
been tried\&. Values are:
.RS
.PP
.PD 0
.TP
.PD
\fBcomplete\fP
The cursor is left where it was when completion finished, but only if
it is after a character equal to the one just inserted by the user\&. If
it is after another character, this value is the same as `\fBkey\fP\&'\&.
.TP
\fBkey\fP
The cursor is left
after the \fIn\fPth occurrence of the character just inserted, where
\fIn\fP is the number of times that character appeared in the word
before completion was attempted\&. In short, this has the effect of
leaving the cursor after the character just typed even if the
completion code found out that no other characters need to be inserted
at that position\&.
.PP
Any other value for this style unconditionally leaves the cursor at the
position where the completion code left it\&.
.RE
.TP
\fBlist\fP
When using the \fBincremental\-complete\-word\fP widget, this style says
if the matches should be listed on every key press (if they fit on the
screen)\&. Use the context prefix `\fB:completion:incremental\fP\&'\&.
.RS
.PP
The \fBinsert\-and\-predict\fP widget uses this style to decide if the
completion should be shown even if there is only one possible completion\&.
This is done if the value of this style is the string \fBalways\fP\&. In this
case the context is `\fB:predict\fP\&' (\fInot\fP `\fB:completion:predict\fP')\&.
.RE
.TP
\fBmatch\fP
This style is used by \fBsmart\-insert\-last\-word\fP to provide a pattern
(using full \fBEXTENDED_GLOB\fP syntax) that matches an interesting word\&.
The context is the name of the widget to which \fBsmart\-insert\-last\-word\fP
is bound (see above)\&. The default behavior of \fBsmart\-insert\-last\-word\fP
is equivalent to:
.RS
.PP
.RS
.nf
\fBzstyle :insert\-last\-word match \&'*[[:alpha:]/\e\e]*'\fP
.fi
.RE
.PP
However, you might want to include words that contain spaces:
.PP
.RS
.nf
\fBzstyle :insert\-last\-word match \&'*[[:alpha:][:space:]/\e\e]*'\fP
.fi
.RE
.PP
Or include numbers as long as the word is at least two characters long:
.PP
.RS
.nf
\fBzstyle :insert\-last\-word match \&'*([[:digit:]]?|[[:alpha:]/\e\e])*'\fP
.fi
.RE
.PP
The above example causes redirections like "2>" to be included\&.
.RE
.TP
\fBprompt\fP
The \fBincremental\-complete\-word\fP widget shows the value of this
style in the status line during incremental completion\&. The string
value may contain any of the following substrings in the manner of
the \fBPS1\fP and other prompt parameters:
.RS
.PP
.PD 0
.TP
.PD
\fB%c\fP
Replaced by the name of the completer function that generated the
matches (without the leading underscore)\&.
.TP
\fB%l\fP
When the \fBlist\fP style is set,
replaced by `\fB\&.\&.\&.\fP\&' if the list of matches is too long to fit on the
screen and with an empty string otherwise\&. If the \fBlist\fP style is
`false\&' or not set, `\fB%l\fP' is always removed\&.
.TP
\fB%n\fP
Replaced by the number of matches generated\&.
.TP
\fB%s\fP
Replaced by `\fB\-no match\-\fP\&', `\fB\-no prefix\-\fP', or an empty string
if there is no completion matching the word on the line, if the
matches have no common prefix different from the word on the line, or
if there is such a common prefix, respectively\&.
.TP
\fB%u\fP
Replaced by the unambiguous part of all matches, if there
is any, and if it is different from the word on the line\&.
.PP
Like `\fBbreak\-keys\fP\&', this uses the `\fB:incremental\fP' context\&.
.RE
.TP
\fBstop\-keys\fP
This style is used by the \fBincremental\-complete\-word\fP widget\&. Its value
is treated similarly to the one for the \fBbreak\-keys\fP style (and uses
the same context: `\fB:incremental\fP\&')\&. However, in
this case all keys matching the pattern given as its value will stop
incremental completion and will then execute their usual function\&.
.TP
\fBtoggle\fP
This boolean style is used by \fBpredict\-on\fP and its related widgets in
the context `\fB:predict\fP\&'\&. If set to one of the standard `true' values,
predictive typing is automatically toggled off in situations where it is
unlikely to be useful, such as when editing a multi\-line buffer or after
moving into the middle of a line and then deleting a character\&. The
default is to leave prediction turned on until an explicit call to
\fBpredict\-off\fP\&.
.TP
\fBverbose\fP
This boolean style is used by \fBpredict\-on\fP and its related widgets in
the context `\fB:predict\fP\&'\&. If set to one of the standard `true' values,
these widgets display a message below the prompt when the predictive state
is toggled\&. This is most useful in combination with the \fBtoggle\fP style\&.
The default does not display these messages\&.
.TP
\fBwidget\fP
This style is similar to the \fBcommand\fP style: For widget functions that
use \fBzle\fP to call other widgets, this style can sometimes be used to
override the widget which is called\&. The context for this style is the
name of the calling widget (\fInot\fP the name of the calling function,
because one function may be bound to multiple widget names)\&.
.RS
.PP
.RS
.nf
\fBzstyle :copy\-earlier\-word widget smart\-insert\-last\-word\fP
.fi
.RE
.PP
Check the documentation for the calling widget or function to determine
whether the \fBwidget\fP style is used\&.
.RE
.RE
.PP
.SH "EXCEPTION HANDLING"
.PP
Two functions are provided to enable zsh to provide exception handling in a
form that should be familiar from other languages\&.
.PP
.PD 0
.TP
.PD
\fBthrow\fP \fIexception\fP
The function \fBthrow\fP throws the named \fIexception\fP\&. The name is
an arbitrary string and is only used by the \fBthrow\fP and \fBcatch\fP
functions\&. An exception is for the most part treated the same as a
shell error, i\&.e\&. an unhandled exception will cause the shell to abort all
processing in a function or script and to return to the top level in an
interactive shell\&.
.TP
\fBcatch\fP \fIexception\-pattern\fP
The function \fBcatch\fP returns status zero if an exception was thrown and
the pattern \fIexception\-pattern\fP matches its name\&. Otherwise it
returns status 1\&. \fIexception\-pattern\fP is a standard
shell pattern, respecting the current setting of the \fBEXTENDED_GLOB\fP
option\&. An alias \fBcatch\fP is also defined to prevent the argument to the
function from matching filenames, so patterns may be used unquoted\&. Note
that as exceptions are not fundamentally different from other shell errors
it is possible to catch shell errors by using an empty string as the
exception name\&. The shell variable \fBCAUGHT\fP is set by \fBcatch\fP to the
name of the exception caught\&. It is possible to rethrow an exception by
calling the \fBthrow\fP function again once an exception has been caught\&.
.PP
The functions are designed to be used together with the \fBalways\fP construct
described in
\fIzshmisc\fP(1)\&. This is important as only this
construct provides the required support for exceptions\&. A typical example
is as follows\&.
.PP
.RS
.nf
\fB{
# "try" block
# \&.\&.\&. nested code here calls "throw MyExcept"
} always {
# "always" block
if catch MyExcept; then
print "Caught exception MyExcept"
elif catch \&''; then
print "Caught a shell error\&. Propagating\&.\&.\&."
throw \&''
fi
# Other exceptions are not handled but may be caught further
# up the call stack\&.
}\fP
.fi
.RE
.PP
If all exceptions should be caught, the following idiom might be
preferable\&.
.PP
.RS
.nf
\fB{
# \&.\&.\&. nested code here throws an exception
} always {
if catch *; then
case $CAUGHT in
(MyExcept)
print "Caught my own exception"
;;
(*)
print "Caught some other exception"
;;
esac
fi
}\fP
.fi
.RE
.PP
In common with exception handling in other languages, the exception may be
thrown by code deeply nested inside the `try\&' block\&. However, note that it
must be thrown inside the current shell, not in a subshell forked for a
pipeline, parenthesised current\-shell construct, or some form of
command or process substitution\&.
.PP
The system internally uses the shell variable \fBEXCEPTION\fP to record the
name of the exception between throwing and catching\&. One drawback of this
scheme is that if the exception is not handled the variable \fBEXCEPTION\fP
remains set and may be incorrectly recognised as the name of an exception
if a shell error subsequently occurs\&. Adding \fBunset EXCEPTION\fP at the
start of the outermost layer of any code that uses exception handling will
eliminate this problem\&.
.PP
.SH "MIME FUNCTIONS"
.PP
Three functions are available to provide handling of files recognised by
extension, for example to dispatch a file \fBtext\&.ps\fP when executed as a
command to an appropriate viewer\&.
.PP
.PD 0
.TP
.PD 0
\fBzsh\-mime\-setup [\-flv]\fP
.TP
.PD
\fBzsh\-mime\-handler\fP
These two functions use the files \fB~/\&.mime\&.types\fP and \fB/etc/mime\&.types\fP,
which associate types and extensions, as well as \fB~/\&.mailcap\fP and
\fB/etc/mailcap\fP files, which associate types and the programs that
handle them\&. These are provided on many systems with the Multimedia
Internet Mail Extensions\&.
.RS
.PP
To enable the system, the function \fBzsh\-mime\-setup\fP should be
autoloaded and run\&. This allows files with extensions to be treated
as executable; such files be completed by the function completion system\&.
The function \fBzsh\-mime\-handler\fP should not need to be called by the
user\&.
.PP
The system works by setting up suffix aliases with `\fBalias \-s\fP\&'\&.
Suffix aliases already installed by the user will not be overwritten\&.
.PP
Repeated calls to \fBzsh\-mime\-setup\fP do not override the existing
mapping between suffixes and executable files unless the option \fB\-f\fP
is given\&. Note, however, that this does not override existing suffix
aliases assigned to handlers other than \fBzsh\-mime\-handler\fP\&.
Calling \fBzsh\-mime\-setup\fP with the option \fB\-l\fP lists the existing
mappings without altering them\&. Calling \fBzsh\-mime\-setup\fP with the option
\fB\-v\fP causes verbose output to be shown during the setup operation\&.
.PP
The system respects the \fBmailcap\fP flags \fBneedsterminal\fP and
\fBcopiousoutput\fP, see \fImailcap\fP(4)\&.
.PP
The functions use the following styles, which are defined with the
\fBzstyle\fP builtin command (see \fIzshmodules\fP(1))\&. They should be defined
before \fBzsh\-mime\-setup\fP is run\&. The contexts used all
start with \fB:mime:\fP, with additional components in some cases\&.
It is recommended that a trailing \fB*\fP (suitably quoted) be appended
to style patterns in case the system is extended in future\&. Some
examples are given below\&.
.PD 0
.TP
.PD
\fBcurrent\-shell\fP
If this boolean style is true, the mailcap handler for the context in
question is run using the \fBeval\fP builtin instead of by starting a new
\fBsh\fP process\&. This is more efficient, but may not work in the occasional
cases where the mailcap handler uses strict POSIX syntax\&.
.TP
\fBexecute\-as\-is\fP
This style gives a list of patterns to be matched against files
passed for execution with a handler program\&. If the file matches
the pattern, the entire command line is executed in its current form,
with no handler\&. This is useful for files which might have suffixes
but nonetheless be executable in their own right\&. If the style
is not set, the pattern \fB*(*) *(/)\fP is used;
hence executable files are executed directly and not passed to a
handler, and the option \fBAUTO_CD\fP may be used to change to directories
that happen to have MIME suffixes\&.
.TP
\fBflags\fP
Defines flags to go with a handler; the context is as for the
\fBhandler\fP style, and the format is as for the flags in \fBmailcap\fP\&.
.TP
\fBhandle\-nonexistent\fP
By default, arguments that don\&'t correspond to files are not passed
to the MIME handler in order to prevent it from intercepting commands found
in the path that happen to have suffixes\&. This style may be set to
an array of extended glob patterns for arguments that will be passed to the
handler even if they don\&'t exist\&. If it is not explicitly set it
defaults to \fB[[:alpha:]]#:/*\fP which allows URLs to be passed to the MIME
handler even though they don\&'t exist in that format in the file system\&.
.TP
\fBhandler\fP
Specifies a handler for a suffix; the suffix is given by the context as
\fB:mime:\&.\fP\fIsuffix\fP\fB:\fP, and the format of the handler is exactly
that in \fBmailcap\fP\&. Note in particular the `\fB\&.\fP\&' and trailing colon
to distinguish this use of the context\&. This overrides any handler
specified by the \fBmailcap\fP files\&. If the handler requires a terminal,
the \fBflags\fP style should be set to include the word \fBneedsterminal\fP,
or if the output is to be displayed through a pager (but not if the
handler is itself a pager), it should include \fBcopiousoutput\fP\&.
.TP
\fBmailcap\fP
A list of files in the format of \fB~/\&.mailcap\fP and
\fB/etc/mailcap\fP to be read during setup, replacing the default list
which consists of those two files\&. The context is \fB:mime:\fP\&.
A \fB+\fP in the list will be replaced by the default files\&.
.TP
\fBmailcap\-priorities\fP
This style is used to resolve multiple mailcap entries for the same MIME
type\&. It consists of an array of the following elements, in descending
order of priority; later entries will be used if earlier entries are
unable to resolve the entries being compared\&. If none of the tests
resolve the entries, the first entry encountered is retained\&.
.RS
.PP
.PD 0
.TP
.PD
\fBfiles\fP
The order of files (entries in the \fBmailcap\fP style) read\&. Earlier
files are preferred\&. (Note this does not resolve entries in the same file\&.)
.TP
\fBpriority\fP
The priority flag from the mailcap entry\&. The priority is an integer
from 0 to 9 with the default value being 5\&.
.TP
\fBflags\fP
The test given by the \fBmailcap\-prio\-flags\fP option is used to resolve
entries\&.
.TP
\fBplace\fP
Later entries are preferred; as the entries are strictly ordered, this
test always succeeds\&.
.PP
Note that as this style is handled during initialisation, the context
is always \fB:mime:\fP, with no discrimination by suffix\&.
.RE
.TP
\fBmailcap\-prio\-flags\fP
This style is used when the keyword \fBflags\fP is encountered in the
list of tests specified by the \fBmailcap\-priorities\fP style\&.
It should be set to a list of patterns, each of which is tested against
the flags specified in the mailcap entry (in other words, the sets of
assignments found with some entries in the mailcap file)\&. Earlier
patterns in the list are preferred to later ones, and matched patterns
are preferred to unmatched ones\&.
.TP
\fBmime\-types\fP
A list of files in the format of \fB~/\&.mime\&.types\fP and
\fB/etc/mime\&.types\fP to be read during setup, replacing the default list
which consists of those two files\&. The context is \fB:mime:\fP\&.
A \fB+\fP in the list will be replaced by the default files\&.
.TP
\fBnever\-background\fP
If this boolean style is set, the handler for the given context is
always run in the foreground, even if the flags provided in the mailcap
entry suggest it need not be (for example, it doesn\&'t require a
terminal)\&.
.TP
\fBpager\fP
If set, will be used instead of \fB$PAGER\fP or \fBmore\fP to handle
suffixes where the \fBcopiousoutput\fP flag is set\&. The context is
as for \fBhandler\fP, i\&.e\&. \fB:mime:\&.\fP\fIsuffix\fP\fB:\fP for handling
a file with the given \fIsuffix\fP\&.
.PP
Examples:
.PP
.RS
.nf
\fBzstyle \&':mime:*' mailcap ~/\&.mailcap /usr/local/etc/mailcap
zstyle \&':mime:\&.txt:' handler less %s
zstyle \&':mime:\&.txt:' flags needsterminal\fP
.fi
.RE
.PP
When \fBzsh\-mime\-setup\fP is subsequently run, it will look for
\fBmailcap\fP entries in the two files given\&. Files of suffix \fB\&.txt\fP
will be handled by running `\fBless\fP \fIfile\&.txt\fP\&'\&. The flag
\fBneedsterminal\fP is set to show that this program must run attached to a
terminal\&.
.PP
As there are several steps to dispatching a command, the following
should be checked if attempting to execute a file by extension
\fB\&.\fP\fIext\fP does not have the expected effect\&.
.PP
.PD 0
.TP
.PD
The command `\fBalias \-s\fP \fIext\fP\&' should show
`\fBps=zsh\-mime\-handler\fP\&'\&. If it shows something else, another suffix
alias was already installed and was not overwritten\&. If it shows
nothing, no handler was installed: this is most likely because no
handler was found in the \fB\&.mime\&.types\fP and \fBmailcap\fP combination for
\fB\&.ext\fP files\&. In that case, appropriate handling should be added to
\fB~/\&.mime\&.types\fP and \fBmailcap\fP\&.
.TP
If the extension is handled by \fBzsh\-mime\-handler\fP but the file is
not opened correctly, either the handler defined for the type is
incorrect, or the flags associated with it are in appropriate\&. Running
\fBzsh\-mime\-setup \-l\fP will show the handler and, if there are any, the
flags\&. A \fB%s\fP in the handler is replaced by the file (suitably quoted
if necessary)\&. Check that the handler program listed lists and can
be run in the way shown\&. Also check that the flags \fBneedsterminal\fP or
\fBcopiousoutput\fP are set if the handler needs to be run under a
terminal; the second flag is used if the output should be sent to a pager\&.
An example of a suitable \fBmailcap\fP entry for such a program is:
.RS
.PP
.RS
.nf
\fBtext/html; /usr/bin/lynx \&'%s'; needsterminal\fP
.fi
.RE
.RE
.RE
.RE
.TP
\fBpick\-web\-browser\fP
This function is separate from the two MIME functions described above
and can be assigned directly to a suffix:
.RS
.PP
.RS
.nf
\fBautoload \-U pick\-web\-browser
alias \-s html=pick\-web\-browser\fP
.fi
.RE
.PP
It is provided as an intelligent front end to dispatch a web browser\&.
It will check if an X Windows display is available, and if so if there
is already a browser running on the display which can accept a remote
connection\&. In that case, the file will be displayed in that browser;
you should check explicitly if it has appeared in the running browser\&'s
window\&. Otherwise, it will start a new browser according to a built\-in
set of preferences\&.
.PP
Alternatively, \fBpick\-web\-browser\fP can be run as a zsh script\&.
.PP
Two styles are available to customize the choice of browsers:
\fBx\-browsers\fP when running under the X Window System, and
\fBtty\-browsers\fP otherwise\&. These are arrays in decreasing order
of preference consisting of the command name under which to start the
browser\&. They are looked up in the context \fB:mime:\fP (which may
be extended in future, so appending `\fB*\fP\&' is recommended)\&. For
example,
.PP
.RS
.nf
\fBzstyle \&':mime:*' x\-browsers opera konqueror netscape\fP
.fi
.RE
.PP
specifies that \fBpick\-web\-browser\fP should first look for a runing
instance of Opera, Konqueror or Netscape, in that order, and if it
fails to find any should attempt to start Opera\&.
.PP
In addition, the style \fBcommand\fP, if set, is used to pick the command
used to open a page for a browser\&. The context is
\fB:mime:browser:new:$browser:\fP to start a new browser or
\fB:mime:browser:running:$browser:\fP to open a URL in a browser already
runing on the current X display\&. The escape sequence \fB%b\fP in the
style\&'s value will be replaced by the browser, while \fB%u\fP will be
replaced by the URL\&. If the style is not set, the default for all new
instances is equivalent to \fB%b %u\fP and the defaults for using running
browsers are equivalent to the values \fBkfmclient openURL %u\fP for
Konqueror, \fBfirefox \-new\-tab %u\fP for Firefox and \fB%b \-remote
"openUrl(%u)"\fP for all others\&.
.RE
.RE
.PP
.SH "MATHEMATICAL FUNCTIONS"
.PP
.PD 0
.TP
.PD
\fBzcalc\fP [ \fIexpression\fP \&.\&.\&. ]
A reasonably powerful calculator based on zsh\&'s arithmetic evaluation
facility\&. The syntax is similar to that of formulae in most programming
languages; see
the section `Arithmetic Evaluation\&' in \fIzshmisc\fP(1) for details\&. The mathematical
library \fBzsh/mathfunc\fP will be loaded if it is available; see
the section `The zsh/mathfunc Module\&' in \fIzshmodules\fP(1)\&. The mathematical functions
correspond to the raw system libraries, so trigonometric functions are
evaluated using radians, and so on\&.
.RS
.PP
Each line typed is evaluated as an expression\&. The prompt shows a number,
which corresponds to a positional parameter where the result of that
calculation is stored\&. For example, the result of the calculation on the
line preceded by `\fB4> \fP\&' is available as \fB$4\fP\&. The last value
calculated is available as \fBans\fP\&. Full command line editing, including
the history of previous calculations, is available; the history is saved in
the file \fB~/\&.zcalc_history\fP\&. To exit, enter a blank line or type `\fBq\fP\&'
on its own\&.
.PP
If arguments are given to \fBzcalc\fP on start up, they are used to prime the
first few positional parameters\&. A visual indication of this is given when
the calculator starts\&.
.PP
The constants \fBPI\fP (3\&.14159\&.\&.\&.) and \fBE\fP (2\&.71828\&.\&.\&.) are provided\&.
Parameter assignment is possible, but note that all parameters will be put
into the global namespace\&.
.PP
The output base can be initialised by passing the option `\fB\-#\fP\fIbase\fP\&',
for example `\fBzcalc \-#16\fP\&' (the `\fB#\fP' may have to be quoted, depending
on the globbing options set)\&.
.PP
The prompt is configurable via the parameter \fBZCALCPROMPT\fP, which
undergoes standard prompt expansion\&. The index of the current entry is
stored locally in the first element of the array \fBpsvar\fP, which can be
referred to in \fBZCALCPROMPT\fP as `\fB%1v\fP\&'\&. The default prompt is
`\fB%1v> \fP\&'\&.
.PP
The output precision may be specified within zcalc by special commands
familiar from many calculators:
.PD 0
.TP
.PD
\fBnorm\fP
The default output format\&. It corresponds to the printf \fB%g\fP
specification\&. Typically this shows six decimal digits\&.
.TP
\fBsci\fP \fIdigits\fP
Scientific notation, corresponding to the printf \fB%g\fP output format with
the precision given by \fIdigits\fP\&. This produces either fixed point or
exponential notation depending on the value output\&.
.TP
\fBfix\fP \fIdigits\fP
Fixed point notation, corresponding to the printf \fB%f\fP output format with
the precision given by \fIdigits\fP\&.
.TP
\fBeng\fP \fIdigits\fP
Exponential notation, corresponding to the printf \fB%E\fP output format with
the precision given by \fIdigits\fP\&.
.PP
Other special commands:
.PD 0
.TP
.PD
\fBlocal\fP \fIarg\fP \&.\&.\&.
Declare variables local to the function\&. Note that certain variables
are used by the function for its own purposes\&. Other variables
may be used, too, but they will be taken from or put into the global
scope\&.
.TP
\fBfunction\fP \fIname\fP [ \fIbody\fP ]
Define a mathematical function or (with no \fIbody\fP) delete it\&.
The function is defined using \fBzmathfuncdef\fP, see below\&.
.RS
.PP
Note that \fBzcalc\fP takes care of all quoting\&. Hence for example:
.PP
.RS
.nf
\fBfunction cube $1 * $1 * $1\fP
.fi
.RE
.PP
defines a function to cube the sole argument\&.
.RE
.TP
\fB[#\fP\fIbase\fP\fB]\fP
When this syntax appears on a line by itself, the default output radix
is set to \fIbase\fP\&. Use, for example, `\fB[#16]\fP\&' to display hexadecimal
output preceded by an indication of the base, or `\fB[##16]\fP\&' just to
display the raw number in the given base\&. Bases themselves are always
specified in decimal\&. `\fB[#]\fP\&' restores the normal output format\&. Note
that setting an output base suppresses floating point output; use `\fB[#]\fP\&'
to return to normal operation\&.
.RS
.PP
.RE
.RE
.PP
See the comments in the function for a few extra tips\&.
.RE
.TP
\fBzmathfuncdef\fP \fImathfunc\fP [ \fIbody\fP ]
A convenient front end to \fBfunctions \-M\fP\&.
.RS
.PP
With two arguments, define a mathematical function named \fImathfunc\fP
which can be used in any form of arithmetic evaluation\&. \fIbody\fP
is a mathematical expression to implement the function\&. It may
contain references to position parameters \fB$1\fP, \fB$2\fP, \&.\&.\&.
to refer to mandatory parameters and \fB${1:\-\fP\fIdefvalue\fP\fB}\fP \&.\&.\&.
to refer to optional parameters\&. Note that the forms must be
strictly adhered to for the function to calculate the correct number
of arguments\&. The implementation is held in a shell function named
\fBzsh_math_func_\fP\fImathfunc\fP; usually the user will not need
to refer to the shell function directly\&.
.PP
With one argument, remove the mathematical function \fImathfunc\fP
as well as the shell function implementation\&.
.RE
.RE
.PP
.SH "OTHER FUNCTIONS"
.PP
There are a large number of helpful functions in the \fBFunctions/Misc\fP
directory of the zsh distribution\&. Most are very simple and do not
require documentation here, but a few are worthy of special mention\&.
.PP
.SS "Descriptions"
.PP
.PD 0
.TP
.PD
\fBcolors\fP
This function initializes several associative arrays to map color names to
(and from) the ANSI standard eight\-color terminal codes\&. These are used
by the prompt theme system (see above)\&. You seldom should need to run
\fBcolors\fP more than once\&.
.RS
.PP
The eight base colors are: black, red, green, yellow, blue, magenta, cyan,
and white\&. Each of these has codes for foreground and background\&. In
addition there are eight intensity attributes: bold, faint, standout,
underline, blink, reverse, and conceal\&. Finally, there are six codes used
to negate attributes: none (reset all attributes to the defaults), normal
(neither bold nor faint), no\-standout, no\-underline, no\-blink, and
no\-reverse\&.
.PP
Some terminals do not support all combinations of colors and intensities\&.
.PP
The associative arrays are:
.PP
.PD 0
.TP
.PD 0
color
.TP
.PD
colour
Map all the color names to their integer codes, and integer codes to the
color names\&. The eight base names map to the foreground color codes, as
do names prefixed with `\fBfg\-\fP\&', such as `\fBfg\-red\fP'\&. Names prefixed
with `\fBbg\-\fP\&', such as `\fBbg\-blue\fP', refer to the background codes\&. The
reverse mapping from code to color yields base name for foreground codes
and the \fBbg\-\fP form for backgrounds\&.
.RS
.PP
Although it is a misnomer to call them `colors\&', these arrays also map the
other fourteen attributes from names to codes and codes to names\&.
.RE
.TP
.PD 0
fg
.TP
.PD 0
fg_bold
.TP
.PD
fg_no_bold
Map the eight basic color names to ANSI terminal escape sequences that set
the corresponding foreground text properties\&. The \fBfg\fP sequences change
the color without changing the eight intensity attributes\&.
.TP
.PD 0
bg
.TP
.PD 0
bg_bold
.TP
.PD
bg_no_bold
Map the eight basic color names to ANSI terminal escape sequences that set
the corresponding background properties\&. The \fBbg\fP sequences change the
color without changing the eight intensity attributes\&.
.PP
In addition, the scalar parameters \fBreset_color\fP and \fBbold_color\fP are
set to the ANSI terminal escapes that turn off all attributes and turn on
bold intensity, respectively\&.
.RE
.TP
\fBfned\fP \fIname\fP
Same as \fBzed \-f\fP\&. This function does not appear in the zsh
distribution, but can be created by linking \fBzed\fP to the name \fBfned\fP
in some directory in your \fBfpath\fP\&.
.TP
\fBis\-at\-least\fP \fIneeded\fP [ \fIpresent\fP ]
Perform a greater\-than\-or\-equal\-to comparison of two strings having the
format of a zsh version number; that is, a string of numbers and text with
segments separated by dots or dashes\&. If the \fIpresent\fP string is not
provided, \fB$ZSH_VERSION\fP is used\&. Segments are paired left\-to\-right in
the two strings with leading non\-number parts ignored\&. If one string has
fewer segments than the other, the missing segments are considered zero\&.
.RS
.PP
This is useful in startup files to set options and other state that are
not available in all versions of zsh\&.
.PP
.RS
.nf
\fBis\-at\-least 3\&.1\&.6\-15 && setopt NO_GLOBAL_RCS
is\-at\-least 3\&.1\&.0 && setopt HIST_REDUCE_BLANKS
is\-at\-least 2\&.6\-17 || print "You can\&'t use is\-at\-least here\&."\fP
.fi
.RE
.RE
.TP
\fBnslookup\fP [ \fIarg\fP \&.\&.\&. ]
This wrapper function for the \fBnslookup\fP command requires the
\fBzsh/zpty\fP module (see
\fIzshmodules\fP(1))\&. It behaves exactly like the standard \fBnslookup\fP
except that it provides customizable prompts (including a right\-side
prompt) and completion of nslookup commands, host names, etc\&. (if you use
the function\-based completion system)\&. Completion styles may be set with
the context prefix `\fB:completion:nslookup\fP\&'\&.
.RS
.PP
See also the \fBpager\fP, \fBprompt\fP and \fBrprompt\fP styles below\&.
.RE
.TP
\fBrun\-help\fP
See `Accessing On\-Line Help\&'
above\&.
.TP
\fBtetris\fP
Zsh was once accused of not being as complete as Emacs,
because it lacked a Tetris game\&. This function was written to
refute this vicious slander\&.
.RS
.PP
This function must be used as a ZLE widget:
.PP
.RS
.nf
\fBautoload \-U tetris
zle \-N tetris
bindkey \fIkeys\fP tetris\fP
.fi
.RE
.PP
To start a game, execute the widget by typing the \fIkeys\fP\&. Whatever command
line you were editing disappears temporarily, and your keymap is also
temporarily replaced by the Tetris control keys\&. The previous editor state
is restored when you quit the game (by pressing `\fBq\fP\&') or when you lose\&.
.PP
If you quit in the middle of a game, the next invocation of the \fBtetris\fP
widget will continue where you left off\&. If you lost, it will start a new
game\&.
.RE
.TP
\fBzargs\fP [ \fIoption\fP \&.\&.\&. \fB\-\fP\fB\-\fP ] [ \fIinput\fP \&.\&.\&. ] [ \fB\-\fP\fB\-\fP \fIcommand\fP [ \fIarg\fP \&.\&.\&. ] ]
This function works like GNU xargs, except that instead of reading lines
of arguments from the standard input, it takes them from the command line\&.
This is useful because zsh, especially with recursive glob operators,
often can construct a command line for a shell function that is longer
than can be accepted by an external command\&.
.RS
.PP
The \fIoption\fP list represents options of the \fBzargs\fP command itself,
which are the same as those of \fBxargs\fP\&. The \fIinput\fP list is the
collection of strings (often file names) that become the arguments of the
\fBcommand\fP, analogous to the standard input of \fBxargs\fP\&. Finally, the
\fIarg\fP list consists of those arguments (usually options) that are
passed to the \fIcommand\fP each time it runs\&. The \fIarg\fP list precedes
the elements from the \fBinput\fP list in each run\&. If no \fIcommand\fP is
provided, then no \fIarg\fP list may be provided, and in that event the
default command is `\fBprint\fP\&' with arguments `\fB\-r \-\fP\fB\-\fP'\&.
.PP
For example, to get a long \fBls\fP listing of all plain files in the
current directory or its subdirectories:
.PP
.RS
.nf
\fBautoload \-U zargs
zargs \-\- **/*(\&.) \-\- ls \-l\fP
.fi
.RE
.PP
Note that `\fB\-\fP\fB\-\fP\&' is used both to mark the end of the \fIoption\fP
list and to mark the end of the \fIinput\fP list, so it must appear twice
whenever the \fIinput\fP list may be empty\&. If there is guaranteed to be
at least one \fIinput\fP and the first \fIinput\fP does not begin with a
`\fB\-\fP\&', then the first `\fB\-\fP\fB\-\fP' may be omitted\&.
.PP
In the event that the string `\fB\-\fP\fB\-\fP\&' is or may be an \fIinput\fP, the
\fB\-e\fP option may be used to change the end\-of\-inputs marker\&. Note that
this does \fInot\fP change the end\-of\-options marker\&. For example, to use
`\fB\&.\&.\fP\&' as the marker:
.PP
.RS
.nf
\fBzargs \-e\&.\&. \-\- **/*(\&.) \&.\&. ls \-l\fP
.fi
.RE
.PP
This is a good choice in that example because no plain file can be named
`\fB\&.\&.\fP\&', but the best end\-marker depends on the circumstances\&.
.PP
For details of the other \fBzargs\fP options, see \fIxargs\fP(1) or run
\fBzargs\fP with the \fB\-\fP\fB\-help\fP option\&.
.RE
.TP
.PD 0
\fBzed\fP [ \fB\-f\fP ] \fIname\fP
.TP
.PD
\fBzed \-b\fP
This function uses the ZLE editor to edit a file or function\&.
.RS
.PP
Only one \fIname\fP argument is allowed\&.
If the \fB\-f\fP option is given, the name is taken to be that of
a function; if the function is marked for autoloading, \fBzed\fP searches
for it in the \fBfpath\fP and loads it\&. Note that functions edited this way
are installed into the current shell, but \fInot\fP written back to the
autoload file\&.
.PP
Without \fB\-f\fP, \fIname\fP is the path name of the file to edit, which need
not exist; it is created on write, if necessary\&.
.PP
While editing, the function sets the main keymap to \fBzed\fP and the
vi command keymap to \fBzed\-vicmd\fP\&. These will be copied from the existing
\fBmain\fP and \fBvicmd\fP keymaps if they do not exist the first time \fBzed\fP
is run\&. They can be used to provide special key bindings used only in zed\&.
.PP
If it creates the keymap, \fBzed\fP rebinds the return key to insert a line
break and `\fB^X^W\fP\&' to accept the edit in the \fBzed\fP keymap, and binds
`\fBZZ\fP\&' to accept the edit in the \fBzed\-vicmd\fP keymap\&.
.PP
The bindings alone can be installed by running `\fBzed \-b\fP\&'\&. This is
suitable for putting into a startup file\&. Note that, if rerun,
this will overwrite the existing \fBzed\fP and \fBzed\-vicmd\fP keymaps\&.
.PP
Completion is available, and styles may be set with the context prefix
`\fB:completion:zed\fP\&'\&.
.PP
A zle widget \fBzed\-set\-file\-name\fP is available\&. This can be called by
name from within zed using `\fB\eex zed\-set\-file\-name\fP\&' (note, however, that
because of zed\&'s rebindings you will have to type \fB^j\fP at the end instead
of the return key), or can be bound to a key in either of the \fBzed\fP or
\fBzed\-vicmd\fP keymaps after `\fBzed \-b\fP\&' has been run\&. When the widget is
called, it prompts for a new name for the file being edited\&. When zed
exits the file will be written under that name and the original file will
be left alone\&. The widget has no effect with `\fBzed \-f\fP\&'\&.
.PP
While \fBzed\-set\-file\-name\fP is running, zed uses the keymap
\fBzed\-normal\-keymap\fP, which is linked from the main keymap in effect
at the time zed initialised its bindings\&. (This is to make the return key
operate normally\&.) The result is that if the main keymap has been changed,
the widget won\&'t notice\&. This is not a concern for most users\&.
.RE
.TP
.PD 0
\fBzcp\fP [ \fB\-finqQvwW\fP ] \fIsrcpat\fP \fIdest\fP
.TP
.PD
\fBzln\fP [ \fB\-finqQsvwW\fP ] \fIsrcpat\fP \fIdest\fP
Same as \fBzmv \-C\fP and \fBzmv \-L\fP, respectively\&. These functions do not
appear in the zsh distribution, but can be created by linking \fBzmv\fP to
the names \fBzcp\fP and \fBzln\fP in some directory in your \fBfpath\fP\&.
.TP
\fBzkbd\fP
See `Keyboard Definition\&'
above\&.
.TP
\fBzmv\fP [ \fB\-finqQsvwW\fP ] [ \-C | \-L | \-M | \-p \fIprogram\fP ] [ \-o \fIoptstring\fP ] \fIsrcpat\fP \fIdest\fP
Move (usually, rename) files matching the pattern \fIsrcpat\fP to
corresponding files having names of the form given by \fIdest\fP, where
\fIsrcpat\fP contains parentheses surrounding patterns which will be
replaced in turn by $1, $2, \&.\&.\&. in \fIdest\fP\&. For example,
.RS
.PP
.RS
.nf
\fBzmv \&'(*)\&.lis' '$1\&.txt'\fP
.fi
.RE
.PP
renames `\fBfoo\&.lis\fP\&' to `\fBfoo\&.txt\fP', `\fBmy\&.old\&.stuff\&.lis\fP' to
`\fBmy\&.old\&.stuff\&.txt\fP\&', and so on\&.
.PP
The pattern is always treated as an \fBEXTENDED_GLOB\fP pattern\&. Any file
whose name is not changed by the substitution is simply ignored\&. Any
error (a substitution resulted in an empty string, two substitutions gave
the same result, the destination was an existing regular file and \fB\-f\fP
was not given) causes the entire function to abort without doing anything\&.
.PP
Options:
.PP
.PD 0
.TP
\fB\-f\fP
Force overwriting of destination files\&. Not currently
passed down to the \fBmv\fP/\fBcp\fP/\fBln\fP command due to vagaries of
implementations (but you can use \fB\-o\-f\fP to do that)\&.
.TP
\fB\-i\fP
Interactive: show each line to be executed and ask the user
whether to execute it\&. `Y\&' or `y' will execute it, anything else will
skip it\&. Note that you just need to type one character\&.
.TP
\fB\-n\fP
No execution: print what would happen, but don\&'t do it\&.
.TP
\fB\-q\fP
Turn bare glob qualifiers off: now assumed by default, so
this has no effect\&.
.TP
\fB\-Q\fP
Force bare glob qualifiers on\&. Don\&'t turn this on unless
you are actually using glob qualifiers in a pattern\&.
.TP
\fB\-s\fP
Symbolic, passed down to \fBln\fP; only works with \fB\-L\fP\&.
.TP
\fB\-v\fP
Verbose: print each command as it\&'s being executed\&.
.TP
\fB\-w\fP
Pick out wildcard parts of the pattern, as described above,
and implicitly add parentheses for referring to them\&.
.TP
\fB\-W\fP
Just like \fB\-w\fP, with the addition of turning wildcards in
the replacement pattern into sequential ${1} \&.\&. ${N} references\&.
.TP
\fB\-C\fP
.TP
\fB\-L\fP
.TP
\fB\-M\fP
Force \fBcp\fP, \fBln\fP or \fBmv\fP, respectively, regardless of
the name of the function\&.
.TP
\fB\-p\fP \fIprogram\fP
Call \fIprogram\fP instead of \fBcp\fP, \fBln\fP or
\fBmv\fP\&. Whatever it does, it should at least understand the form
`\fIprogram\fP \fB\-\fP\fB\-\fP \fIoldname\fP \fInewname\fP\&'
where \fIoldname\fP and \fInewname\fP are filenames generated by \fBzmv\fP\&.
.TP
\fB\-o\fP \fIoptstring\fP
The \fIoptstring\fP is split into words and
passed down verbatim to the \fBcp\fP, \fBln\fP or \fBmv\fP command called to
perform the work\&. It should probably begin with a `\fB\-\fP\&'\&.
.PD
.PP
For more complete examples and other implementation details, see the
\fBzmv\fP source file, usually located in one of the directories named in
your \fBfpath\fP, or in \fBFunctions/Misc/zmv\fP in the zsh distribution\&.
.RE
.TP
\fBzrecompile\fP
See `Recompiling Functions\&'
above\&.
.TP
\fBzstyle+\fP \fIcontext\fP \fIstyle\fP \fIvalue\fP [ + \fIsubcontext\fP \fIstyle\fP \fIvalue\fP \&.\&.\&. ]
This makes defining styles a bit simpler by using a single `\fB+\fP\&' as a
special token that allows you to append a context name to the previously
used context name\&. Like this:
.RS
.PP
.RS
.nf
\fBzstyle+ \&':foo:bar' style1 value1 \e
+ \&':baz' style2 value2 \e
+ \&':frob' style3 value3\fP
.fi
.RE
.PP
This defines `style1\&' with `value1' for the context \fB:foo:bar\fP as usual,
but it also defines `style2\&' with `value2' for the context
\fB:foo:bar:baz\fP and `style3\&' with `value3' for \fB:foo:bar:frob\fP\&. Any
\fIsubcontext\fP may be the empty string to re\-use the first context
unchanged\&.
.RE
.RE
.PP
.SS "Styles"
.PP
.PD 0
.TP
.PD
\fBinsert\-tab\fP
The \fBzed\fP function \fIsets\fP this style in context `\fB:completion:zed:*\fP\&'
to turn off completion when \fBTAB\fP is typed at the beginning of a line\&.
You may override this by setting your own value for this context and style\&.
.TP
\fBpager\fP
The \fBnslookup\fP function looks up this style in the context
`\fB:nslookup\fP\&' to determine the program used to display output that does
not fit on a single screen\&.
.TP
.PD 0
\fBprompt\fP
.TP
.PD
\fBrprompt\fP
The \fBnslookup\fP function looks up this style in the context
`\fB:nslookup\fP\&' to set the prompt and the right\-side prompt, respectively\&.
The usual expansions for the \fBPS1\fP and \fBRPS1\fP parameters may be used
(see
\fIzshmisc\fP(1))\&.
|