From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23437 invoked from network); 30 Apr 2000 14:46:00 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 30 Apr 2000 14:46:00 -0000 Received: (qmail 23994 invoked by alias); 30 Apr 2000 14:45:08 -0000 Mailing-List: contact zsh-announce-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 108 Received: (qmail 22523 invoked from network); 30 Apr 2000 14:41:44 -0000 To: zsh-announce@sunsite.auc.dk Subject: Z-Shell (zsh) FAQ changes this month Date: Sun, 30 Apr 2000 15:41:31 +0100 From: Peter Stephenson Message-Id: This file contains general information on how to find out about zsh, (the first part of the FAQ up to item 1.1), then any other items which have changed since last month's posting, then the differences in the yodl version of the FAQ. If you would like a complete individual copy, email me and I will add you to the list. Changes since issue posted March 2000: 3.8 Mention the `keypad mode' horror and fixes (from Bart). 3.25 Rephrased, example for older versions added. 5.1 Mention :x and :q modifiers again This document contains a list of frequently-asked (or otherwise significant) questions concerning the Z-shell, a command interpreter for many UNIX systems which is freely available to anyone with FTP access. Zsh is among the most powerful freely available Bourne-like shell for interactive use. If you have never heard of `sh', `csh' or `ksh', then you are probably better off to start by reading a general introduction to UNIX rather than this document. If you just want to know how to get your hands on the latest version, skip to question 1.6; if you want to know what to do with insoluble problems, go to 5.2. Notation: Quotes `like this' are ordinary textual quotation marks. Other uses of quotation marks are input to the shell. Contents: Chapter 1: Introducing zsh and how to install it 1.1. Sources of information 1.2. What is it? 1.3. What is it good at? 1.4. On what machines will it run? (Plus important compilation notes) 1.5. What's the latest version? 1.6. Where do I get it? 1.7. I don't have root access: how do I make zsh my login shell? Chapter 2: How does zsh differ from...? 2.1. sh and ksh? 2.2. csh? 2.3. Why do my csh aliases not work? (Plus other alias pitfalls.) 2.4. tcsh? 2.5. bash? 2.6. Shouldn't zsh be more/less like ksh/(t)csh? Chapter 3: How to get various things to work 3.1. Why does `$var' where `var="foo bar"' not do what I expect? 3.2. In which startup file do I put...? 3.3. What is the difference between `export' and the ALL_EXPORT option? 3.4. How do I turn off spelling correction/globbing for a single command? 3.5. How do I get the meta key to work on my xterm? 3.6. How do I automatically display the directory in my xterm title bar? 3.7. How do I make the completion list use eight bit characters? 3.8. Why do the cursor (arrow) keys not work? 3.9. Why does my terminal act funny in some way? 3.10. Why does zsh not work in an Emacs shell mode any more? 3.11. Why do my autoloaded functions not autoload [the first time]? 3.12. How does base arithmetic work? 3.13. How do I get a newline in my prompt? 3.14. Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny? 3.15. Why can't I bind \C-s and \C-q any more? 3.16. How do I execute command `foo' within function `foo'? 3.17. Why do history substitutions with single bangs do something funny? 3.18. Why does zsh kill off all my background jobs when I logout? 3.19. How do I list all my history entries? 3.20. How does the alternative loop syntax, e.g. `while {...} {...}' work? 3.21. Why is my history not being saved? 3.22. How do I get a variable's value to be evaluated as another variable? 3.23. How do I prevent the prompt overwriting output when there is no newline? 3.24. What's wrong with cut and paste on my xterm? 3.25. How do I get coloured prompts on my colour xterm? Chapter 4: The mysteries of completion 4.1. What is completion? 4.2. What sorts of things can be completed? 4.3. How does zsh deal with ambiguous completions? 4.4. How do I complete in the middle of words / just what's before the cursor? 4.5. How do I get started with programmable completion? 4.6. And if programmable completion isn't good enough? Chapter 5: The future of zsh 5.1. What bugs are currently known and unfixed? (Plus recent important changes) 5.2. Where do I report bugs, get more info / who's working on zsh? 5.3. What's on the wish-list? 5.4. Will zsh have problems in the year 2000? Acknowledgments Copyright --- End of Contents --- Chapter 1: Introducing zsh and how to install it 1.1: Sources of information Information on zsh is available via the World Wide Web. The URL is http://sunsite.auc.dk/zsh/ . The server provides this FAQ and much else and is now maintained by Karsten Thygesen and others (mail zsh@sunsite.auc.dk with any related messages). The FAQ is at http://sunsite.auc.dk/zsh/FAQ/ . The site also contains some contributed zsh scripts and functions; we are delighted to add more, or simply links to your own collection. This document was originally written in YODL, allowing it to be converted easily into various other formats. The master source file lives at http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo and the plain text version can be found at http://sunsite.auc.dk/zsh/FAQ/zshfaq.txt . Another useful source of information is the collection of FAQ articles posted frequently to the Usenet news groups comp.unix.questions, comp.unix.shells and comp.answers with answers to general questions about UNIX. The fifth of the seven articles deals with shells, including zsh, with a brief description of differences. There is also a separate FAQ on shell differences and how to change your shell. Usenet FAQs are available via FTP from rtfm.mit.edu and mirrors and also on the World Wide Web; see USA http://www.cis.ohio-state.edu/hypertext/faq/usenet/top.html UK http://www.lib.ox.ac.uk/internet/news/faq/comp.unix.shell.html Netherlands http://www.cs.uu.nl/wais/html/na-dir/unix-faq/shell/.html You can also get it via email by emailing mail-server@rtfm.mit.edu with, in the body of the message, `send faqs/unix-faq/shell/zsh'. The latest version of this FAQ is also available directly from any of the zsh archive sites listed in question 1.6. I have been putting together a user guide to complement the manual by explaining the most useful features of zsh in a more easy to read way. This will be a long project, but a partial version describing how to write startup files and how to use the new, more powerful, form for completion which first appeared in 3.1.6 (and is not described in this FAQ) can be seen by looking at http://www.pwstephenson.fsnet.co.uk/computing/ where it exists in various formats. (As a method of reading the following in Emacs, you can type \M-2 \C-x $ to make all the indented text vanish, then \M-0 \C-x $ when you are on the title you want.) For any more eclectic information, you should contact the mailing list: see question 5.2. --- End of general information, changed items follow in full --- 3.8: Why do the cursor (arrow) keys not work? The cursor keys send different codes depending on the terminal; zsh only binds the most well known versions. If you see these problems, try putting the following in your .zshrc: bindkey "$(echotc kl)" backward-char bindkey "$(echotc kr)" forward-char bindkey "$(echotc ku)" up-line-or-history bindkey "$(echotc kd)" down-line-or-history If you use vi mode, use `vi-backward-char' and `vi-forward-char' where appropriate. Note, however, that up to version 3.0 binding arbitrary multiple key sequences can cause problems, so check that this works with your set up first. Also, from version 3.1.3, more sequences are supported by default, namely those in the form `O' followed by A, B, C or D, as well as the corresponding set beginning `[', so this may be redundant. A particular problem which sometimes occurs is that there are two different modes for arrow keys, normal mode and keypad mode, which send different sequences. Although this is largely a historical artifact, it sometimes happens that your terminal can be switched from one mode to the other, for example by a rogue programme that sends the sequence to switch one way, but not the sequence to switch back. Thus you are stuck with the effects. Luckily in this case the arrow key sequences are likely to be standard, and you can simply bind both sets. The following code does this. bindkey '\e[A' up-line-or-history bindkey '\e[B' down-line-or-history bindkey '\e[C' forward-char bindkey '\e[D' backward-char bindkey '\eOA' up-line-or-history bindkey '\eOB' down-line-or-history bindkey '\eOC' forward-char bindkey '\eOD' backward-char For most even vaguely VT100-compatible terminals, the above eight instructions are a fairly safe bet for your .zshrc. Of course you can substitute variant functions for the second argument here too. 3.25: How do I get coloured prompts on my colour xterm? (Or `color xterm', if you're reading this in black and white.) You need to find the sequences which generate the various colours from the manual for your terminal emulator; these are ANSI standard on those I know about which support colour. With a recent (post 3.1.6) distribution of zsh, there is a theme system to handle this for you; even if you don't see that, the installed function ``colors'' (meaning `colours', if you're not reading this in black and white) gives the escape sequences. You will end up with code looking like this (borrowed from Oliver Kiddle): PS1=$'%{\e[1;31m%}%{\e[0m%}' The `$'' form of quoting turns the ``\e'' into a real escape character; this only works from about version 3.1.4, so if you're using 3.0.x, you need to do something like PS1="$(print '%{\e[1;31m%}%{\e[0m%}')" The ``%{...%}'' is used in prompts for strings which will not appear as characters, so that the prompt code doesn't miscalculate the length of the prompt which would have a bad effect on editing. The resulting ``[1;31m'' makes the prompt red, and the ``[0m'' puts printing back to normal so that the rest of the line is unchanged. 5.1: What bugs are currently known and unfixed? (Plus recent important changes) Here are some of the more well-known ones, very roughly in decreasing order of significance. Many of these can also be counted against differences from ksh in question 2.1; note that this applies to the latest beta version and that simple bugs are often fixed quite quickly. There is a file Etc/BUGS in the source distribution with more detail. o `time' is ignored with builtins and can't be used with `{...}'. o When showing completion lists with exactly 80 columns, some terminals print an extra newline which messes up zsh's logic. o `set -x' (`setopt xtrace') still has a few glitches; these are mostly fixed in 3.1.6. o Zsh's notion of the current line number (via $LINENO) is sometimes not well handled, particularly when using functions and traps. This should also work reliably from 3.0.6 and 3.1.6. o In vi mode, `u' can go past the original modification point. o The singlelinezle option has problems with prompts containing escapes. o The `r' command does not work inside `$(...)' or ``...`' expansions. This is fixed in 3.1. o `typeset' handling is non-optimal, particularly with regard to flags, and is ksh-incompatible in unpredictable ways. 3.1.6 has been overhauled, but remaining glitches are to be expected. o Nested closures in extended globbing and pattern matching, such as [[ fofo = (fo#)# ]] were not correctly handled, and there were problems with complicated exclusions using `^' or `~'. These are fixed in version 3.1.3. o Handling of the `:q' and `:x' with parameter subsitutions is erratic: neither work in any 3.0 release, and :x doesn't work in any release so far. Note that a few recent changes introduce incompatibilities (these are not bugs): Changes after zsh 3.0 (3.1.x is still currently in beta): o The options ALWAYS_LAST_PROMPT (return to the line you were editing after displaying completion lists) and LIST_AMBIGUOUS (don't do AUTO_LIST if there was an unambiguous prefix that could be inserted, i.e. only list if it is ambiguous what to insert next) are now set by default. This is in response to complaints that too many zsh features are never noticed by many users. To turn them off, just put `unsetopt alwayslastprompt listambiguous' in your .zshrc file. o In 3.1.5, history-search-{forward,backward} only find previous lines where the first word is the same as the current one. For example, compp will find lines in the history like `comp -edit emacs', but not `compress file' any more. For this reason, `\M-n' and `\M-p' use history-beginning-search-{forward,backward} which search for a line with the same prefix up to the cursor position. From 3.1.6, there is a different implementation which makes this closer (though not identical) to the old behaviour, and the traditional bindings have been restored.. The story for the {up,down}-line-or-search commands is similar. o In vi insert mode, the cursor keys no longer work. The following will bind them: bindkey -M viins '^[[D' vi-backward-char '^[[C' vi-forward-char \ '^[[A' up-line-or-history '^[[B' down-line-or-history (unless your terminal requires `^[O' instead of `^[['). The rationale is that the insert mode and command mode keymaps for keys with prefixes are now separate. Changes since zsh 2.5: o The left hand of an assignment is no longer substituted. Thus, `$1=$2' will not work. You can use something like `eval "$1=\$2"', which should have the identical effect. o Signal traps established with the `trap' builtin are now called with the environment of the caller, as in ksh, instead of as a new function level. Traps established as functions (e.g. `TRAPINT() {...}') work as before. o The NO_CLOBBER option is now -C and PRINT_EXIT_VALUE -1; they used to be the other way around. (Use of names rather than letters is generally recommended.) o `[[' is a reserved word, hence must be separated from other characters by whitespace; `{' and `}' are also reserved words if the IGNORE_BRACES option is set. o The option CSH_JUNKIE_PAREN has been removed: csh-like code now always does what it looks like it does, so `if ( ... ) ...' executes the code in parentheses in a subshell. To make this useful, the syntax expected after an `if', etc., is less strict than in other shells. o `foo=*' does not perform globbing immediately on the right hand side of the assignment; the old behaviour now requires the option GLOB_ASSIGN. (`foo=(*)' is and has always been the consistent way of doing this.) o <> performs redirection of input and output to the specified file. For numeric globs, you now need <->. o The command line qualifiers exec, noglob, command, - are now treated more like builtin commands: previously they were syntactically special. This should make it easier to perform tricks with them (disabling, hiding in parameters, etc.). o The pushd builtin has been rewritten for compatibility with other shells. The old behavour can be achieved with a shell function. o The current version now uses ~'s for directory stack substitution instead of ='s. This is for consistency: all other directory substitution (~user, ~name, ~+, ...) used a tilde, while = caused problems with =program substitution. o The HISTLIT option was broken in various ways and has been removed: the rewritten history mechanism doesn't alter history lines, making the option unnecessary. o History expansion is disabled in single-quoted strings, like other forms of expansion -- hence exclamation marks there should not be backslashed. o The `$HISTCHARS' variable is now `$histchars'. Currently both are tied together for compatibility. o The PROMPT_SUBST option now performs backquote expansion -- hence you should quote these in prompts. (SPROMPT has changed as a result.) o Quoting in prompts has changed: close parentheses inside ternary expressions should be quoted with a %; history is now %!, not !. Backslashes are no longer special. --- End of changed items, diff from previous version follows --- Index: zshfaq.yo =================================================================== RCS file: /pack/anoncvs/zsh/www/FAQ/zshfaq.yo,v retrieving revision 1.53 diff -u -r1.53 zshfaq.yo --- zshfaq.yo 2000/03/24 20:55:34 1.53 +++ zshfaq.yo 2000/04/30 14:39:09 @@ -43,20 +43,21 @@ whenman(report(ARG1)(ARG2)(ARG3))\ whenms(report(ARG1)(ARG2)(ARG3))\ whensgml(report(ARG1)(ARG2)(ARG3))) -myreport(Z-Shell Frequently-Asked Questions)(Peter Stephenson)(2000/03/24) +myreport(Z-Shell Frequently-Asked Questions)(Peter Stephenson)(2000/04/30) COMMENT(-- the following are for Usenet and must appear first)\ description(\ mydit(Archive-Name:) unix-faq/shell/zsh -mydit(Last-Modified:) 2000/03/24 +mydit(Last-Modified:) 2000/04/30 mydit(Submitted-By:) email(pws@pwstephenson.fsnet.co.uk (Peter Stephenson)) -mydit(Version:) $Id: faqpost.txt,v 1.19 2000/04/30 14:41:10 pws Exp $ mydit(Posting-Frequency:) Monthly mydit(Copyright:) (C) P.W. Stephenson, 1995--2000 (see end of document) ) -bf(Changes since issue posted February 2000:) +bf(Changes since issue posted March 2000:) description( -mydit(3.25) Now question: coloured prompts on colour xterms. +mydit(3.8) Mention the `keypad mode' horror and fixes (from Bart). +mydit(3.25) Rephrased, example for older versions added. +mydit(5.1) Mention :x and :q modifiers again ) This document contains a list of frequently-asked (or otherwise @@ -1190,7 +1191,30 @@ tt(B), tt(C) or tt(D), as well as the corresponding set beginning mytt([), so this may be redundant. + A particular problem which sometimes occurs is that there are two + different modes for arrow keys, normal mode and keypad mode, which + send different sequences. Although this is largely a historical + artifact, it sometimes happens that your terminal can be switched from + one mode to the other, for example by a rogue programme that sends the + sequence to switch one way, but not the sequence to switch back. Thus + you are stuck with the effects. Luckily in this case the arrow key + sequences are likely to be standard, and you can simply bind both sets. + The following code does this. + verb( + bindkey '\e[A' up-line-or-history + bindkey '\e[B' down-line-or-history + bindkey '\e[C' forward-char + bindkey '\e[D' backward-char + bindkey '\eOA' up-line-or-history + bindkey '\eOB' down-line-or-history + bindkey '\eOC' forward-char + bindkey '\eOD' backward-char + ) + For most even vaguely VT100-compatible terminals, the above eight + instructions are a fairly safe bet for your tt(.zshrc). Of course + you can substitute variant functions for the second argument here too. + sect(Why does my terminal act funny in some way?) If you are using an OpenWindows cmdtool as your terminal, any @@ -1606,24 +1630,29 @@ sect(How do I get coloured prompts on my colour xterm?) -(Or `color xterm', if you're reading this in black and white.) You need to -find the sequences which generate the various colours from the manual; -these are ANSI standard on the terminal emulators I know about which -support colour. With a recent (post 3.1.6) distribution of zsh, there is a -theme system to handle this for you; even if you don't see that, the -installed function `mytt(colors)' (meaning `colours', if you're not reading -this in black and white) gives the escape sequences. You will end up with -code looking like this (borrowed from Oliver Kiddle): -verb( - PS1=$'%{\e[1;31m%}%{\e[0m%}' -) -The mytt($') form of quoting turns the `mytt(\e)' into a real escape -character. The `mytt(%{...%})' is used in prompts for strings which will -not appear as characters, so that the prompt code doesn't miscalculate the -length of the prompt which would have a bad effect on editing. The -resulting `mytt([1;31m)' makes the prompt red, and the -`mytt([0m)' puts printing back to normal so that the rest of the line -is unchanged. + (Or `color xterm', if you're reading this in black and white.) You need + to find the sequences which generate the various colours from the manual + for your terminal emulator; these are ANSI standard on those I know about + which support colour. With a recent (post 3.1.6) distribution of zsh, + there is a theme system to handle this for you; even if you don't see that, + the installed function `mytt(colors)' (meaning `colours', if you're not + reading this in black and white) gives the escape sequences. You will end + up with code looking like this (borrowed from Oliver Kiddle): + verb( + PS1=$'%{\e[1;31m%}%{\e[0m%}' + ) + The mytt($') form of quoting turns the `mytt(\e)' into a real escape + character; this only works from about version 3.1.4, so if you're using + 3.0.x, you need to do something like + verb( + PS1="$(print '%{\e[1;31m%}%{\e[0m%}')" + ) + The `mytt(%{...%})' is used in prompts for strings which will + not appear as characters, so that the prompt code doesn't miscalculate the + length of the prompt which would have a bad effect on editing. The + resulting `mytt([1;31m)' makes the prompt red, and the + `mytt([0m)' puts printing back to normal so that the rest of the line + is unchanged. chapter(The mysteries of completion) @@ -1980,6 +2009,9 @@ complicated exclusions using mytt(^) or mytt(~). These are fixed in version 3.1.3. ) + it() Handling of the mytt(:q) and mytt(:x) with parameter subsitutions is + erratic: neither work in any 3.0 release, and tt(:x) doesn't work in + any release so far. Note that a few recent changes introduce incompatibilities (these are not bugs):