Some optional parts of zsh are in modules, separate from the core of the shell. Each of these modules may be linked in to the shell at build time, or can be dynamically linked while the shell is running if the installation supports this feature. The modules available are:
cap
clone
comp1
compctl
and zle
modules.
compctl
compctl
builtin for controlling completion.
deltochar
zap-to-char
.
example
files
sched
stat
stat
system call.
zle
bindkey
and vared
builtins.
The cap
module is used for manipulating POSIX.1e (POSIX.6) capability
sets. If the operating system does not support this interface, the
builtins defined by this module will do nothing.
The builtins in this module are:
cap
[ capabilities ]
getcap
filename ...
setcap
capabilities filename ...
The clone
module makes available one builtin command:
clone
tty
PID
, PPID
and TTY
special
parameters are changed appropriately. $!
is set to zero in the new
shell, and to the new shell's PID in the original shell.
The return value of the builtin is zero in both shells if successful,
and non-zero on error.
The comp1
module does nothing that is visible to the user.
Its purpose is to provide the internal basis of the programmable
completion mechanism.
This module must be loaded before any module that
provides a means of controlling completion (such as the compctl
module), or that uses completions (such as the zle
module).
This is done automatically for modules distributed with zsh, and
for other modules can be effected by the use of zmodload -d
.
The compctl
module makes available one builtin command, compctl
,
which is the standard way to control completions for ZLE. See
section Programmable Completion.
The deltochar
module makes available one ZLE function:
delete-to-char
The example
module makes available one builtin command:
example
[ -flags
] [ args ... ]
The purpose of the module is to serve as an example of how to write a module.
The files
module makes some standard commands available as builtins:
ln
[ -dfis
] filename dest
ln
[ -dfis
] filename ... dir
-s
, symbolic) links. In the first form, the
specified destination is created, as a link to the specified
filename. In the second form, each of the filenames is
taken in turn, and linked to a pathname in the specified directory
that has the same last pathname component.
Normally, ln
will not attempt to create hard links to
directories. This check can be overridden using the -d
option.
Typically only the super-user can actually succeed in creating
hard links to directories.
This does not apply to symbolic links in any case.
By default, existing files cannot be replaced by links.
The -i
option causes the user to be queried about replacing
existing files. The -f
option causes existing files to be
silently deleted, without querying. -f
takes precedence.
mkdir
[ -p
] [ -m
mode ] dir ...
-p
option, non-existing parent
directories are first created if necessary, and there will be
no complaint if the directory already exists.
The -m
option can be used to specify (in octal) a set of file permissions
for the created directories, otherwise mode 777 modified by the current
umask
(see man page umask(2)) is used.
mv
[ -fi
] filename dest
mv
[ -fi
] filename ... dir
-i
option causes the user to be queried about replacing
any existing files. The -f
option causes any existing files to be
silently deleted, without querying. -f
takes precedence.
Note that this mv
will not move files across devices.
Historical versions of mv
, when actual renaming is impossible,
fall back on copying and removing files; if this behaviour is desired,
use cp
and rm
manually. This may change in a future version.
rm
[ -dfirs
] filename ...
rm
will not remove directories (except with the -r
option). The -d
option causes rm
to try removing directories
with unlink
(see man page unlink(2)), the same method used for files.
Typically only the super-user can actually succeed in unlinking
directories in this way.
-d
takes precedence over -r
.
By default, the user will be queried before removing any file
that the user cannot write to, but writable files will be silently
removed.
The -i
option causes the user to be queried about removing
any files. The -f
option causes files to be
silently deleted, without querying, and suppresses all error indications.
-f
takes precedence.
The -r
option causes rm
to recursively descend into directories,
deleting all files in the directory before removing the directory with
the rmdir
system call (see man page rmdir(2)).
The -s
option is a zsh extension to rm
functionality. It enables
paranoid behaviour, intended to avoid common security problems involving
a root-run rm
being tricked into removing files other than the ones
intended. It will refuse to follow symbolic links, so that (for example)
"rm /tmp/foo/passwd
'' can't accidentally remove /etc/passwd
if /tmp/foo
happens to be a link to /etc
. It will also check
where it is after leaving directories, so that a recursive removal of
a deep directory tree can't end up recursively removing /usr
as
a result of directories being moved up the tree.
rmdir
dir ...
sync
The sched
module makes available one builtin command:
sched
[+
]hh:
mm command ...
sched
[ -
item ]
-
item', removes the given item
from the list.
The stat
module makes available one builtin command:
stat
[ -gnNlLtTrs
] [ -f
fd ] [ -A
array ] [ -F
fmt ] [ +
element ] [ file ... ]
stat
system call (see
man page stat(2)).
If the stat
call fails, the appropriate system error message
printed and status 1 is returned.
The fields of struct stat
give information about
the files provided as arguments to the command. In addition to those
available from the stat
call, an extra element `link
' is provided.
These elements are:
device
inode
mode
-s
option, this will
be returned as a string corresponding to the first column in the
display of the ls -l
command.
nlink
uid
-s
option, this is displayed as a user name.
gid
-s
option, this
is displayed as a group name.
rdev
size
atime
mtime
ctime
-s
option,
these are printed as strings for the local time zone; the format
can be altered with the -F
option, and with the -g
option the times are in GMT.
blksize
block
link
-L
option is in
effect, this contains the name of the file linked to, otherwise
it is empty. Note that if this element is selected ("stat +link
'')
then the -L
option is automatically used.
+
' in the option list; only one element is allowed.
The element may be shortened to any unique set of leading
characters. Otherwise, all elements will be shown for all files.
Options:
-A
array
struct stat
element per array
element for each file in order. In this case neither the name
of the element nor the name of the files is provided unless the
-t
or -n
options are provided, respectively. In the
former case the element name appears as a prefix to the
appropriate array element and in the latter case the file name
appears as a separate array element preceding all the others.
Other formatting options are respected.
-f
fd
-F
fmt
strftime
(see man page strftime(3)) string for the
formatting of the time elements. The -s
option is implied.
-g
-s
option is implied.
-l
-A
and arguments are ignored.
-L
lstat
(see man page lstat(2)) rather than a stat
system call. In this case, if the file is a link, information
about the link itself rather than the target file is returned.
This option is required to make the link
element useful.
-n
-N
-r
-s
format); the string data appears in parentheses
after the raw data.
-s
mode
, uid
, gid
and the three time
elements as strings instead of numbers. In each case the format
is like that of ls -l
.
-t
struct stat
. Usually these are only shown when output is to
standard output and no individual element has been selected.
-T
struct stat
elements.
The zle
module contains the Zsh Line Editor. See
section Zsh Line Editor. It also contains three related builtin commands:
bindkey
[ options ] -l
bindkey
[ options ] -d
bindkey
[ options ] -D
keymap ...
bindkey
[ options ] -A
old-keymap new-keymap
bindkey
[ options ] -N
new-keymap [ old-keymap ]
bindkey
[ options ] -m
bindkey
[ options ] -r
in-string ...
bindkey
[ options ] -s
in-string out-string ...
bindkey
[ options ] in-string command ...
bindkey
[ options ] [ in-string ]
bindkey
's options can be divided into three categories: keymap selection,
operation selection, and others. The keymap selection options are:
-e
emacs
', and also links it to `main
'.
-v
viins
', and also links it to `main
'.
-a
vicmd
'.
-M
main
' keymap is used. These operations do not permit a keymap to be
selected:
-l
-L
option is used, list in the form of bindkey
commands to create the keymaps.
-d
-D
keymap ...
-A
old-keymap new-keymap
-N
new-keymap [ old-keymap ]
-m
self-insert
are affected.
-r
in-string ...
undefined-key
.
-s
in-string out-string ...
-e
or -v
options are used alone, the keymap is not
displayed - the implicit linking of keymaps is the only thing that happens.
-R
option is used, the in-strings
are interpreted as ranges, instead of plain strings. A valid range
consists of two characters, with an optional `-
'
between them. All characters between the two specified, inclusive,
are bound as specified.
For either in-string or out-string, the following
escape sequences are recognised:
\a
\b
\e
, \E
\f
\n
\r
\t
\v
\
NNN
\x
NN
\M
[-
]X
\C
[-
]X
^
X
\
' escapes the following character. Delete is
written as `^?
'. Note that `\M^?
' and `^\M?
' are not the same.
vared
[ -ch
] [ -p
prompt ] [ -r
rprompt ] name
-c
flag is given, the parameter is created if it doesn't
already exist.
If the -p
flag is given, the following string will be taken as
the prompt to display at the left. If the -r
flag is given,
the following string gives the prompt to display at the right. If the
-h
flag is specified, the history can be accessed from ZLE.
zle
-l
[ -L
]
zle
-D
widget ...
zle
-A
old-widget new-widget
zle
-N
widget [ function ]
zle
widget
zle
builtin performs a number of different actions concerning
ZLE. Which operation it performs depends on its options:
-l
[ -L
]
-L
option is used, list in the form of zle
commands to create the widgets.
Built-in widgets are not listed.
-D
widget ...
-A
old-widget new-widget
-N
widget [ function ]
Go to the first, previous, next, last section, table of contents.