Merge remote-tracking branch 'origin/github/pr/45'
[grml.org.git] / zsh / grmlzshrc.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>GRMLZSHRC</title>
5 <meta name="generator" content="http://txt2tags.org">
6 <link rel="stylesheet" href="t2t-modern.css">
7 <style>
8 body{background-color:#fff;color:#000;}
9 hr{background-color:#000;border:0;color:#000;}
10 hr.heavy{height:5px;}
11 hr.light{height:1px;}
12 img{border:0;display:block;}
13 img.right{margin:0 0 0 auto;}
14 img.center{border:0;margin:0 auto;}
15 table th,table td{padding:4px;}
16 .center,header{text-align:center;}
17 table.center {margin-left:auto; margin-right:auto;}
18 .right{text-align:right;}
19 .left{text-align:left;}
20 .tableborder,.tableborder td,.tableborder th{border:1px solid #000;}
21 .underline{text-decoration:underline;}
22 </style>
23 </head>
24 <body>
25 <header>
26 <hgroup>
27 <h1>GRMLZSHRC</h1>
28 <h3>September, 2014</h3>
29 </hgroup>
30 </header>
31 <article>
32
33 <div class="body" id="body">
34
35 <section>
36 <h1>NAME</h1>
37
38 <p>
39 grmlzshrc - Grml's zsh setup
40 </p>
41
42 </section>
43 <section>
44 <h1>SYNOPSIS</h1>
45
46 <p>
47 <em>zsh</em> [<strong>options</strong>]...
48 </p>
49
50 </section>
51 <section>
52 <h1>DESCRIPTION</h1>
53
54 <p>
55 The Grml project provides a fairly exhaustive interactive setup (referred to
56 as <em>grmlzshrc</em> throughout this document) for the amazing unix shell zsh
57 (<a href="http://zsh.sourceforge.net">http://zsh.sourceforge.net</a>). This is the reference manual for that
58 setup.
59 </p>
60 <p>
61 To use <em>grmlzshrc</em>, you need at least version 3.1.7 of zsh (although not all
62 features are enabled in every version).
63 </p>
64 <p>
65 <em>grmlzshrc</em> behaves differently depending on which user loads it. For the
66 root user (<strong>EUID</strong> == 0) only a subset of features is loaded by default. This
67 behaviour can be altered by setting the <strong>GRML_ALWAYS_LOAD_ALL</strong> STARTUP
68 VARIABLE (see below).
69 </p>
70 <p>
71 Users may want to keep an up-to-date version of the setup (possibly from the
72 git-sources) in <em>~/.zshrc</em>. If that happens on a system where the global
73 zshrc is also a <em>grmlzshrc</em> (but possibly an older one), you can inhibit
74 loading the global version by doing:
75 \
76 </p>
77
78 <pre>
79 echo setopt no_global_rcs &gt;&gt; ~/.zshenv
80 </pre>
81
82 <p>
83 Note, that this will disable <em>ANY</em> global files, except for the global
84 zshenv file.
85 </p>
86
87 </section>
88 <section>
89 <h1>STARTUP VARIABLES</h1>
90
91 <p>
92 Some of the behaviour of <em>grmlzshrc</em> can be altered by setting certain shell
93 variables. These may be set temporarily when starting zsh like this:
94 \
95 </p>
96
97 <pre>
98 % GRML_DISPLAY_BATTERY=1 zsh
99 </pre>
100
101 <p>
102 Or by setting them permanently in <strong>zshrc.pre</strong> (See AUXILIARY FILES below).
103 </p>
104
105 <dl>
106 <dt><strong>BATTERY</strong></dt><dd>
107 Deprecated. Use <strong>GRML_DISPLAY_BATTERY</strong> instead.
108 <p></p>
109 </dd>
110 <dt><strong>COMMAND_NOT_FOUND</strong></dt><dd>
111 A non zero value activates a handler, which is called when a command can not
112 be found. The handler is defined by GRML_ZSH_CNF_HANDLER (see below).
113 <p></p>
114 </dd>
115 <dt><strong>GRML_COMP_CACHING</strong></dt><dd>
116 If set to <em>yes</em> (the default), the setup will enable zsh's completion caching
117 mechanism, with the caching data being placed into <em>$GRML_COMP_CACHE_DIR</em>.
118 <p></p>
119 </dd>
120 <dt><strong>GRML_COMP_CACHE_DIR</strong></dt><dd>
121 This defines where zsh's completion caching data will be placed, if
122 <em>$GRML_COMP_CACHING</em> is active. The default is <em>${ZDOTDIR:-$HOME}/.cache</em>.
123 The setup will ensure the directory exists before attempting to use it.
124 <p></p>
125 </dd>
126 <dt><strong>GRML_DISPLAY_BATTERY</strong></dt><dd>
127 If set to a value greater than zero, <em>grmlzshrc</em> will put the battery status
128 into the right hand side interactive prompt. Supported OSes are <em>GNU/Linux</em>,
129 <em>FreeBSD</em>, <em>OpenBSD</em> and <em>Darwin</em>.
130 <p></p>
131 </dd>
132 <dt><strong>GRML_ZSH_CNF_HANDLER</strong></dt><dd>
133 This variable contains the handler to be used by COMMAND_NOT_FOUND (see above)
134 and defaults to "/usr/share/command-not-found/command-not-found".
135 <p></p>
136 </dd>
137 <dt><strong>GRML_NO_APT_ALIASES</strong></dt><dd>
138 A non-empty value inhibits the definition of apt-specific short aliases,
139 such as ag, agi, ati etc.
140 <p></p>
141 </dd>
142 <dt><strong>GRML_NO_SMALL_ALIASES</strong></dt><dd>
143 A non-empty value inhibits the definition of 2-letter aliases such as da.
144 ls, ll, la and other common ls-related aliases are exempt from this, as are
145 the aliases inhibited by GRML_NO_APT_ALIASES.
146 <p></p>
147 </dd>
148 <dt><strong>GRMLSMALL_SPECIFIC</strong></dt><dd>
149 Set this to zero to remove items in zsh config, which do not work in
150 grml-small.
151 <p></p>
152 </dd>
153 <dt><strong>HISTFILE</strong></dt><dd>
154 Where zsh saves the history. Default: ${HOME}/.zsh_history.
155 <p></p>
156 </dd>
157 <dt><strong>HISTSIZE</strong></dt><dd>
158 Number of commands to be kept in the history. On a Grml-CD this defaults to
159 500, on a hard disk installation to 5000.
160 <p></p>
161 </dd>
162 <dt><strong>MAILCHECK</strong></dt><dd>
163 Sets the frequency in seconds for zsh to check for new mail. Defaults to 30.
164 A value of zero turns off checking.
165 <p></p>
166 </dd>
167 <dt><strong>NOCOR</strong></dt><dd>
168 Non zero values deactivate automatic correction of commands.
169 <p></p>
170 </dd>
171 <dt><strong>NOMENU</strong></dt><dd>
172 If set to zero (default), allows selection from a menu, if there are at least
173 five possible options of completion.
174 <p></p>
175 </dd>
176 <dt><strong>NOPRECMD</strong></dt><dd>
177 A non zero value disables precmd and preexec commands. These are functions
178 that are run before every command (setting xterm/screen titles etc.).
179 <p></p>
180 </dd>
181 <dt><strong>REPORTTIME</strong></dt><dd>
182 Show time (user, system and cpu) used by external commands, if they run longer
183 than the defined number of seconds (default: 5).
184 <p></p>
185 </dd>
186 <dt><strong>SAVEHIST</strong></dt><dd>
187 Number of commands to be stored in ${HISTFILE}. Defaults to 1000 on a Grml-CD
188 and to 10000 on an installation on hard disk.
189 <p></p>
190 </dd>
191 <dt><strong>watch</strong></dt><dd>
192 As in tcsh(1) an array of login/logout events to be reported by the shell
193 builtin "log". For details see zshparam(1). Defaults to (notme root).
194 <p></p>
195 </dd>
196 <dt><strong>ZSH_NO_DEFAULT_LOCALE</strong></dt><dd>
197 Import "/etc/default/locale", if set to zero (default).
198 <p></p>
199 </dd>
200 <dt><strong>ZSH_PROFILE_RC</strong></dt><dd>
201 A non zero value causes shell functions to be profiled. The results can be
202 obtained with the zprof builtin command (see zshmodules(1) for details).
203 <p></p>
204 </dd>
205 <dt><strong>COMPDUMPFILE</strong></dt><dd>
206 Specifies the location of the completion dump file. Default: $HOME/.zcompdump.
207 </dd>
208 </dl>
209
210 </section>
211 <section>
212 <h1>GRML-ZSHRC SPECIFIC STYLES</h1>
213
214 <p>
215 Styles are a context sensitive configuration mechanism included with zsh. The
216 shell uses it extensively in sub-systems like the completion and the VCS info
217 system. It lives outside of the classic shell variable namespace, so it avoids
218 polluting it. New functionality in grml's zshrc will likely use styles instead
219 of variables. Some features of the setup (like the directory stack handling)
220 already use styles. Those styles are documented with the specific features.
221 This section documents more general styles.
222 </p>
223
224 <section>
225 <h2>Context: :grml:completion:compinit</h2>
226
227 <p>
228 This context revolves around the zshrc's <em>compinit</em> function call, that
229 initialises zsh's function based completion system.
230 </p>
231
232 <dl>
233 <dt><strong>arguments</strong></dt><dd>
234 This style allows the injection of arguments to the command line that is used
235 to run compinit. It is a list style and its default is the empty list. Using
236 this style, it's possible to add <strong>-i</strong> to <em>compinit</em> in order to disable
237 <em>compaudit</em>.
238 \
239
240 <pre>
241 zstyle ':grml:completion:compinit' arguments -i
242 </pre>
243
244 \
245 Only do this, if you know what sort of security checks are disabled if
246 <em>compaudit</em> is not active and if that's acceptable with your specific setup.
247 \
248 This style has to be set at the point that Grml's zshrc runs <em>compinit</em>. A
249 possible way to achieve this is to set it in <em>~/.zshrc.pre</em> (see AUXILIARY
250 FILES below for details).
251 </dd>
252 </dl>
253
254 </section>
255 </section>
256 <section>
257 <h1>FEATURE DESCRIPTION</h1>
258
259 <p>
260 This is an in depth description of non-standard features implemented by
261 <em>grmlzshrc</em>.
262 </p>
263
264 <section>
265 <h2>DIRSTACK HANDLING</h2>
266
267 <p>
268 The dirstack in <em>grmlzshrc</em> has a persistent nature. It is stored into a
269 file each time zsh's working directory is changed. That file can be configured
270 via the <strong>DIRSTACKFILE</strong> variable and it defaults to <strong>~/.zdirs</strong>. The
271 <strong>DIRSTACKSIZE</strong> variable defaults to <strong>20</strong> in this setup.
272 </p>
273 <p>
274 The <strong>DIRSTACKFILE</strong> is loaded each time zsh starts, therefore freshly started
275 zshs inherit the dirstack of the zsh that most recently updated
276 <strong>DIRSTACKFILE</strong>.
277 </p>
278 <p>
279 If you would like to <em>disable</em> the persistent dirstack feature altogether,
280 you can do that by setting the boolean <em>enable</em> style to <em>false</em> in the
281 right context (the default is <em>true</em>):
282 \
283 </p>
284
285 <pre>
286 zstyle ':grml:chpwd:dirstack' enable false
287 </pre>
288
289 <p>
290 It is possible to apply a filter to the names of directories that will be
291 committed to the persistent dirstack file. There are two ways to configure this
292 filter: A general function based filter and a pattern based filter. Both are
293 setup via styles in the <strong>':grml:chpwd:dirstack'</strong> context.
294 </p>
295 <p>
296 To use a function based filter set the <em>filter</em> style for that context to the
297 name of a function to call every time a directory name is to be added to the
298 persistent dirstack. If the function's return value signals success (ie. return
299 value "0"), the directory name is filtered out and <strong>not</strong> added to the
300 persistent stack. Example:
301 \
302 </p>
303
304 <pre>
305 function my_dirstack_filter() { [[ $1 == /tmp(|/*) ]] }
306 zstyle ':grml:chpwd:dirstack' filter my_dirstack_filter
307 </pre>
308
309 <p>
310 The pattern based filter uses a list of patterns passed to the <em>exclude</em>
311 style in the aforementioned context. Each pattern is tested and the first that
312 matches will keep the directory name from being added to the persistent stack.
313 If none of the patterns matches, the name is added. example:
314 \
315 </p>
316
317 <pre>
318 zstyle ':grml:chpwd:dirstack' exclude "/tmp(|/*)" "$HOME/tmp(|/*)"
319 </pre>
320
321 <p>
322 The function based filter is more general, the pattern based filter easier to
323 set up. If both filter variants are used at the same time, the function based
324 filter will be executed <em>before</em> the pattern based one.
325 </p>
326 <p>
327 If you would like to apply your filters while <em>loading</em> the persistent
328 dirstack file, set the <em>filter-on-load</em> boolean style (the default is
329 <em>false</em>):
330 \
331 </p>
332
333 <pre>
334 zstyle ':grml:chpwd:dirstack' filter-on-load true
335 </pre>
336
337 <p>
338 Setting the <em>filter-on-load</em> and <em>enable</em> styles needs to be done in
339 ".zshrc.pre" because the styles need to be set when the main setup is
340 executing! The other styles do not have this limitation, but enabling the
341 system as well as the initial filtering will obviously be done using settings
342 and filters that are configured <strong>at</strong> <strong>that</strong> <strong>point</strong>.
343 </p>
344 <p>
345 With respect to <em>filter-on-load</em>, the rule of thumb is: If you want to filter
346 on load, setup everything in ".zshrc.pre" otherwise ".zshrc.local" works just
347 as well.
348 </p>
349
350 </section>
351 <section>
352 <h2>DIRECTORY BASED PROFILES</h2>
353
354 <p>
355 If you need to perform certain actions each time you enter certain
356 directory-trees, this is the feature you are looking for.
357 </p>
358
359 <section>
360 <h3>Initialisation</h3>
361
362 <p>
363 To initialise the system, you need to call the function `chpwd_profiles' at
364 some point in your `zshrc.local'; preferably <strong>after</strong> you configured the
365 system. The configuration of the system is described further below.
366 </p>
367 <p>
368 If you need to do initialisations the first time `chpwd_profiles' is called
369 (which should be in your configuration file), you can do that in a function
370 called "chpwd_profiles_init". That function needs to be defined <strong>before</strong>
371 `chpwd_profiles' is called for this to work.
372 </p>
373 <p>
374 During the <strong>first</strong> call of `chpwd_profiles' (and therefore all its profile
375 functions) the parameter `$CHPWD_PROFILES_INIT' exists and is set to `1'. In
376 all other cases, the parameter does not exist at all.
377 </p>
378
379 </section>
380 <section>
381 <h3>Styles and Profile-names</h3>
382
383 <p>
384 To store its configuration, the system uses <strong>functions</strong> and <strong>styles</strong>
385 (zsh's context sensitive configuration system), such as this:
386 </p>
387 <p>
388 \
389 </p>
390
391 <pre>
392 zstyle ':chpwd:profiles:/usr/src/grml(|/|/*)'   profile grml
393 zstyle ':chpwd:profiles:/usr/src/debian(|/|/*)' profile debian
394 </pre>
395
396 <p>
397 When that's done and you enter a directory that matches the pattern in the
398 third part of the context, a function called chpwd_profile_grml, for example,
399 is called (if it exists).
400 </p>
401 <p>
402 If no pattern matches (read: no profile is detected) the profile is set to
403 'default', which means chpwd_profile_default is attempted to be called.
404 </p>
405 <p>
406 A word about the context (the ':chpwd:profiles:*' stuff in the zstyle command)
407 which is used: The third part in the context is matched against ${PWD}. That's
408 why using a pattern such as /foo/bar(|/|/*) makes sense. Because that way the
409 profile is detected for all these values of ${PWD}:
410 \
411 </p>
412
413 <pre>
414   /foo/bar
415   /foo/bar/
416   /foo/bar/baz
417 </pre>
418
419 <p>
420 So, if you want to make double damn sure a profile works in /foo/bar and
421 everywhere deeper in that tree, just use (|/|/*) and be happy.
422 </p>
423 <p>
424 The name of the detected profile will be available in a variable called
425 'profile' in your functions. You don't need to do anything, it'll just be
426 there.
427 </p>
428
429 </section>
430 <section>
431 <h3>Controlling Profile Execution</h3>
432
433 <p>
434 During its initialisation run, the system creates a parameter $CHPWD_PROFILE,
435 which is set to the profile that was is currently active (the default value is
436 "default"). That way you can avoid running code for a profile that is already
437 active, by running code such as the following at the start of your function:
438 \
439 </p>
440
441 <pre>
442 function chpwd_profile_grml() {
443     [[ ${profile} == ${CHPWD_PROFILE} ]] &amp;&amp; return 1
444   ...
445 }
446 </pre>
447
448 <p>
449 If you know you are going to do that all the time for each and every
450 directory-profile function you are ever going to write, you may also set the
451 `re-execute' style to `false' (which only defaults to `true' for backwards
452 compatibility), like this:
453 \
454 </p>
455
456 <pre>
457   zstyle ':chpwd:profiles:*' re-execute false
458 </pre>
459
460 </section>
461 <section>
462 <h3>Signaling availabily/profile changes</h3>
463
464 <p>
465 If you use this feature and need to know whether it is active in your current
466 shell, there are several ways to do that. Here are two simple ways:
467 </p>
468 <p>
469 a) If knowing if the profiles feature is active when zsh starts is good
470 enough for you, you can use the following snippet:
471 </p>
472 <p>
473 (( ${+functions[chpwd_profiles]} )) &amp;&amp; print "directory profiles active"
474 </p>
475 <p>
476 b) If that is not good enough, and you would prefer to be notified whenever a
477 profile changes, you can solve that by making sure you start <strong>every</strong>
478 profile function you create like this:
479 </p>
480 <p>
481 function chpwd_profile_myprofilename() {
482     [[ ${profile} == ${CHPWD_PROFILE} ]] &amp;&amp; return 1
483     print "chpwd(): Switching to profile: $profile"
484   ...
485 }
486 </p>
487 <p>
488 That makes sure you only get notified if a profile is <strong>changed</strong>, not
489 everytime you change directory. (To avoid this, you may also set the newer
490 `re-execute' style like described further above instead of the test on top of
491 the function.
492 </p>
493
494 </section>
495 <section>
496 <h3>Leaving Profiles</h3>
497
498 <p>
499 When the system switches from one profile to another, it executes a function
500 named "chpwd_leave_profile_&lt;PREVIOUS-PROFILE-NAME&gt;()" before calling the
501 profile-function for the new profile.
502 </p>
503
504 </section>
505 <section>
506 <h3>Version requirement</h3>
507
508 <p>
509 This feature requires zsh <em>4.3.3</em> or newer.
510 </p>
511
512 </section>
513 </section>
514 <section>
515 <h2>ACCEPTLINE WRAPPER</h2>
516
517 <p>
518 The <em>accept-line</em> wiget is the one that is taking action when the <strong>return</strong>
519 key is hit. <em>grmlzshrc</em> uses a wrapper around that widget, which adds new
520 functionality.
521 </p>
522 <p>
523 This wrapper is configured via styles. That means, you issue commands, that look
524 like:
525 \
526 </p>
527
528 <pre>
529 zstyle 'context' style value
530 </pre>
531
532 <p>
533 The context namespace, that we are using is 'acceptline'. That means, the actual
534 context for your commands look like: <strong>':acceptline:&lt;subcontext&gt;'</strong>.
535 </p>
536 <p>
537 Where <strong>&lt;subcontext&gt;</strong> is one of: <strong>default</strong>, <strong>normal</strong>, <strong>force</strong>, <strong>misc</strong>
538 or <strong>empty</strong>.
539 </p>
540
541 <section>
542 <h3>Recognized Contexts</h3>
543
544 <dl>
545 <dt><strong>default</strong></dt><dd>
546 This is the value, the context is initialized with.
547 The <em>compwarnfmt and //rehash</em> styles are looked up in this context.
548 <p></p>
549 </dd>
550 <dt><strong>normal</strong></dt><dd>
551 If the first word in the command line is either a command, alias, function,
552 builtin or reserved word, you are in this context.
553 <p></p>
554 </dd>
555 <dt><strong>force</strong></dt><dd>
556 This is the context, that is used if you hit enter again, after being warned
557 about the existence of a _completion for the non-existing command you
558 entered.
559 <p></p>
560 </dd>
561 <dt><strong>empty</strong></dt><dd>
562 This is the context, you are in if the command line is empty or only
563 consists of whitespace.
564 <p></p>
565 </dd>
566 <dt><strong>misc</strong></dt><dd>
567 This context is in effect, if you entered something that does not match any
568 of the above. (e.g.: variable assignments).
569 </dd>
570 </dl>
571
572 </section>
573 <section>
574 <h3>Available Styles</h3>
575
576 <dl>
577 <dt><strong>nocompwarn</strong></dt><dd>
578 If you set this style to true, the warning about non existent commands,
579 for which completions exist will not be issued. (Default: <strong>false</strong>)
580 <p></p>
581 </dd>
582 <dt><strong>compwarnfmt</strong></dt><dd>
583 The message, that is displayed to warn about the _completion issue.
584 (default: <strong>'%c will not execute and completion %f exists.'</strong>)
585 '%c' is replaced by the command name, '%f' by the completion's name.
586 <p></p>
587 </dd>
588 <dt><strong>rehash</strong></dt><dd>
589 If this is set, we'll force rehashing, if appropriate. (Defaults to
590 <strong>true</strong> in <em>grmlzshrc</em>).
591 <p></p>
592 </dd>
593 <dt><strong>actions</strong></dt><dd>
594 This can be a list of wigdets to call in a given context. If you need a
595 specific order for these to be called, name them accordingly. The default value
596 is an <strong>empty list</strong>.
597 <p></p>
598 </dd>
599 <dt><strong>default_action</strong></dt><dd>
600 The name of a widget, that is called after the widgets from 'actions'.
601 By default, this will be '.accept-line' (which is the built-in accept-line
602 widget).
603 <p></p>
604 </dd>
605 <dt><strong>call_default</strong></dt><dd>
606 If true in the current context, call the widget in the 'default_action'
607 style. (The default is <strong>true</strong> in all contexts.)
608 </dd>
609 </dl>
610
611 </section>
612 </section>
613 <section>
614 <h2>PROMPT</h2>
615
616 <p>
617 The <em>grmlzshrc</em> now supplies three prompt themes compatible with zsh's
618 <strong>promptinit</strong> system. The three themes are called <strong>grml</strong>, <strong>grml-large</strong> and
619 <strong>grml-chroot</strong>.
620 </p>
621 <p>
622 By default, <strong>grml</strong> is used, unless <em>$GRMLPROMPT</em> is set to a value larger
623 than zero, in which case <strong>grml-large</strong> is used. Lastly, if <em>$GRML_CHROOT</em> is
624 non-empty, <strong>grml-chroot</strong> is used.
625 </p>
626 <p>
627 As usual, with promptinit themes, the user may switch to a different theme using
628 the <em>prompt</em> utility:
629 \
630 </p>
631
632 <pre>
633     prompt grml-large
634 </pre>
635
636 <p>
637 That will use the <strong>grml-large</strong> prompt theme.
638 </p>
639 <p>
640 The themes are highly customisable. The main source of documentation about
641 customisation is the main <strong>grml</strong> theme's doc-string, that is available via
642 the following command:
643 \
644 </p>
645
646 <pre>
647     prompt -h grml
648 </pre>
649
650 <p>
651 The other themes also come with doc-strings, but the main theme's is the
652 canonical reference about all of them.
653 </p>
654 <p>
655 This feature requires version <em>4.3.7</em> of the shell. Older versions will use
656 the classic grml prompt as a fallback.
657 </p>
658 <p>
659 A note to people who like customisation: If you are <strong>not</strong> using a prompt
660 theme for your customisation, but you're either statically setting $PS1 (or
661 $PROMPT) or you're constructing one of those variables in zsh's \`precmd()'
662 function, make sure you are turning the zsh's prompt theme system <strong>off</strong>
663 before doing so. A correct example customisation could look like this:
664 \
665 </p>
666
667 <pre>
668     # Turn the prompt system off:
669     prompt off
670     # Customise the prompt yourself:
671     PS1='%~ %# '
672 </pre>
673
674 <p>
675 You also add your own tokens by using the \`grml_theme_add_token()' function.
676 Call the function without arguments for detailed documentation about that
677 procedure.
678 </p>
679
680 </section>
681 <section>
682 <h2>GNU/SCREEN STATUS SETTING</h2>
683
684 <p>
685 <em>grmlzshrc</em> sets screen's hardstatus lines to the currently running command
686 or <strong>'zsh'</strong> if the shell is idling at its prompt. If the current working
687 directory is inside a repository unter version control, screen status is set
688 to: <strong>'zsh: &lt;repository name&gt;'</strong> via zsh's vcs_info.
689 </p>
690
691 </section>
692 <section>
693 <h2>PERSISTENT HISTORY</h2>
694
695 <p>
696 If you got commands you consider important enough to be included in every
697 shell's history, you can put them into $GRML_IMPORTANT_COMMANDS (which defaults
698 for backward compatibility to ~/.important_commands) and they will be available
699 via the usual history lookup widgets.
700 </p>
701
702 </section>
703 </section>
704 <section>
705 <h1>REFERENCE</h1>
706
707 <section>
708 <h2>ENVIRONMENT VARIABLES</h2>
709
710 <p>
711 <em>grmlzshrc</em> sets some environment variables, which influence the
712 behaviour of applications.
713 </p>
714
715 <dl>
716 <dt><strong>COLORTERM</strong></dt><dd>
717 Set to "yes". Some applications read this to learn about properties
718 of the terminal they are running in.
719 <p></p>
720 </dd>
721 <dt><strong>EDITOR</strong></dt><dd>
722 If not already set, sets the default editor. Falls back to vi(1),
723 if vim(1) is not available.
724 <p></p>
725 </dd>
726 <dt><strong>LESS_TERMCAP_*</strong></dt><dd>
727 Some environment variables that add colour support to less(1) for viewing
728 man pages. See termcap(5) for details.
729 <p></p>
730 </dd>
731 <dt><strong>MAIL</strong></dt><dd>
732 The mailbox file for the current user is set to /var/mail/$USER, if not
733 already set otherwise.
734 <p></p>
735 </dd>
736 <dt><strong>PAGER</strong></dt><dd>
737 Set less(1) as default pager, if not already set to something different.
738 </dd>
739 </dl>
740
741 </section>
742 <section>
743 <h2>OPTIONS</h2>
744
745 <p>
746 Apart from zsh's default options, <em>grmlzshrc</em> sets some options
747 that change the behaviour of zsh. Options that change Z-shell's default
748 settings are marked by &lt;grml&gt;. But note, that zsh's defaults vary depending
749 on its emulation mode (csh, ksh, sh, or zsh). For details, see zshoptions(1).
750 </p>
751
752 <dl>
753 <dt><strong>append_history</strong></dt><dd>
754 Zsh sessions, that use <em>grmlzshrc</em>, will append their history list to the
755 history file, rather than replace it. Thus, multiple parallel zsh sessions
756 will all have the new entries from their history lists added to the history
757 file, in the order that they exit. The file will still be periodically
758 re-written to trim it when the number of lines grows 20% beyond the value
759 specified by $SAVEHIST.
760 <p></p>
761 </dd>
762 <dt><strong>auto_cd</strong> &lt;grml&gt;</dt><dd>
763 If a command is issued that can't be executed as a normal command, and the
764 command is the name of a directory, perform the cd command to that directory.
765 <p></p>
766 </dd>
767 <dt><strong>auto_pushd</strong> &lt;grml&gt;</dt><dd>
768 Make cd push the old directory onto the directory stack.
769 <p></p>
770 </dd>
771 <dt><strong>completeinword</strong> &lt;grml&gt;</dt><dd>
772 If the cursor is inside a word, completion is done from both ends;
773 instead of moving the cursor to the end of the word first and starting
774 from there.
775 <p></p>
776 </dd>
777 <dt><strong>extended_glob</strong> &lt;grml&gt;</dt><dd>
778 Treat the '#', '~' and '^' characters as active globbing pattern characters.
779 <p></p>
780 </dd>
781 <dt><strong>extended_history</strong> &lt;grml&gt;</dt><dd>
782 Save each command's beginning timestamp (in seconds since the epoch) and the
783 duration (in seconds) to the history file.
784 <p></p>
785 </dd>
786 <dt><strong>hash_list_all</strong></dt><dd>
787 Whenever a command completion is attempted, make sure the entire command
788 path is hashed first. This makes the first completion slower.
789 <p></p>
790 </dd>
791 <dt><strong>histignorealldups</strong> &lt;grml&gt;</dt><dd>
792 If a new command line being added to the history list duplicates an
793 older one, the older command is removed from the list, even if it is
794 not the previous event.
795 <p></p>
796 </dd>
797 <dt><strong>histignorespace</strong> &lt;grml&gt;</dt><dd>
798 Remove command lines from the history list when the first character on
799 the line is a space, or when one of the expanded aliases contains a
800 leading space. Note that the command lingers in the internal history
801 until the next command is entered before it vanishes.
802 <p></p>
803 </dd>
804 <dt><strong>longlistjobs</strong> &lt;grml&gt;</dt><dd>
805 List jobs in long format by default.
806 <p></p>
807 </dd>
808 <dt><strong>nobeep</strong> &lt;grml&gt;</dt><dd>
809 Avoid to beep on errors in zsh command line editing (zle).
810 <p></p>
811 </dd>
812 <dt><strong>noglobdots</strong></dt><dd>
813 A wildcard character never matches a leading '.'.
814 <p></p>
815 </dd>
816 <dt><strong>nohup</strong> &lt;grml&gt;</dt><dd>
817 Do not send the hangup signal (HUP:1) to running jobs when the shell exits.
818 <p></p>
819 </dd>
820 <dt><strong>nonomatch</strong> &lt;grml&gt;</dt><dd>
821 If a pattern for filename generation has no matches, do not print an error
822 and leave it unchanged in the argument list. This also applies to file
823 expansion of an initial `~' or `='.
824 <p></p>
825 </dd>
826 <dt><strong>notify</strong></dt><dd>
827 Report the status of background jobs immediately, rather than waiting until
828 just before printing a prompt.
829 <p></p>
830 </dd>
831 <dt><strong>pushd_ignore_dups</strong> &lt;grml&gt;</dt><dd>
832 Don't push multiple copies of the same directory onto the directory stack.
833 <p></p>
834 </dd>
835 <dt><strong>share_history</strong> &lt;grml&gt;</dt><dd>
836 As each line is added to the history file, it is checked to see if anything
837 else was written out by another shell, and if so it is included in the
838 history of the current shell too. Using !-style history, the commands from
839 the other sessions will not appear in the history list unless you explicitly
840 type the "history" command. This option is activated for zsh versions &gt;= 4,
841 only.
842 </dd>
843 </dl>
844
845 </section>
846 <section>
847 <h2>KEYBINDINGS</h2>
848
849 <p>
850 Apart from zsh's default key bindings, <em>grmlzshrc</em> comes with its own set of
851 key bindings. Note that bindings like <strong>ESC-e</strong> can also be typed as <strong>ALT-e</strong>
852 on PC keyboards.
853 </p>
854
855 <dl>
856 <dt><strong>ESC-e</strong></dt><dd>
857 Edit the current command buffer in your favourite editor.
858 <p></p>
859 </dd>
860 <dt><strong>ESC-v</strong></dt><dd>
861 Deletes a word left of the cursor; seeing '/' as additional word separator.
862 <p></p>
863 </dd>
864 <dt><strong>CTRL-x-1</strong></dt><dd>
865 Jump right after the first word.
866 <p></p>
867 </dd>
868 <dt><strong>CTRL-x-M()</strong></dt><dd>
869 Create directory under cursor or the selected area.
870 To select an area press ctrl-@ and use the cursor.
871 Use case: you type "mv abc ~/testa/testb/testc/" and remember that the
872 directory does not exist yet -&gt; press <strong>CTRL-xM</strong> and problem solved.
873 <p></p>
874 </dd>
875 <dt><strong>CTRL-x-p</strong></dt><dd>
876 Searches the last occurrence of string before the cursor in the command history.
877 <p></p>
878 </dd>
879 <dt><strong>CTRL-x-z</strong></dt><dd>
880 Display help on keybindings and zsh line editor. Press consecutively to page through content.
881 <p></p>
882 </dd>
883 <dt><strong>CTRL-z</strong></dt><dd>
884 Brings a job, which got suspended with CTRL-z back to foreground.
885 </dd>
886 </dl>
887
888 <section>
889 <h3>Customisation</h3>
890
891 <p>
892 To customise keybindings, you can just use zsh's bindkey utility. However, if
893 you plan to use the `<em>zle-line-init</em>' or `<em>zle-line-finish</em>' hooks
894 yourself, make sure you call the following functions in the respective hook:
895 </p>
896
897 <ul>
898 <li><strong>zle-line-init</strong>: <em>zle-smkx</em>
899 </li>
900 <li><strong>zle-line-finish</strong>: <em>zle-rmkx</em>
901 </li>
902 </ul>
903
904 <p>
905 This is <strong>required</strong> so the keybindings set up by <em>grmlzshrc</em> work. The
906 reason for this is to turn the terminal into the right mode while zsh's line
907 editor (zle) is running. This enables us to query <em>terminfo</em> about escape
908 sequences for special keys and thus simplify and generalise our keybinding
909 section.
910 </p>
911
912 </section>
913 </section>
914 <section>
915 <h2>SHELL FUNCTIONS</h2>
916
917 <p>
918 <em>grmlzshrc</em> comes with a wide array of defined shell functions to ease the
919 user's life.
920 </p>
921
922 <dl>
923 <dt><strong>855resolution()</strong></dt><dd>
924 If 915resolution is available, issues a warning to the user to run it instead
925 to modify the resolution on intel graphics chipsets.
926 <p></p>
927 </dd>
928 <dt><strong>accessed()</strong></dt><dd>
929 Lists files in current directory, which have been accessed within the
930 last N days. N is an integer to be passed as first and only argument.
931 If no argument is specified N is set to 1.
932 <p></p>
933 </dd>
934 <dt><strong>any()</strong></dt><dd>
935 Lists processes matching given pattern.
936 <p></p>
937 </dd>
938 <dt><strong>asc()</strong></dt><dd>
939 Login on the host provided as argument using autossh. Then reattach a GNU screen
940 session if a detached session is around or detach a currently attached screen or
941 else start a new screen.  This is especially useful for roadwarriors using GNU
942 screen and ssh.
943 <p></p>
944 </dd>
945 <dt><strong>bk()</strong></dt><dd>
946 Simple backup management of a file or directory using standard unix programs.
947 The target file name is the original name plus a time stamp attached. Symlinks
948 and file attributes like mode, ownership and timestamps are preserved.
949 <p></p>
950 </dd>
951 <dt><strong>cdrecord()</strong></dt><dd>
952 If the original cdrecord is not installed, issues a warning to the user to
953 use the wodim binary instead. Wodim is the debian fork of Joerg Schillings
954 cdrecord.
955 <p></p>
956 </dd>
957 <dt><strong>cdt()</strong></dt><dd>
958 Creates a temporary directory using mktemp. Then changes current
959 working directory to it.
960 <p></p>
961 </dd>
962 <dt><strong>changed()</strong></dt><dd>
963 Lists files in current directory, which have been changed within the
964 last N days. N is an integer to be passed as first and only argument.
965 If no argument is specified N is set to 1.
966 <p></p>
967 </dd>
968 <dt><strong>check_com()</strong></dt><dd>
969 Returns true if given command exists either as program, function, alias,
970 builtin or reserved word. If the option -c is given, only returns true,
971 if command is a program.
972 <p></p>
973 </dd>
974 <dt><strong>checkhome()</strong></dt><dd>
975 Changes directory to $HOME on first invocation of zsh. This is necessary on
976 Grml systems with autologin.
977 <p></p>
978 </dd>
979 <dt><strong>cl()</strong></dt><dd>
980 Changes current directory to the one supplied by argument and lists the files
981 in it, including file names starting with ".".
982 <p></p>
983 </dd>
984 <dt><strong>dchange()</strong></dt><dd>
985 Shows the changelog of given package in $PAGER.
986 <p></p>
987 </dd>
988 <dt><strong>dcopyright()</strong></dt><dd>
989 Shows the copyright of given package in $PAGER.
990 <p></p>
991 </dd>
992 <dt><strong>debian2hd()</strong></dt><dd>
993 Tells the user to use grml-debootstrap, if she wants to install debian to
994 harddisk.
995 <p></p>
996 </dd>
997 <dt><strong>deswap()</strong></dt><dd>
998 A trick from $LINUX-KERNELSOURCE/Documentation/power/swsusp.txt. It brings
999 back interactive responsiveness after suspend, when the system is swapping
1000 heavily.
1001 <p></p>
1002 </dd>
1003 <dt><strong>dnews()</strong></dt><dd>
1004 Shows the NEWS file for the given package in $PAGER.
1005 <p></p>
1006 </dd>
1007 <dt><strong>edalias()</strong></dt><dd>
1008 Edit given alias.
1009 <p></p>
1010 </dd>
1011 <dt><strong>edfunc()</strong></dt><dd>
1012 Edit given shell function.
1013 <p></p>
1014 </dd>
1015 <dt><strong>freload()</strong></dt><dd>
1016 Reloads an autoloadable shell function (See autoload in zshbuiltins(1)).
1017 <p></p>
1018 </dd>
1019 <dt><strong>grml_vcs_info_toggle_colour()</strong></dt><dd>
1020 Toggles between coloured and uncoloured formats in vcs_info configuration.
1021 This is useful with prompts that break if colour codes are in vcs_info
1022 format expansions (like the `clint' prompt and every other prompt that
1023 uses %v to expand the contents of `$vcs_into_msg_0_'). If you are using
1024 customised vcs_info formats, you shouldn't be using this function, since
1025 it will set all formats to grml's default values (either coloured or plain)
1026 again.
1027 <p></p>
1028 </dd>
1029 <dt><strong>hgdi()</strong></dt><dd>
1030 Use GNU diff with options -ubwd for mercurial.
1031 <p></p>
1032 </dd>
1033 <dt><strong>hgstat()</strong></dt><dd>
1034 Displays diffstat between the revision given as argument and tip (no
1035 argument means last revision).
1036 <p></p>
1037 </dd>
1038 <dt><strong>hidiff()</strong></dt><dd>
1039 Outputs highlighted diff; needs highstring(1).
1040 <p></p>
1041 </dd>
1042 <dt><strong>is4()</strong></dt><dd>
1043 Returns true, if zsh version is equal or greater than 4, else false.
1044 <p></p>
1045 </dd>
1046 <dt><strong>is41()</strong></dt><dd>
1047 Returns true, if zsh version is equal or greater than 4.1, else false.
1048 <p></p>
1049 </dd>
1050 <dt><strong>is42()</strong></dt><dd>
1051 Returns true, if zsh version is equal or greater than 4.2, else false.
1052 <p></p>
1053 </dd>
1054 <dt><strong>is425()</strong></dt><dd>
1055 Returns true, if zsh version is equal or greater than 4.2.5, else false.
1056 <p></p>
1057 </dd>
1058 <dt><strong>is43()</strong></dt><dd>
1059 Returns true, if zsh version is equal or greater than 4.3, else false.
1060 <p></p>
1061 </dd>
1062 <dt><strong>is433()</strong></dt><dd>
1063 Returns true, if zsh version is equal or greater than 4.3.3, else false.
1064 <p></p>
1065 </dd>
1066 <dt><strong>isdarwin()</strong></dt><dd>
1067 Returns true, if running on darwin, else false.
1068 <p></p>
1069 </dd>
1070 <dt><strong>isfreebsd()</strong></dt><dd>
1071 Returns true, if running on FreeBSD, else false.
1072 <p></p>
1073 </dd>
1074 <dt><strong>isgrml()</strong></dt><dd>
1075 Returns true, if running on a grml system, else false.
1076 <p></p>
1077 </dd>
1078 <dt><strong>isgrmlcd()</strong></dt><dd>
1079 Returns true, if running on a grml system from a live cd, else false.
1080 <p></p>
1081 </dd>
1082 <dt><strong>isgrmlsmall()</strong></dt><dd>
1083 Returns true, if run on grml-small, else false.
1084 <p></p>
1085 </dd>
1086 <dt><strong>islinux()</strong></dt><dd>
1087 Returns true, if running on Linux, else false.
1088 <p></p>
1089 </dd>
1090 <dt><strong>iso2utf()</strong></dt><dd>
1091 Changes every occurrence of the string iso885915 or ISO885915 in
1092 environment variables to UTF-8.
1093 <p></p>
1094 </dd>
1095 <dt><strong>isopenbsd()</strong></dt><dd>
1096 Returns true, if running on OpenBSD, else false.
1097 <p></p>
1098 </dd>
1099 <dt><strong>isutfenv()</strong></dt><dd>
1100 Returns true, if run within an utf environment, else false.
1101 <p></p>
1102 </dd>
1103 <dt><strong>mkcd()</strong></dt><dd>
1104 Creates directory including parent directories, if necessary. Then changes
1105 current working directory to it.
1106 <p></p>
1107 </dd>
1108 <dt><strong>modified()</strong></dt><dd>
1109 Lists files in current directory, which have been modified within the
1110 last N days. N is an integer to be passed as first and only argument.
1111 If no argument is specified N is set to 1.
1112 <p></p>
1113 </dd>
1114 <dt><strong>nt()</strong></dt><dd>
1115 A helper function for the "e" glob qualifier to list all files newer
1116 than a reference file.
1117 \
1118 Example usages:
1119
1120 <pre>
1121 % NTREF=/reference/file
1122 % ls -l *(e:nt:)
1123 % # Inline:
1124 % ls -l *(e:'nt /reference/file':)
1125 </pre>
1126
1127 <p></p>
1128 </dd>
1129 <dt><strong>profile()</strong></dt><dd>
1130 Runs a command in zsh with profiling enabled (See startup variable
1131 ZSH_PROFILE_RC above).
1132 <p></p>
1133 </dd>
1134 <dt><strong>salias()</strong></dt><dd>
1135 Creates an alias with sudo prepended, if $EUID is not zero. Run "salias -h"
1136 for details. See also xunfunction() below.
1137 <p></p>
1138 </dd>
1139 <dt><strong>simple-extract()</strong></dt><dd>
1140 Tries to uncompress/unpack given files with the appropriate programs. If an URI
1141 starting with https, http or ftp is provided simple-extract tries to download
1142 and then uncompress/unpack the file. The choice is made along the filename
1143 ending. simple-extract will not delete the original archive (even on .gz,.bz2 or
1144 .xz) unless you use the '-d' option.
1145 <p></p>
1146 </dd>
1147 <dt><strong>sll()</strong></dt><dd>
1148 Prints details of symlinks given as arguments.
1149 <p></p>
1150 </dd>
1151 <dt><strong>ssl-cert-fingerprints</strong></dt><dd>
1152 Prints the SHA512, SHA256, SHA1 and MD5 digest of a x509 certificate.
1153 First and only parameter must be a file containing a certificate. Use
1154 /dev/stdin as file if you want to pipe a certificate to these
1155 functions.
1156 <p></p>
1157 </dd>
1158 <dt><strong>ssl-cert-info</strong></dt><dd>
1159 Prints all information of a x509 certificate including the SHA512,
1160 SHA256, SHA1 and MD5 digests. First and only parameter must be a file
1161 containing a certificate. Use /dev/stdin as file if you want to pipe a
1162 certificate to this function.
1163 <p></p>
1164 </dd>
1165 <dt><strong>ssl-cert-sha512(), ssl-cert-sha256(), ssl-cert-sha1(), ssl-cert-md5()</strong></dt><dd>
1166 Prints the SHA512, SHA256, SHA1 respective MD5 digest of a x509
1167 certificate. First and only parameter must be a file containing a
1168 certificate. Use /dev/stdin as file if you want to pipe a certificate
1169 to this function.
1170 <p></p>
1171 </dd>
1172 <dt><strong>Start(), Restart(), Stop(), Force-Reload(), Reload()</strong></dt><dd>
1173 Functions for controlling daemons.
1174
1175 <pre>
1176 Example usage:
1177 % Restart ssh
1178 </pre>
1179
1180 <p></p>
1181 </dd>
1182 <dt><strong>trans()</strong></dt><dd>
1183 Translates a word from german to english (-D) or vice versa (-E).
1184 <p></p>
1185 </dd>
1186 <dt><strong>uchange()</strong></dt><dd>
1187 Shows upstreams changelog of a given package in $PAGER.
1188 <p></p>
1189 </dd>
1190 <dt><strong>uprint()</strong></dt><dd>
1191 Works around the "print -l ${(u)foo}"-limitation on zsh older than 4.2.
1192 <p></p>
1193 </dd>
1194 <dt><strong>utf2iso()</strong></dt><dd>
1195 Changes every occurrence of the string UTF-8 or utf-8 in environment
1196 variables to iso885915.
1197 <p></p>
1198 </dd>
1199 <dt><strong>vim()</strong></dt><dd>
1200 Wrapper for vim(1). It tries to set the title and hands vim the environment
1201 variable VIM_OPTIONS on the command line. So the user may define command
1202 line options, she always wants, in her .zshrc.local.
1203 <p></p>
1204 </dd>
1205 <dt><strong>whatwhen()</strong></dt><dd>
1206 Searches the history for a given pattern and lists the results by date.
1207 The first argument is the search pattern. The second and third ones are
1208 optional and denote a search range (default: -100).
1209 <p></p>
1210 </dd>
1211 <dt><strong>xcat()</strong></dt><dd>
1212 Tries to cat(1) file(s) given as parameter(s). Always returns true.
1213 See also xunfunction() below.
1214 <p></p>
1215 </dd>
1216 <dt><strong>xsource()</strong></dt><dd>
1217 Tries to source the file(s) given as parameter(s). Always returns true.
1218 See zshbuiltins(1) for a detailed description of the source command.
1219 See also xunfunction() below.
1220 <p></p>
1221 </dd>
1222 <dt><strong>xtrename()</strong></dt><dd>
1223 Changes the title of xterm window from within screen(1). Run without
1224 arguments for details.
1225 <p></p>
1226 </dd>
1227 <dt><strong>xunfunction()</strong></dt><dd>
1228 Removes the functions salias, xcat, xsource, xunfunction and zrcautoload.
1229 <p></p>
1230 </dd>
1231 <dt><strong>zrcautoload()</strong></dt><dd>
1232 Wrapper around the autoload builtin. Loads the definitions of functions
1233 from the file given as argument. Searches $fpath for the file. See also
1234 xunfunction() above.
1235 <p></p>
1236 </dd>
1237 <dt><strong>zrclocal()</strong></dt><dd>
1238 Sources /etc/zsh/zshrc.local and ${HOME}/.zshrc.local. These are the files
1239 where own modifications should go. See also zshbuiltins(1) for a description
1240 of the source command.
1241 </dd>
1242 </dl>
1243
1244 </section>
1245 <section>
1246 <h2>ALIASES</h2>
1247
1248 <p>
1249 <em>grmlzshrc</em> comes with a wide array of predefined aliases to ease the user's
1250 life. A few aliases (like those involving <em>grep</em> or <em>ls</em>) use the option
1251 <em>--color=auto</em> for colourizing output. That option is part of <strong>GNU</strong>
1252 implementations of these tools, and will only be used if such an implementation
1253 is detected.
1254 </p>
1255
1256 <dl>
1257 <dt><strong>acp</strong> (<em>apt-cache policy</em>)</dt><dd>
1258 With no arguments prints out the priorities of each source. If a package name
1259 is given, it displays detailed information about the priority selection of the
1260 package.
1261 <p></p>
1262 </dd>
1263 <dt><strong>acs</strong> (<em>apt search</em>)</dt><dd>
1264 Searches debian package lists for the regular expression provided as argument.
1265 The search includes package names and descriptions. Prints out name and short
1266 description of matching packages.
1267 <p></p>
1268 </dd>
1269 <dt><strong>acsh</strong> (<em>apt show</em>)</dt><dd>
1270 Shows the package records for the packages provided as arguments.
1271 <p></p>
1272 </dd>
1273 <dt><strong>adg</strong> (<em>apt dist-upgrade</em>)</dt><dd>
1274 Performs an upgrade of all installed packages. Also tries to automatically
1275 handle changing dependencies with new versions of packages. As this may change
1276 the install status of (or even remove) installed packages, it is potentially
1277 dangerous to use dist-upgrade; invoked by sudo, if necessary.
1278 <p></p>
1279 </dd>
1280 <dt><strong>ag</strong> (<em>apt upgrade</em>)</dt><dd>
1281 Downloads and installs the newest versions of all packages currently installed
1282 on the system. Under no circumstances are currently installed packages removed,
1283 or packages not already installed retrieved and installed. New versions of
1284 currently installed packages that cannot be upgraded without changing the install
1285 status of another package will be left at their current version. An update must
1286 be performed first (see au below); run by sudo, if necessary.
1287 <p></p>
1288 </dd>
1289 <dt><strong>agi</strong> (<em>apt install</em>)</dt><dd>
1290 Downloads and installs or upgrades the packages given on the command line.
1291 If a hyphen is appended to the package name, the identified package will be
1292 removed if it is installed. Similarly a plus sign can be used to designate a
1293 package to install. This may be useful to override decisions made by apt's
1294 conflict resolution system.
1295 A specific version of a package can be selected for installation by following
1296 the package name with an equals and the version of the package to select. This
1297 will cause that version to be located and selected for install. Alternatively a
1298 specific distribution can be selected by following the package name with a slash
1299 and the version of the distribution or the Archive name (stable, testing, unstable).
1300 Gets invoked by sudo, if user id is not 0.
1301 <p></p>
1302 </dd>
1303 <dt><strong>ati</strong> (<em>aptitude install</em>)</dt><dd>
1304 Aptitude is a terminal-based package manager with a command line mode similar to
1305 apt (see agi above); invoked by sudo, if necessary.
1306 <p></p>
1307 </dd>
1308 <dt><strong>au</strong> (<em>apt update</em>)</dt><dd>
1309 Resynchronizes the package index files from their sources. The indexes of
1310 available packages are fetched from the location(s) specified in
1311 /etc/apt/sources.list. An update should always be performed before an
1312 upgrade or dist-upgrade; run by sudo, if necessary.
1313 <p></p>
1314 </dd>
1315 <dt><strong>da</strong> (<em>du -sch</em>)</dt><dd>
1316 Prints the summarized disk usage of the arguments as well as a grand total
1317 in human readable format.
1318 <p></p>
1319 </dd>
1320 <dt><strong>dbp</strong> (<em>dpkg-buildpackage</em>)</dt><dd>
1321 Builds binary or source packages from sources (See: dpkg-buildpackage(1)).
1322 <p></p>
1323 </dd>
1324 <dt><strong>debs-by-size</strong> (<em>grep-status -FStatus -sInstalled-Size,Package -n "install ok installed" | paste -sd "  \n" | sort -rn</em>)</dt><dd>
1325 Prints installed Packages sorted by size (descending).
1326 <p></p>
1327 </dd>
1328 <dt><strong>dir</strong> (<em>ls -lSrah</em>)</dt><dd>
1329 Lists files (including dot files) sorted by size (biggest last) in long and
1330 human readable output format.
1331 <p></p>
1332 </dd>
1333 <dt><strong>ge</strong> (<em>grep-excuses</em>)</dt><dd>
1334 Searches the testing excuses files for a specific maintainer (See:
1335 grep-excuses(1)).
1336 <p></p>
1337 </dd>
1338 <dt><strong>grep</strong> (<em>grep --color=auto</em>)</dt><dd>
1339 Shows grep output in nice colors, if available.
1340 <p></p>
1341 </dd>
1342 <dt><strong>grml-version</strong> (<em>cat /etc/grml_version</em>)</dt><dd>
1343 Prints version of running grml.
1344 <p></p>
1345 </dd>
1346 <dt><strong>hbp</strong> (<em>hg-buildpackage</em>)</dt><dd>
1347 Helper program to maintain Debian packages with mercurial.
1348 <p></p>
1349 </dd>
1350 <dt><strong>http</strong> (<em>python -m SimpleHTTPServer</em>)</dt><dd>
1351 Basic HTTP server implemented in python. Listens on port 8000/tcp and
1352 serves current directory. Implements GET and HEAD methods.
1353 <p></p>
1354 </dd>
1355 <dt><strong>insecscp</strong> (<em>scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"</em>)</dt><dd>
1356 scp with possible man-in-the-middle attack enabled. This is convenient, if the targets
1357 host key changes frequently, for example on virtualized test- or development-systems.
1358 To be used only inside trusted networks, of course.
1359 <p></p>
1360 </dd>
1361 <dt><strong>insecssh</strong> (<em>ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"</em>)</dt><dd>
1362 ssh with possible man-in-the-middle attack enabled
1363 (for an explanation see insecscp above).
1364 <p></p>
1365 </dd>
1366 <dt><strong>help-zshglob</strong> (<em>H-Glob()</em>)</dt><dd>
1367 Runs the function H-Glob() to expand or explain wildcards.
1368 <p></p>
1369 </dd>
1370 <dt><strong>j</strong> (<em>jobs -l</em>)</dt><dd>
1371 Prints status of jobs in the current shell session in long format.
1372 <p></p>
1373 </dd>
1374 <dt><strong>l</strong> (<em>ls -l --color=auto</em>)</dt><dd>
1375 Lists files in long output format with indicator for filetype appended
1376 to filename. If the terminal supports it, with colored output.
1377 <p></p>
1378 </dd>
1379 <dt><strong>la</strong> (<em>ls -la --color=auto</em>)</dt><dd>
1380 Lists files in long colored output format. Including file names
1381 starting with ".".
1382 <p></p>
1383 </dd>
1384 <dt><strong>lad</strong> (<em>ls -d .*(/)</em>)</dt><dd>
1385 Lists the dot directories (not their contents) in current directory.
1386 <p></p>
1387 </dd>
1388 <dt><strong>lh</strong> (<em>ls -hAl --color=auto</em>)</dt><dd>
1389 Lists files in long and human readable output format in nice colors,
1390 if available. Includes file names starting with "." except "." and
1391 "..".
1392 <p></p>
1393 </dd>
1394 <dt><strong>ll</strong> (<em>ls -l --color=auto</em>)</dt><dd>
1395 Lists files in long colored output format.
1396 <p></p>
1397 </dd>
1398 <dt><strong>llog</strong> (<em>$PAGER /var/log/syslog</em>)</dt><dd>
1399 Opens syslog in pager.
1400 <p></p>
1401 </dd>
1402 <dt><strong>ls</strong> (<em>ls -C --color=auto</em>)</dt><dd>
1403 Lists directory, entries are listed by columns and an indicator for
1404 file type is appended to each file name. Additionally the output is
1405 colored, if the terminal supports it.
1406 <p></p>
1407 </dd>
1408 <dt><strong>lsa</strong> (<em>ls -a .*(.)</em>)</dt><dd>
1409 Lists dot files in current working directory.
1410 <p></p>
1411 </dd>
1412 <dt><strong>lsbig</strong> (<em>ls -flh *(.OL[1,10])</em>)</dt><dd>
1413 Displays the ten biggest files (long and human readable output format).
1414 <p></p>
1415 </dd>
1416 <dt><strong>lsd</strong> (<em>ls -d *(/)</em>)</dt><dd>
1417 Shows directories.
1418 <p></p>
1419 </dd>
1420 <dt><strong>lse</strong> (<em>ls -d *(/^F)</em>)</dt><dd>
1421 Shows empty directories.
1422 <p></p>
1423 </dd>
1424 <dt><strong>lsl</strong> (<em>ls -l *(@)</em>)</dt><dd>
1425 Lists symbolic links in current directory.
1426 <p></p>
1427 </dd>
1428 <dt><strong>lsnew</strong> (<em>ls -rl *(D.om[1,10])</em>)</dt><dd>
1429 Displays the ten newest files (long output format).
1430 <p></p>
1431 </dd>
1432 <dt><strong>lsnewdir</strong> (<em>ls -rthdl *(/om[1,10]) .*(D/om[1,10])</em>)</dt><dd>
1433 Displays the ten newest directories and ten newest .directories.
1434 <p></p>
1435 </dd>
1436 <dt><strong>lsold</strong> (<em>ls -rtlh *(D.om[1,10])</em>)</dt><dd>
1437 Displays the ten oldest files (long output format).
1438 <p></p>
1439 </dd>
1440 <dt><strong>lsolddir</strong> (<em>ls -rthdl *(/Om[1,10]) .*(D/Om[1,10])</em>)</dt><dd>
1441 Displays the ten oldest directories and ten oldest .directories.
1442 <p></p>
1443 </dd>
1444 <dt><strong>lss</strong> (<em>ls -l *(s,S,t)</em>)</dt><dd>
1445 Lists files in current directory that have the setuid, setgid or sticky bit
1446 set.
1447 <p></p>
1448 </dd>
1449 <dt><strong>lssmall</strong> (<em>ls -Srl *(.oL[1,10])</em>)</dt><dd>
1450 Displays the ten smallest files (long output format).
1451 <p></p>
1452 </dd>
1453 <dt><strong>lsw</strong> (<em>ls -ld *(R,W,X.^ND/)</em>)</dt><dd>
1454 Displays all files which are world readable and/or world writable and/or
1455 world executable (long output format).
1456 <p></p>
1457 </dd>
1458 <dt><strong>lsx</strong> (<em>ls -l *(*)</em>)</dt><dd>
1459 Lists only executable files.
1460 <p></p>
1461 </dd>
1462 <dt><strong>mdstat</strong> (<em>cat /proc/mdstat</em>)</dt><dd>
1463 Lists all active md (i.e. linux software raid) devices with some information
1464 about them.
1465 <p></p>
1466 </dd>
1467 <dt><strong>mq</strong> (<em>hg -R $(readlink -f $(hg root)/.hg/patches)</em>)</dt><dd>
1468 Executes the commands on the versioned patch queue from current repository.
1469 <p></p>
1470 </dd>
1471 <dt><strong>rmcdir</strong> (<em>'cd ..; rmdir $OLDPWD || cd $OLDPWD</em>)</dt><dd>
1472 rmdir current working directory
1473 <p></p>
1474 </dd>
1475 <dt><strong>screen</strong> (<em>screen -c file</em>)</dt><dd>
1476 If invoking user is root, starts screen session with /etc/grml/screenrc
1477 as config file. If invoked by a regular user and users .screenc does not exist,
1478 starts screen with /etc/grml/screenrc_grml config if it exists, else fallbacks
1479 to /etc/grml/screenrc.
1480 <p></p>
1481 </dd>
1482 <dt><strong>su</strong> (<em>sudo su</em>)</dt><dd>
1483 If user is running a Grml live system, don't ask for any password, if she
1484 wants a root shell.
1485 <p></p>
1486 </dd>
1487 <dt><strong>term2iso</strong> (<em>echo 'Setting terminal to iso mode' ; print -n '\e%@'</em>)</dt><dd>
1488 Sets mode from UTF-8 to ISO 2022 (See:
1489 <a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html#term">http://www.cl.cam.ac.uk/~mgk25/unicode.html#term</a>).
1490 <p></p>
1491 </dd>
1492 <dt><strong>term2utf</strong> (<em>echo 'Setting terminal to utf-8 mode'; print -n '\e%G'</em>)</dt><dd>
1493 Sets mode from ISO 2022 to UTF-8 (See:
1494 <a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html#term">http://www.cl.cam.ac.uk/~mgk25/unicode.html#term</a>).
1495 <p></p>
1496 </dd>
1497 <dt><strong>tlog</strong> (<em>tail -f /var/log/syslog</em>)</dt><dd>
1498 Prints syslog continuously (See tail(1)).
1499 <p></p>
1500 </dd>
1501 <dt><strong>up</strong> (<em>aptitude update ; aptitude safe-upgrade</em>)</dt><dd>
1502 Performs a system update followed by a system upgrade using aptitude; run
1503 by sudo, if necessary. See au and ag above.
1504 <p></p>
1505 </dd>
1506 <dt><strong>url-quote</strong> (<em>autoload -U url-quote-magic ; zle -N self-insert url-quote-magic</em>)</dt><dd>
1507 After calling, characters of URLs as typed get automatically escaped, if necessary, to
1508 protect them from the shell.
1509 <p></p>
1510 </dd>
1511 <dt><strong>$(uname -r)-reboot</strong> (<em>kexec -l --initrd=/boot/initrd.img-"$(uname -r)" --command-line=\"$(cat /proc/cmdline)\" /boot/vmlinuz-"$(uname -r)"</em>)</dt><dd>
1512 Reboots using kexec(8) and thus reduces boot time by skipping hardware initialization of BIOS/firmware.
1513 <p></p>
1514 </dd>
1515 <dt><strong>...</strong> (<em>cd ../../</em>)</dt><dd>
1516 Changes current directory two levels higher.
1517 </dd>
1518 </dl>
1519
1520 </section>
1521 </section>
1522 <section>
1523 <h1>AUXILIARY FILES</h1>
1524
1525 <p>
1526 This is a set of files, that - if they exist - can be used to customize the
1527 behaviour of <em>grmlzshrc</em>.
1528 </p>
1529
1530 <dl>
1531 <dt><strong>.zshrc.pre</strong></dt><dd>
1532 Sourced at the very beginning of <em>grmlzshrc</em>. Among other things, it can
1533 be used to permantenly change <em>grmlzshrc</em>'s STARTUP VARIABLES (see above):
1534 \
1535
1536 <pre>
1537 # show battery status in RPROMPT
1538 GRML_DISPLAY_BATTERY=1
1539 # always load the complete setup, even for root
1540 GRML_ALWAYS_LOAD_ALL=1
1541 </pre>
1542
1543 <p></p>
1544 </dd>
1545 <dt><strong>.zshrc.local</strong></dt><dd>
1546 Sourced right before loading <em>grmlzshrc</em> is finished. There is a global
1547 version of this file (/etc/zsh/zshrc.local) which is sourced before the
1548 user-specific one.
1549 <p></p>
1550 </dd>
1551 <dt><strong>.zdirs</strong></dt><dd>
1552 Directory listing for persistent dirstack (see above).
1553 <p></p>
1554 </dd>
1555 <dt><strong>.important_commands</strong></dt><dd>
1556 List of commands, used by persistent history (see above).
1557 </dd>
1558 </dl>
1559
1560 </section>
1561 <section>
1562 <h1>INSTALLATION ON NON-DEBIAN SYSTEMS</h1>
1563
1564 <p>
1565 On Debian systems (<a href="http://www.debian.org">http://www.debian.org</a>) - and possibly Ubuntu
1566 (<a href="http://www.ubuntu.com">http://www.ubuntu.com</a>) and similar systems - it is very easy to get
1567 <em>grmlzshrc</em> via grml's .deb repositories.
1568 </p>
1569 <p>
1570 On non-debian systems, that is not an option, but all is not lost:
1571 \
1572 </p>
1573
1574 <pre>
1575 % wget -O .zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
1576 </pre>
1577
1578 <p>
1579 If you would also like to get separate function files (which you can put into
1580 your <strong>$fpath</strong>), you can browse and download them at:
1581 </p>
1582 <p>
1583 <a href="http://git.grml.org/?p=grml-etc-core.git;a=tree;f=usr_share_grml/zsh;hb=HEAD">http://git.grml.org/?p=grml-etc-core.git;a=tree;f=usr_share_grml/zsh;hb=HEAD</a>
1584 </p>
1585
1586 </section>
1587 <section>
1588 <h1>ZSH REFCARD TAGS</h1>
1589
1590 <p>
1591 If you read <em>grmlzshrc</em>'s code you may notice strange looking comments in
1592 it. These are there for a purpose. grml's zsh-refcard is automatically
1593 generated from the contents of the actual configuration file. However, we need
1594 a little extra information on which comments and what lines of code to take
1595 into account (and for what purpose).
1596 </p>
1597 <p>
1598 Here is what they mean:
1599 </p>
1600 <p>
1601 List of tags (comment types) used:
1602 </p>
1603
1604 <dl>
1605 <dt><strong>#a#</strong></dt><dd>
1606 Next line contains an important alias, that should be included in the
1607 grml-zsh-refcard. (placement tag: @@INSERT-aliases@@)
1608 <p></p>
1609 </dd>
1610 <dt><strong>#f#</strong></dt><dd>
1611 Next line contains the beginning of an important function. (placement
1612 tag: @@INSERT-functions@@)
1613 <p></p>
1614 </dd>
1615 <dt><strong>#v#</strong></dt><dd>
1616 Next line contains an important variable. (placement tag:
1617 @@INSERT-variables@@)
1618 <p></p>
1619 </dd>
1620 <dt><strong>#k#</strong></dt><dd>
1621 Next line contains an important keybinding. (placement tag:
1622 @@INSERT-keybindings@@)
1623 <p></p>
1624 </dd>
1625 <dt><strong>#d#</strong></dt><dd>
1626 Hashed directories list generation: <em>start</em>: denotes the start of a list of
1627 'hash -d' definitions. <em>end</em>: denotes its end. (placement tag:
1628 @@INSERT-hasheddirs@@)
1629 <p></p>
1630 </dd>
1631 <dt><strong>#A#</strong></dt><dd>
1632 Abbreviation expansion list generation: <em>start</em>: denotes the beginning of
1633 abbreviations. <em>end</em>: denotes their end.
1634 \
1635 Lines within this section that end in '#d .*' provide extra documentation to
1636 be included in the refcard. (placement tag: @@INSERT-abbrev@@)
1637 <p></p>
1638 </dd>
1639 <dt><strong>#m#</strong></dt><dd>
1640 This tag allows you to manually generate refcard entries for code lines that
1641 are hard/impossible to parse.
1642 Example:
1643 \
1644
1645 <pre>
1646 #m# k ESC-h Call the run-help function
1647 </pre>
1648
1649 \
1650 That would add a refcard entry in the keybindings table for 'ESC-h' with the
1651 given comment.
1652 \
1653 So the syntax is: #m# &lt;section&gt; &lt;argument&gt; &lt;comment&gt;
1654 <p></p>
1655 </dd>
1656 <dt><strong>#o#</strong></dt><dd>
1657 This tag lets you insert entries to the 'other' hash. Generally, this should
1658 not be used. It is there for things that cannot be done easily in another way.
1659 (placement tag: @@INSERT-other-foobar@@)
1660 </dd>
1661 </dl>
1662
1663 <p>
1664 All of these tags (except for m and o) take two arguments, the first
1665 within the tag, the other after the tag:
1666 </p>
1667 <p>
1668 #&lt;tag&gt;&lt;section&gt;# &lt;comment&gt;
1669 </p>
1670 <p>
1671 Where &lt;section&gt; is really just a number, which are defined by the @secmap
1672 array on top of 'genrefcard.pl'. The reason for numbers instead of names is,
1673 that for the reader, the tag should not differ much from a regular comment.
1674 For zsh, it is a regular comment indeed. The numbers have got the following
1675 meanings:
1676 </p>
1677
1678 <dl>
1679 <dt><strong>0</strong></dt><dd>
1680 <em>default</em>
1681 <p></p>
1682 </dd>
1683 <dt><strong>1</strong></dt><dd>
1684 <em>system</em>
1685 <p></p>
1686 </dd>
1687 <dt><strong>2</strong></dt><dd>
1688 <em>user</em>
1689 <p></p>
1690 </dd>
1691 <dt><strong>3</strong></dt><dd>
1692 <em>debian</em>
1693 <p></p>
1694 </dd>
1695 <dt><strong>4</strong></dt><dd>
1696 <em>search</em>
1697 <p></p>
1698 </dd>
1699 <dt><strong>5</strong></dt><dd>
1700 <em>shortcuts</em>
1701 <p></p>
1702 </dd>
1703 <dt><strong>6</strong></dt><dd>
1704 <em>services</em>
1705 </dd>
1706 </dl>
1707
1708 <p>
1709 So, the following will add an entry to the 'functions' table in the 'system'
1710 section, with a (hopefully) descriptive comment:
1711 \
1712 </p>
1713
1714 <pre>
1715 #f1# Edit an alias via zle
1716 edalias() {
1717 </pre>
1718
1719 <p>
1720 \
1721 It will then show up in the @@INSERT-aliases-system@@ replacement tag that can
1722 be found in 'grml-zsh-refcard.tex.in'. If the section number is omitted, the
1723 'default' section is assumed. Furthermore, in 'grml-zsh-refcard.tex.in'
1724 @@INSERT-aliases@@ is exactly the same as @@INSERT-aliases-default@@. If you
1725 want a list of <strong>all</strong> aliases, for example, use @@INSERT-aliases-all@@.
1726 </p>
1727
1728 </section>
1729 <section>
1730 <h1>CONTRIBUTING</h1>
1731
1732 <p>
1733 If you want to help to improve grml's zsh setup, clone the grml-etc-core
1734 repository from git.grml.org:
1735 \
1736 </p>
1737
1738 <pre>
1739 % git clone git://git.grml.org/grml-etc-core.git
1740 </pre>
1741
1742 <p>
1743 Make your changes, commit them; use '<strong>git format-patch</strong>' to create a series
1744 of patches and send those to the following address via '<strong>git send-email</strong>':
1745 \
1746 </p>
1747
1748 <pre>
1749 grml-etc-core@grml.org
1750 </pre>
1751
1752 <p>
1753 Doing so makes sure the right people get your patches for review and
1754 possibly inclusion.
1755 </p>
1756
1757 </section>
1758 <section>
1759 <h1>STATUS</h1>
1760
1761 <p>
1762 This manual page is the <strong>reference</strong> manual for <em>grmlzshrc</em>.
1763 </p>
1764 <p>
1765 That means that in contrast to the existing refcard it should document <strong>every</strong>
1766 aspect of the setup.
1767 </p>
1768 <p>
1769 This manual is currently not complete. If you want to help improving it, visit
1770 the following pages:
1771 </p>
1772 <p>
1773 <a href="http://wiki.grml.org/doku.php?id=zshrcmanual">http://wiki.grml.org/doku.php?id=zshrcmanual</a>
1774 </p>
1775 <p>
1776 <a href="http://lists.mur.at/pipermail/grml/2009-August/004609.html">http://lists.mur.at/pipermail/grml/2009-August/004609.html</a>
1777 </p>
1778 <p>
1779 Contributions are highly welcome.
1780 </p>
1781
1782 </section>
1783 <section>
1784 <h1>AUTHORS</h1>
1785
1786 <p>
1787 This manpage was written by Frank Terbeck &lt;<a href="mailto:ft@grml.org">ft@grml.org</a>&gt;, Joerg Woelke
1788 &lt;<a href="mailto:joewoe@fsmail.de">joewoe@fsmail.de</a>&gt;, Maurice McCarthy &lt;<a href="mailto:manselton@googlemail.com">manselton@googlemail.com</a>&gt; and Axel
1789 Beckert &lt;<a href="mailto:abe@deuxchevaux.org">abe@deuxchevaux.org</a>&gt;.
1790 </p>
1791
1792 </section>
1793 <section>
1794 <h1>COPYRIGHT</h1>
1795
1796 <p>
1797 Copyright (c) 2009-2013 Grml project &lt;<a href="http://grml.org">http://grml.org</a>&gt;
1798 </p>
1799 <p>
1800 This manpage is distributed under the terms of the GPL version 2.
1801 </p>
1802 <p>
1803 Most parts of grml's zshrc are distributed under the terms of GPL v2, too,
1804 except for <strong>accept-line()</strong> which are distributed under the same conditions
1805 as zsh itself (which is BSD-like).
1806 </p>
1807 </section>
1808 </div>
1809
1810 <!-- html code generated by txt2tags 3.4 (http://txt2tags.org) -->
1811 <!-- cmdline: txt2tags -\-target html -\-style t2t-modern.css grmlzshrc.t2t -->
1812 </article></body></html>