1 zsh-workshop - 20061128
2 =======================
7 The following documentation is *not* a full documentation of the zsh
8 workshop, it just documents some general stuff which might be useful for
9 workshop participants. Notice: some configuration/keybindings/... are not
10 set up on default zsh but used in link:http://grml.org/[grml]'s
16 ''Zsh is a shell designed for interactive use, although it is also a
17 powerful scripting language. Many of the useful features of bash, ksh, and
18 tcsh were incorporated into zsh; many original features were added. ''
20 -- http://zsh.dotsrc.org/
22 Merges the best from ksh, csh and bash! ('emulate sh + emulate ksh')
24 More than 100 builtins, ~150 options + >300 keybindings
29 wget -O ~/.zshrc http://hg.grml.org/grml-etc-core/raw-file/tip/etc/skel/.zshrc
30 wget -O ~/.zshrc.global http://hg.grml.org/grml-etc-core/raw-file/tip/etc/zsh/zshrc
32 Useful modules and settings
33 ---------------------------
35 % setopt autocd && /tmp # cd /tmp
36 % setopt append_history share_history histignorealldups
38 % autoload -U zmv # zmv "programmable rename"
39 % zmv '* *' '$f:gs/ /_' # Replace spaces in filenames with a underline
41 % autoload run-help # esc-h
42 % autoload compinit && compinit
45 TIP: run 'setopt ksh_option_print && setopt' to get a listing of all
48 Globbing / Glob Qualifier
49 -------------------------
52 % ls -d *.^c # list all files excluding c-source files
53 % ls /etc/*(@) # list symlinks only
54 % ls -l *.(png|jpg|gif) # list pictures only
55 % ls *(*) # list executables only
56 % ls /etc/**/zsh # which directories contain 'zsh'?
57 % ls **/*(-@) # list dangling symlinks
58 % ls **/*(/^F) # list empty directories
60 TIP: run 'H-Glob' on your grml system for getting help regarding globbing
65 Some very interesting ones (besides default 'bindkey'):
69 CTRL-w delete last word
71 TAB complete and take first result
72 ESC-. insert last parameter of last typed command (similar to typing !$)
73 ESC-e edit the current line in $EDITOR
74 ESC-h call run-help for the 1st word on the commandline
75 ESC-m insert last typed word
76 CTRL-E d insert a timestamp on the commandline (yyyy-mm-dd)
79 Alt-' quote-line => ''
80 Alt-<number>-char insert <number> of chars
82 CTRL-x+a complete alias
83 CTRL-x+e complete word
87 CTRL-y yank (insert kill-ring)
89 TIP: run "bindkey 'ctrl-v <keys>'" to find out which action is bount to a key
95 % !23 # Re-execute history command 23
96 % ^foo^bar # edit previous command replace foo by bar
98 Check your history for most frequently used commands and create
99 aliases/functions for them!
101 % print -l -- ${(o)history%% *} | uniq -c | sort -nr | head -n 10
103 "Unsorted Must Knows"
104 ---------------------
106 % rehash # important for bash-users
107 % ls /u/s/d/x/exa<TAB> # try it :)
108 % dpkg -i ~deb/foo.deb # hash for /var/cache/apt/archives
109 % ls ~doc # hash /usr/share/doc
110 % ls =vim # ls $(which vim)
111 % sort <f{oo,ubar} # cat foo fubar | sort
112 % less <(gzip -cd foo.gz) # gzip -cd foo.gz && less foo
113 % ls >file1 >file2 >file3
120 % precmd () { RPROMPT="%(?..:()%" }
121 % xpdf =(zcat /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz)
122 % w3m http://www.bash2zsh.com/zsh_refcard/refcard.pdf
128 TIP: run 'zsh-help' on your grml system to get some hints regarding zsh
130 * link:http://grml.org/zsh/[grml's zsh webpage]
131 * link:http://www.bash2zsh.com/[Book: From Bash to Z Shell: Conquering the Command Line]
136 (c) Michael Prokop <mika@grml.org>; HTML version powered by link:http://www.methods.co.nz/asciidoc/[asciidoc].
138 // vim: ft=asciidoc autoindent textwidth=75 formatoptions=tcqn