Z-shell (zsh) Frequently-Asked Questions

Z-shell (zsh) Frequently-Asked Questions

Post by Peter Stephens » Thu, 26 Jul 2001 07:15:32

Archive-Name: unix-faq/shell/zsh
Last-Modified: 2001/07/24
Submitted-By: p...@pwstephenson.fsnet.co.uk (Peter Stephenson)
Posting-Frequency: Monthly
Copyright: (C) P.W. Stephenson, 1995--2001 (see end of document)

Changes since last issue posted:

  1.5  4.0.2 really released.

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.

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?
3.26. Why is my output duplicated with `foo 2>&1 >foo.out | bar'?

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. Did zsh have problems in the year 2000?


--- 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.dk/zsh/ .
  The server provides this FAQ and much else and is
  now maintained by Karsten Thygesen and others (mail z...@sunsite.dk
  with any related messages).  The FAQ is at http://sunsite.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.dk/zsh/FAQ/zshfaq.yo and the plain text version
  can be found at http://sunsite.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-ser...@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
  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.

1.2: What is it?

  Zsh is a UNIX command interpreter (shell) which of the standard
  shells most resembles the Korn shell (ksh); its compatibility with
  the 1988 Korn shell has been gradually increasing.  It includes
  enhancements of many types, notably in the command-line editor,
  options for customising its behaviour, filename globbing, features
  to make C-shell (csh) users feel more at home and extra features
  drawn from tcsh (another `custom' shell).

  It was written by Paul Falstad when a student at Princeton; however,
  Paul doesn't maintain it any more and enquiries should be sent to
  the mailing list (see question 5.2).  Zsh is distributed under a
  standard Berkeley style copyright.

  For more information, the files Doc/intro.txt or Doc/intro.troff
  included with the source distribution are highly recommended.  A list
  of features is given in FEATURES, also with the source.

1.3: What is it good at?

  Here are some things that zsh is particularly good at.  No claim of
  exclusivity is made, especially as shells copy one another, though
  in the areas of command line editing and globbing zsh is well ahead
  of the competition.  I am not aware of a major interactive feature
  in any other freely-available shell which zsh does not also have
  (except smallness).

  o  Command line editing:

    o  programmable completion: incorporates the ability to use the
       full power of zsh's globbing and shell programming features,
    o  multi-line commands editable as a single buffer (even files!),
    o  variable editing (vared),
    o  command buffer stack,
    o  print text straight into the buffer for immediate editing (print -z),
    o  execution of unbound commands,
    o  menu completion in two flavours,
    o  variable, editing function and option name completion,
    o  inline expansion of variables and history commands.  

  o  Globbing --- extremely powerful, including:

    o  recursive globbing (cf. find),
    o  file attribute qualifiers (size, type, etc. also cf. find),
    o  full alternation and negation of patterns.

  o  Handling of multiple redirections (simpler than tee).
  o  Large number of options for tailoring.
  o  Path expansion (=foo -> /usr/bin/foo).
  o  Adaptable messages for spelling, watch, time as well as prompt
     (including conditional expressions).
  o  Named directories.
  o  Comprehensive integer and floating point arithmetic.
  o  Manipulation of arrays (including reverse subscripting).
  o  Associative arrays (key-to-value hashes)
  o  Spelling correction.

1.4: On what machines will it run?

  From version 3.0, zsh uses GNU autoconf as the installation
  mechanism.  This considerably increases flexibility over the old
  `buildzsh' mechanism.  Consequently, zsh should compile and run on
  any modern version of UNIX, and a great many not-so-modern versions
  too.  The file Etc/MACHINES in the distribution has more details.

  There are also now separate ports for Windows and OS/2, see `Where
  do I get it' below.

  If you need to change something to support a new machine, it would be
  appreciated if you could add any necessary preprocessor code and
  alter configure.in and acconfig.h to configure zsh automatically,
  then send the required context diffs to the list (see question
  5.2).  Please make sure you have the latest version first.

  To get it to work, retrieve the source distribution (see question
  1.6), un-gzip it, un-tar it and read the INSTALL file in the top
  directory.  Also read the Etc/MACHINES file for up-to-date
  information on compilation on certain architectures.

  *Note for users of nawk* (The

read more »


Z-shell (zsh) Frequently-Asked Questions

Post by Russell Hoov » Fri, 03 Aug 2001 09:02:41

On 24 Jul 2001 23:15:32 +0100, Peter Stephenson

>  Archive-Name: unix-faq/shell/zsh
>    Zsh is distributed under a standard Berkeley style copyright.

Was it ever explained anywhere why zsh isn't distributed under
the GPL?

If it were, wouldn't it likely be included with the GNU package, in
place or alongside of bash, and therefore see much more widespread use?
I seem to know of lots of folks who use bash and have never even heard
of zsh . . .


  City cops & state cops & national guard & bureau cops & tv cops & movie cops
   & uniform & plainclothes cops & riot cops & cops on top of cops on top of
        cops on top of cops: it's a world full of cops.     -- Paleface