Académique Documents
Professionnel Documents
Culture Documents
Command Line
With ZSH
Fabian Kislat
DESY IceTray Seminar
Dec 01, 2009
What is ZSH?
A Unix shell
Very customizable
Today's Topics
History
Globbing
Parameter Expansion
Part I:
Configuring the Shell
.zprofile
Interactive shell?
.zshrc
In an xterm
Keybindings
Defining Keybindings
foo () {
# commands
}
Function:
Script:
Runs in sub-shell
Cannot influence current shell
Full shell startup processed when run
Does not affect startup of your shell
Fabian Kislat - Conquering the Command Line With ZSH
Autoload
Enter: Autoload
autoload foo
Now foo is loaded on demand,
i.e. when run the first time
Runs in current shell
10
Autoload
How to do that?
Write a script (e.g. called foo),
put it into some directory (often ~/.zfunc)
Add directory to the FPATH list:
FPATH=~/.zfunc:$FPATH
11
Options
12
Modules
Useful in scripts:
zmodload zsh/mathfunc
Makes mathematical functions available
I would load them only when needed
Fabian Kislat - Conquering the Command Line With ZSH
13
http://www-zeuthen.desy.de/~kislat/zstartup.tar.gz
14
Part II:
Interactive Features
Shell History
16
More History
setopt hist_ignore_dups
Ignore duplicate lines
setopt hist_ignore_space
Ignore lines starting with whitespace when saving
Many more options
Access history:
17
Modifiers
Example:
$ echo foo/bar.txt
foo/bar.txt
$ echo !$:t
bar.txt
18
Globbing
19
Globbing
20
Globbing
21
Part III:
Scripting
Parameter Expansion
length of var
23
Parameter Expansion II
e.g. ${var:=str}
$var if set else str and set var to it
24
25
Shell Variables
$* all parameters
26
Arrays
27
Miscellaneous
28
Useful References
The book
O. Kiddle, J. Peek, and P. Stephenson, From
Bash to Z Shell Conquering the Command Line,
APress
29