Gentoo Archives: gentoo-doc-cvs

From: Xavier Neys <neysx@×××××××××××.org>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] cvs commit: metadoc.xml zsh.xml
Date: Sun, 03 Sep 2006 19:41:26
Message-Id: 20060903194114.B548D652FE@smtp.gentoo.org
1 neysx 06/09/03 19:41:14
2
3 Modified: metadoc.xml
4 Added: zsh.xml
5 Log:
6 New doc from #123322
7
8 Revision Changes Path
9 1.164 xml/htdocs/doc/en/metadoc.xml
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/metadoc.xml?rev=1.164&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/metadoc.xml?rev=1.164&content-type=text/plain
13 diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/metadoc.xml?r1=1.163&r2=1.164
14
15 Index: metadoc.xml
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v
18 retrieving revision 1.163
19 retrieving revision 1.164
20 diff -u -r1.163 -r1.164
21 --- metadoc.xml 2 Sep 2006 10:04:16 -0000 1.163
22 +++ metadoc.xml 3 Sep 2006 19:41:14 -0000 1.164
23 @@ -1,5 +1,5 @@
24 <?xml version='1.0' encoding="UTF-8"?>
25 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v 1.163 2006/09/02 10:04:16 nightmorph Exp $ -->
26 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v 1.164 2006/09/03 19:41:14 neysx Exp $ -->
27 <!DOCTYPE metadoc SYSTEM "/dtd/metadoc.dtd">
28
29 <metadoc lang="en">
30 @@ -391,6 +391,7 @@
31 <file id="info-guide">/doc/en/info-guide.xml</file>
32 <file id="java-upgrade">/proj/en/java/java-upgrade.xml</file>
33 <file id="kernel-config">/doc/en/kernel-config.xml</file>
34 + <file id="zsh">/doc/en/zsh.xml</file>
35 </files>
36 <docs>
37 <doc id="name-logo">
38 @@ -1278,5 +1279,9 @@
39 <memberof>sysadmin_general</memberof>
40 <fileid>kernel-config</fileid>
41 </doc>
42 + <doc id="zsh">
43 + <memberof>sysadmin_general</memberof>
44 + <fileid>zsh</fileid>
45 + </doc>
46 </docs>
47 </metadoc>
48
49
50
51 1.1 xml/htdocs/doc/en/zsh.xml
52
53 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/zsh.xml?rev=1.1&view=markup
54 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/zsh.xml?rev=1.1&content-type=text/plain
55
56 Index: zsh.xml
57 ===================================================================
58 <?xml version="1.0" encoding="UTF-8"?>
59 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
60 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/zsh.xml,v 1.1 2006/09/03 19:41:14 neysx Exp $ -->
61
62 <guide link="/doc/en/zsh.xml" lang="en">
63
64 <title>zsh Configuration and Installation Guide</title>
65
66 <author title="Author">
67 <mail link="hak8@××.pl">Henryk Konsek</mail>
68 </author>
69 <author title="Author">
70 <mail link="morritt.andrew@×××××.com">Andrew Morritt</mail>
71 </author>
72 <author title="Editor">
73 <mail link="chriswhite@g.o">Chris White</mail>
74 </author>
75 <author title="Editor">
76 <mail link="welp@×××××××××.uk">Peter Weller</mail>
77 </author>
78
79 <abstract>
80 This guide shows how to install and configure zsh quickly. After reading this
81 document you will be able use many zsh features such as advanced
82 tab-completion, command correction and prompt management.
83 </abstract>
84
85 <!-- The content of this document is licensed under the CC-BY-SA license -->
86 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
87 <license/>
88
89 <version>1</version>
90 <date>2006-09-03</date>
91
92 <chapter>
93 <title>Installation</title>
94 <section>
95 <title>Installing zsh</title>
96 <body>
97
98 <p>
99 To install <c>zsh</c> under Gentoo, we need to emerge the <c>app-shells/zsh</c>
100 (zsh itself) and <c>app-shells/zsh-completion</c> (zsh completion scripts)
101 packages.
102 </p>
103
104 <pre caption="Emerging zsh">
105 # <i>emerge zsh zsh-completion</i>
106 </pre>
107
108 </body>
109 </section>
110 <section>
111 <title>Entering zsh</title>
112 <body>
113
114 <p>
115 When you start <c>zsh</c> for the first time, you get the following message.
116 You can skip this menu as we will create an init file later in this guide.
117 </p>
118
119 <pre caption="Skipping the initial config">
120 $ <i>zsh</i>
121 This is the Z Shell configuration function for new users, zsh-newuser-install.
122 You are seeing this message because you have no zsh startup files
123 (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
124 ~). This function can help you with a few settings that should
125 make your use of the shell easier.
126
127 You can:
128
129 (q) Quit and do nothing. The function will be run again next time.
130
131 (0) Exit, creating the file ~/.zshrc containing just a comment.
132 That will prevent this function being run again.
133
134 (1) Continue to the main menu.
135
136 --- Type one of the keys in parentheses --- <i>q</i>
137 </pre>
138
139 </body>
140 </section>
141 </chapter>
142
143 <chapter>
144 <title>Configuration</title>
145 <section>
146 <title>Introduction</title>
147 <body>
148
149 <p>
150 To start zsh for a single session, run <c>zsh</c>, for a more permanent
151 solution, please refer to the chapter on <uri link="#savingsettings">Saving
152 settings</uri>. After the installation, <c>zsh</c> seems to be very simple and
153 rather limited in the area of functionality. To change this, several
154 configuration changes need to be performed.
155 </p>
156
157 </body>
158 </section>
159 <section>
160 <title>Advanced Tab-completion</title>
161 <body>
162
163 <p>
164 To enable the famous <c>zsh</c> tab-completion system, you need to run the
165 following commands:
166 </p>
167
168 <pre caption="Enabling completion">
169 % <i>autoload -U compinit</i>
170 % <i>compinit</i>
171 </pre>
172
173 <p>
174 Default completion style is quite plain and ugly. If you want to improve its
175 appearance, enter the following commands:
176 </p>
177
178 <pre caption="Completion style improvements">
179 % <i>zstyle ':completion:*:descriptions' format '%U%B%d%b%u'</i>
180 % <i>zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'</i>
181 </pre>
182
183 </body>
184 </section>
185 <section>
186 <title>Command correction</title>
187 <body>
188
189 <p>
190 It is also a good idea to enable the auto-correction of the commands typed:
191 </p>
192
193 <pre caption="Enabling correction">
194 % <i>setopt correctall</i>
195 </pre>
196
197 </body>
198 </section>
199 <section>
200 <title>Prompts</title>
201 <body>
202
203 <p>
204 The prompt may seem quite boring however, but we can fix it easily in several
205 steps. First, we need to initialize advanced prompt support:
206 </p>
207
208 <pre caption="Enabling advanced prompts">
209 % <i>autoload -U promptinit</i>
210 % <i>promptinit</i>
211 </pre>
212
213 <p>
214 Available prompts samples may be printed via the <c>prompt -p</c> command. Now
215 we can activate our favorite one:
216 </p>
217
218 <pre caption="Choosing a sample prompt">
219 <comment>(Replace gentoo with the prompt of your choice)</comment>
220 % <i>prompt gentoo</i>
221 </pre>
222
223 <note>
224 If you're playing around with the different prompts, and you don't want to
225 see a sample of every one, you can use <c>prompt -l</c> to list the prompts
226 available.
227 </note>
228
229 <p>
230 Another option is to create your own prompt. To do this you will need to set
231 the PS1 environment variable.
232 </p>
233
234 <pre caption="A simple custom prompt">
235 % <i>export PS1="[Test Prompt] > "</i>
236 [Test Prompt] >
237 </pre>
238
239 <p>
240 While it is good to be able to create a custom text prompt, zsh also provides
241 many escape sequences that allow system information to be inserted into the
242 prompt. Some of the escape sequences available are:
243 </p>
244
245 <table>
246 <tr>
247 <th>Sequence</th>
248 <th>Printed</th>
249 </tr>
250 <tr>
251 <ti>%T</ti>
252 <ti>System time (HH:MM)</ti>
253 </tr>
254 <tr>
255 <ti>%*</ti>
256 <ti>System time (HH:MM:SS)</ti>
257 </tr>
258 <tr>
259 <ti>%D</ti>
260 <ti>System date (YY-MM-DD)</ti>
261 </tr>
262 <tr>
263 <ti>%n</ti>
264 <ti>Your username</ti>
265 </tr>
266 <tr>
267 <ti>%B - %b</ti>
268 <ti>Begin - end bold print</ti>
269 </tr>
270 <tr>
271 <ti>%U - %u</ti>
272 <ti>Begin - end underlining</ti>
273 </tr>
274 <tr>
275 <ti>%d</ti>
276 <ti>Your current working directory</ti>
277 </tr>
278 <tr>
279 <ti>%~</ti>
280 <ti>Your current working directory, relative to ~</ti>
281 </tr>
282 <tr>
283 <ti>%M</ti>
284 <ti>The computer's hostname</ti>
285 </tr>
286 <tr>
287 <ti>%m</ti>
288 <ti>The computer's hostname (truncated before the first period)</ti>
289 </tr>
290 <tr>
291 <ti>%l</ti>
292 <ti>Your current tty</ti>
293 </tr>
294 </table>
295
296 <p>
297 These escape sequences may simply be inserted into the environment variable,
298 PS1, and zsh will parse them automatically.
299 </p>
300
301 <pre caption="A more complex prompt">
302 % <i>export PS1="[%* - %D] %d %% "</i>
303 [08:44:23 - 06-02-18] /home/username %
304 </pre>
305
306 </body>
307 </section>
308 <section>
309 <title>History</title>
310 <body>
311
312 <p>
313 Unfortunately, the default zsh configuration in Gentoo does not include command
314 history support. As working with a shell without history is very frustrating,
315 we should enter the following commands:
316 </p>
317
318 <pre caption="Basic history configuration">
319 % <i>export HISTSIZE=2000</i>
320 % <i>export HISTFILE="$HOME/.history"</i>
321
322 <comment>(History won't be saved without the following command)</comment>
323 % <i>export SAVEHIST=$HISTSIZE</i>
324 </pre>
325
326 <!-- does not work
327 <p>
328 It is very comfortable to search commands in history using the up/down arrow
329 keys, especially after typing the few first letters of the desired command.
330 </p>
331
332 <p>
333 To enable this feature, enter the following commands:
334 </p>
335
336 <pre caption="Setting context searching">
337 % <i>bindkey `tput kcuu1` history-beginning-search-backward >/dev/null 2>&amp;1</i>
338 % <i>bindkey `tput kcud1` history-beginning-search-forward >/dev/null 2>&amp;1 </i>
339 </pre>
340
341 <p>
342 To try the above feature, try the following commands:
343 </p>
344
345 TODO: use commands that *are* in the history, i.e. commands from above samples
346
347 <pre caption="History searching based on the first letters of the commands">
348 <comment>(Do not press Enter after typing)</comment>
349 % <i>vim /etc/</i>
350 <comment>(Now press up arrow key)</comment>
351 % <i>vim /etc/fstab</i>
352 <comment>(Press up arrow key once again)</comment>
353 % <i>vim /etc/X11/xorg.conf</i>
354 </pre>
355 -->
356
357 <p>
358 To prevent history from recording duplicated entries (such as <c>ls -l</c>
359 entered many times during single shell session), you can set the
360 <c>hist_ignore_all_dups</c> option:
361 </p>
362
363 <pre caption="Setting ignoring of duplicates ">
364 % <i>setopt hist_ignore_all_dups</i>
365 </pre>
366
367 <p>
368 A useful trick to prevent particular entries from being recorded
369 into a history by preceding them with at least one space.
370 </p>
371
372 <pre caption="Preventing particular entry from being recorded">
373 % <i>setopt hist_ignore_space</i>
374
375 <comment>(This command won't be recorded. Note the extra space before it.)</comment>
376 % <i> cat /proc/cpuinfo</i>
377 </pre>
378
379 </body>
380 </section>
381 <section>
382 <title>Miscellaneous settings</title>
383 <body>
384
385 <p>
386 You can set the <c>autocd</c> option if you want to avoid tedious typing of
387 <c>cd</c> command while changing current directory (for example
388 <c>/etc</c> instead of <c>cd /etc</c>).
389 </p>
390
391 <pre caption="Setting autocd option">
392 % <i>setopt autocd</i>
393 </pre>
394
395 <p>
396 If standard bash-like globbing does not satisfy you, <c>extendedglob</c>
397 option may be set to enable extended globbing (one similar to
398 regular expressions).
399 </p>
400
401 <pre caption="Setting extended globbing">
402 % <i>setopt extendedglob</i>
403 </pre>
404
405 <p>
406 When option above is set, you are able to use extended globbing queries
407 such as <c>cp ^*.(tar|bz2|gz)</c>.
408 </p>
409
410 </body>
411 </section>
412 </chapter>
413
414 <chapter id="savingsettings">
415 <title>Saving settings</title>
416 <section>
417 <title>Saving zsh settings</title>
418 <body>
419
420 <p>
421 Once we have customized <c>zsh</c> the way we like it, it is a good idea to
422 save these options as the <c>zsh</c> defaults for the system.
423 One possible way to achieve this is to write our settings in the
424 <path>/etc/zsh/zshrc</path> script. Alternatively, we could make them the defaults for our account only be editing <path>~/.zshrc</path>.
425 </p>
426
427 <pre caption="An example zshrc">
428 #!/bin/zsh
429
430 # completion
431 autoload -U compinit
432 compinit
433
434 # correction
435 setopt correctall
436
437 # prompt
438 autoload -U promptinit
439 promptinit
440 prompt gentoo
441 </pre>
442
443 <p>
444 The last thing we need to do is set the zshrc script as executable:
445 </p>
446
447 <pre caption="Making zshrc executable">
448 % <i>chmod a+x /etc/zsh/zshrc</i>
449 </pre>
450
451 </body>
452 </section>
453 </chapter>
454
455 <chapter>
456 <title>Making zsh default shell</title>
457 <section>
458 <title>Option for users with root privileges</title>
459 <body>
460
461 <p>
462 We can change shell for given user with <c>usermod</c> command.
463 </p>
464
465 <pre caption="Switching to zsh permanently using usermod">
466 # <i>usermod -s /bin/zsh userlogin</i>
467 </pre>
468
469 </body>
470 </section>
471 <section>
472 <title>Alternative for non-root users</title>
473 <body>
474
475 <p>
476 If your system administrator (despite gentle requests, that is) refuses to set
477 the shell to zsh for you, you can set <c>bash</c> to execute <c>zsh</c> on
478 startup, all you need to do is make a slight modification to your
479 <path>~/.bashrc</path>.
480 </p>
481
482 <pre caption="Sample ~/.bashrc">
483 <comment>(Add the following to your ~/.bashrc)</comment>
484 exec zsh
485 </pre>
486
487 <p>
488 Another method of changing shells is to use the <c>chsh</c> command (a utility
489 used to change a user's login shell). A normal user may only change the login
490 shell for his own account. As root, you can change the login shell of any user.
491 </p>
492
493 <pre caption="Switching to zsh permanently using chsh">
494 <comment>(Replace "username" with your own username)</comment>
495 $ <i>chsh -s /bin/zsh username</i>
496 </pre>
497
498 </body>
499 </section>
500 </chapter>
501 </guide>
502
503
504
505 --
506 gentoo-doc-cvs@g.o mailing list