1ZSHROADMAP(1) General Commands Manual ZSHROADMAP(1)
2
3
4
6 zshroadmap - informal introduction to the zsh manual The Zsh Manual,
7 like the shell itself, is large and often complicated. This section of
8 the manual provides some pointers to areas of the shell that are likely
9 to be of particular interest to new users, and indicates where in the
10 rest of the manual the documentation is to be found.
11
13 When it starts, the shell reads commands from various files. These can
14 be created or edited to customize the shell. See the section
15 Startup/Shutdown Files in zsh(1).
16
17 If no personal initialization files exist for the current user, a func‐
18 tion is run to help you change some of the most common settings. It
19 won't appear if your administrator has disabled the zsh/newuser module.
20 The function is designed to be self-explanatory. You can run it by
21 hand with `autoload -Uz zsh-newuser-install; zsh-newuser-install -f'.
22 See also the section User Configuration Functions in zshcontrib(1).
23
25 Interaction with the shell uses the builtin Zsh Line Editor, ZLE. This
26 is described in detail in zshzle(1).
27
28 The first decision a user must make is whether to use the Emacs or Vi
29 editing mode as the keys for editing are substantially different.
30 Emacs editing mode is probably more natural for beginners and can be
31 selected explicitly with the command bindkey -e.
32
33 A history mechanism for retrieving previously typed lines (most simply
34 with the Up or Down arrow keys) is available; note that, unlike other
35 shells, zsh will not save these lines when the shell exits unless you
36 set appropriate variables, and the number of history lines retained by
37 default is quite small (30 lines). See the description of the shell
38 variables (referred to in the documentation as parameters) HISTFILE,
39 HISTSIZE and SAVEHIST in zshparam(1). Note that it's currently only
40 possible to read and write files saving history when the shell is in‐
41 teractive, i.e. it does not work from scripts.
42
43 The shell now supports the UTF-8 character set (and also others if sup‐
44 ported by the operating system). This is (mostly) handled transpar‐
45 ently by the shell, but the degree of support in terminal emulators is
46 variable. There is some discussion of this in the shell FAQ,
47 http://www.zsh.org/FAQ/. Note in particular that for combining charac‐
48 ters to be handled the option COMBINING_CHARS needs to be set. Because
49 the shell is now more sensitive to the definition of the character set,
50 note that if you are upgrading from an older version of the shell you
51 should ensure that the appropriate variable, either LANG (to affect all
52 aspects of the shell's operation) or LC_CTYPE (to affect only the han‐
53 dling of character sets) is set to an appropriate value. This is true
54 even if you are using a single-byte character set including extensions
55 of ASCII such as ISO-8859-1 or ISO-8859-15. See the description of
56 LC_CTYPE in zshparam(1).
57
58 Completion
59 Completion is a feature present in many shells. It allows the user to
60 type only a part (usually the prefix) of a word and have the shell fill
61 in the rest. The completion system in zsh is programmable. For exam‐
62 ple, the shell can be set to complete email addresses in arguments to
63 the mail command from your ~/.abook/addressbook; usernames, hostnames,
64 and even remote paths in arguments to scp, and so on. Anything that
65 can be written in or glued together with zsh can be the source of what
66 the line editor offers as possible completions.
67
68 Zsh has two completion systems, an old, so called compctl completion
69 (named after the builtin command that serves as its complete and only
70 user interface), and a new one, referred to as compsys, organized as
71 library of builtin and user-defined functions. The two systems differ
72 in their interface for specifying the completion behavior. The new
73 system is more customizable and is supplied with completions for many
74 commonly used commands; it is therefore to be preferred.
75
76 The completion system must be enabled explicitly when the shell starts.
77 For more information see zshcompsys(1).
78
79 Extending the line editor
80 Apart from completion, the line editor is highly extensible by means of
81 shell functions. Some useful functions are provided with the shell;
82 they provide facilities such as:
83
84 insert-composed-char
85 composing characters not found on the keyboard
86
87 match-words-by-style
88 configuring what the line editor considers a word when moving or
89 deleting by word
90
91 history-beginning-search-backward-end, etc.
92 alternative ways of searching the shell history
93
94 replace-string, replace-pattern
95 functions for replacing strings or patterns globally in the com‐
96 mand line
97
98 edit-command-line
99 edit the command line with an external editor.
100
101 See the section `ZLE Functions' in zshcontrib(1) for descriptions of
102 these.
103
105 The shell has a large number of options for changing its behaviour.
106 These cover all aspects of the shell; browsing the full documentation
107 is the only good way to become acquainted with the many possibilities.
108 See zshoptions(1).
109
111 The shell has a rich set of patterns which are available for file
112 matching (described in the documentation as `filename generation' and
113 also known for historical reasons as `globbing') and for use when pro‐
114 gramming. These are described in the section `Filename Generation' in
115 zshexpn(1).
116
117 Of particular interest are the following patterns that are not commonly
118 supported by other systems of pattern matching:
119
120 ** for matching over multiple directories
121
122 | for matching either of two alternatives
123
124 ~, ^ the ability to exclude patterns from matching when the EX‐
125 TENDED_GLOB option is set
126
127 (...) glob qualifiers, included in parentheses at the end of the pat‐
128 tern, which select files by type (such as directories) or attri‐
129 bute (such as size).
130
132 Although the syntax of zsh is in ways similar to the Korn shell, and
133 therefore more remotely to the original UNIX shell, the Bourne shell,
134 its default behaviour does not entirely correspond to those shells.
135 General shell syntax is introduced in the section `Shell Grammar' in
136 zshmisc(1).
137
138 One commonly encountered difference is that variables substituted onto
139 the command line are not split into words. See the description of the
140 shell option SH_WORD_SPLIT in the section `Parameter Expansion' in zsh‐
141 expn(1). In zsh, you can either explicitly request the splitting (e.g.
142 ${=foo}) or use an array when you want a variable to expand to more
143 than one word. See the section `Array Parameters' in zshparam(1).
144
146 The most convenient way of adding enhancements to the shell is typi‐
147 cally by writing a shell function and arranging for it to be au‐
148 toloaded. Functions are described in the section `Functions' in zsh‐
149 misc(1). Users changing from the C shell and its relatives should no‐
150 tice that aliases are less used in zsh as they don't perform argument
151 substitution, only simple text replacement.
152
153 A few general functions, other than those for the line editor described
154 above, are provided with the shell and are described in zshcontrib(1).
155 Features include:
156
157 promptinit
158 a prompt theme system for changing prompts easily, see the sec‐
159 tion `Prompt Themes'
160
161
162 zsh-mime-setup
163 a MIME-handling system which dispatches commands according to
164 the suffix of a file as done by graphical file managers
165
166 zcalc a calculator
167
168 zargs a version of xargs that makes the find command redundant
169
170 zmv a command for renaming files by means of shell patterns.
171
172
173
174zsh 5.8.1 February 12, 2022 ZSHROADMAP(1)