bash
.
The manual is a number of sections:
overview | |
roadmap | Informal introduction to the manual |
misc | Anything not fitting into the other sections |
expn | command and parameter expansion |
param | parameters |
options | options |
builtins | built-in functions |
zle | command line editing |
compwid | completion widgets |
compsys | completion system |
compctl | completion control |
modules | loadable modules |
tcpsys | built-in TCP functions |
zftpsys | built-in FTP client |
contrib | Additional functions and utilities |
all | Meta-man page containing all of the above |
Command interpreter (shell) zsh is usable as an interactive login shell and as a shell script command processor. Of the common shells, zsh resembles ksh with many enhancements. It does not provide compatibility with POSIX or other shells by default.
Includes command line editing, spelling correction, programmable command completion, shell functions (with autoloading), a history mechanism.
To set the default shel use chsh -s /bin/bash
-i |
Without -c
or -s
remaining arguments, after option processing, the first argument is a script
PATH_SCRIPT
, and the name does not contain a directory path (i.e. there is no `/' in the name),
first the current directory then the command path given by $PATH
are searched. PATH_SCRIPT
or the file name contains a `/' it is used directly.
After the first one or two arguments , the remaining arguments are assigned to the positional parameters.
see zshoptions.
setopt
, unsetopt
, set -o
or set +o
),
To use options by name use -o name […]
zsh -o shwordsplit scr
runs the script scr
with SH_WORD_SPLIT
.
Options are turned off using +o
.
o
can suffix single-letter options. Examples: `-xo shwordsplit' or `-xoshwordsplit' is equivalent to `-x -o shwordsplit'.
Options may be specified by name in long style --option-name
. When this is done, `-'s
in the option name are translated into `_' and ignored.
for example,
`zsh --sh-word-split' invokes zsh with SH_WORD_SPLIT
.
Options are turned off with a `+'; thus `+-sh-word-split' is equivalent to `--no-sh-word-split'.
Long options cannot be suffixes.
--version
sends version information to standard output
--help
sends a list of options that can be used when invoking the shell to standard output
To allow an argument to begin with a -
,
option processing is terminated with a lone -
, +
, --
, +-
or stacked with preceeding options (-x-
is equivalent to -x --
) .
`-b' or `+b' ends option processing. `-b' is like `--', except that further single-letter options can be stacked after the `-b'
sh
or ksh
when invoked as sh
or ksh
.su
uses the name from $SHELL
and emulation is based on that.
interactive_comments
set, a word beginning with
histchars[3]
(orgin 1!) (default #
) begins a comment which
continues until the end-of-line .
With extended_glob
(default set)
℘#
matchs zero or more of the pattern ℘
(corresponds to the regular expression modifier *
)
℘##
matchs one or more
(corresponds to the regular expression modifier +
).
If used intending to be a comment, zsh reports bad pattern
!
Examples of treatment of #
:
$ setopt extended_glob $ echo hello # hello : hello--- a history pattern matchzsh: bad pattern: # $ unsetopt extended_glob $ echo hello # hello : hello--- a regular characterhello # hello : hello $ setopt interactive_comments $ echo hello # hello : hello--- a comment for the rest of the line.hello $ histchars[3]=:--- changing to use$ echo hello # hello : hello hello # hello:
as comment leading.bash interactive_comments
on by default in interactive shells.$ echo hello # hello hello $ shopt -u interactive_commentsunset it$ echo hello # hello hello # hello
if [ -e .vimrc bash true if .vimrc exists, zsh ... if [ -a .vimrc bash true if .vimrc exists, zsh [: too many arguments if [ -d /Volume/DATA bash true if /Volume/DATA exists, zsh false $x == 0 # expected logical test to return result zsh: = not found $x=';' # expected x to be assigned string value of ; zsh: ; not found $x="x" # expected x to be assigned string value of x .zprofile is executed ! When encounters: set editing-mode vi zsh reports zsh:1: command not found: editing-mode set |g vi '*'=( editing-mode vi ) @=( editing-mode vi ) argv=( editing-mode vi ) set '!'=0 also echo $! reports 0 '#'=2 '$'=5982 '*'=( editing-mode vi ) -=569Xils 0=-zsh '?'=127 @=( editing-mode vi )
$SHELL=/bin/zsh SHELL_SESSION_DID_HISTORY_CHECK=1 SHELL_SESSION_DID_INIT=1 SHELL_SESSION_HISTORY=1 SHELL_SESSION_DIR=/Users/$USER/.zsh_sessions SHELL_SESSION_FILE=/Users/$USER/.zsh_sessions/C75FC5F8-92F5-4886-92D7-F2FB6FC7516D.session 1/14/22 227 files since Dec 28, increasing in size fo 40KB to 100kb ! SHELL_SESSION_HISTFILE=/Users/$USER/.zsh_sessions/C75FC5F8-92F5-4886-92D7-F2FB6FC7516D.history SHELL_SESSION_HISTFILE_NEW=/Users/$USER/.zsh_sessions/C75FC5F8-92F5-4886-92D7-F2FB6FC7516D.historynew 0 created at login(?) SHELL_SESSION_HISTFILE_SHARED=/Users/$USER/.zsh_history SHELL_SESSION_TIMESTAMP_FILE=/Users/$USER/.zsh_sessions/_expiration_check_timestamp ZSH_SUBSHELL=1The first two
histchars
(default ! ^
) are used in history expansions.
--emulate mode
can be used as the first option.mode
s are described for the emulate builtin, see zshbuiltins.
When
In
Invoked as
Equivalent to functions -u, with the exception of -X/+X and -w.
With
If
Run for all instances of zsh and should be as small as possible.
Code that does not need to be run for every shell should be behind a test of the
form
Compiled files newer than the original will be used (see zshbuiltins
SEE ALSO
sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1), zshall(1), zshbuiltins(1), zshcompwid(1), zshcompsys(1),
zshcompctl(1), zshcontrib(1), zshexpn(1), zshmisc(1), zshmodules(1), zshoptions(1), zshparam(1), zshroadmap(1),
zshtcpsys(1), zshzftpsys(1), zshzle(1)
A user guide is at http://zsh.sourceforge.net/Guide/. At
emulate
command : variables that conflict
with POSIX usage such as path
are not defined. sh
and ksh
compatibility modes :
ARGC, argv, cdpath, fignore, fpath, HISTCHARS, mailpath, MANPATH, manpath, path, prompt, PROMPT, PROMPT2, PROMPT3,
PROMPT4, psvar, status and watch
are not special and not initialized.
/etc/profile, $HOME/.profile
.
$ENV
is set on invocation, it is sourced after the profile scripts.
The value of ENV is subjected to parameter expansion, command substitution, and arithmetic expansion before being
interpreted as a pathname. PRIVILEGED
affects the execution of startup files.
NO_BAD_PATTERN, NO_BANG_HIST, NO_BG_NICE,
NO_EQUALS, NO_FUNCTION_ARGZERO, GLOB_SUBST, NO_GLOBAL_EXPORT, NO_HUP, INTERACTIVE_COMMENTS, KSH_ARRAYS,
NO_MULTIOS, NO_NOMATCH, NO_NOTIFY, POSIX_BUILTINS, NO_PROMPT_PERCENT, RM_STAR_SILENT, SH_FILE_EXPANSION, SH_GLOB,
SH_OPTION_LETTERS, SH_WORD_SPLIT
are set.
Invoked as sh
BSD_ECHO and IGNORE_BRACES
are set. ksh
KSH_OPTION_PRINT, LOCAL_OPTIONS, PROMPT_BANG, PROMPT_SUBST and SINGLE_LINE_ZLE
are set.
autoload [ {+|-}UXktz ] [ -w ] [ name … ]
-X
may be used only inside a shell function, and may not be followed by a name, causes the calling function to be marked for autoloading and then immediately loaded and executed, with the current array of positional parameters as arguments. This replaces the previous definition of the function.
If no function definition is found, an error is printed and the function remains undefined and marked for autoloading.
+X
loads each name as an autoloaded function, but does not execute it.
The exit status is zero (success) if the function was not previously defined and a definition for it was found.
This does not replace any existing definition of the function.
The exit status is nonzero (failure) if the function was already defined or when no definition was found. In the latter case the function remains undefined and marked for autoloading.
If ksh-style autoloading is enabled, the function created will contain the contents of the file plus a call to the function itself appended to it, giving normal ksh autoloading behaviour on the first call to the function.
-w
files are compiled with zcompile
builtin and
functions defined in them are marked for autoloading.-z
and -k
mark the function to be autoloaded in native or ksh emulation, as if KSH_AUTOLOAD
were unset or were set, respectively. The flags override the setting of the option at the time the function is loaded.
STARTUP/SHUTDOWN FILES
$ZDOTDIR
is unset $HOME
is used .
At startup
/etc/zshenv
Commands are read, this cannot be overridden.
Apple mac os, none is present
if [[ -o rcs ]]; then …
so that it will not be executed when zsh is invoked with -f
.RCS
(set by default) if unset supresses processing of subsequent startup files.
GLOBAL_RCS
(set by default) if unset supresses processing of subsequent global startup files
(those shown here with an path starting with a /).
A file in $ZDOTDIR
can re-enable GLOBAL_RCS.
$ZDOTDIR/.zshenv
/etc/zprofile
Apple mac os has
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`$ZDOTDIR/.zprofile
for a login shell, $ZDOTDIR/.zshrc
for interactive.
Apple mac os for
/etc/zshrc
has :
zshrc_Apple_Terminal
/etc/zlogin
$ZDOTDIR/.zlogin
for a login shell
When the login shell exits:
These are affected by $ZDOTDIR/.zlogout
/etc/zlogout
are processed unless the shell terminates due to exec'ing another process
$RCS
and $GLOBAL_RCS
.
If $RCS
is unset no history file will be saved.
zcompile
).
FILES
$ZDOTDIR/.zshenv
$ZDOTDIR/.zprofile
$ZDOTDIR/.zshrc
$ZDOTDIR/.zlogin
$ZDOTDIR/.zlogout
${TMPPREFIX}* (default is /tmp/zsh*)
/etc/zshenv
/etc/zprofile
/etc/zshrc
/etc/zlogin
/etc/zlogout (installation-specific - /etc is the default)