<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark light">
<meta name="description" content="zshrs full reference — every builtin, keyword, parameter-expansion form, ZshFlag, array shape, AOP intercept, parallel primitive, and coreutils replacement. Code examples for each.">
<title>zshrs — Reference</title>
<link rel="icon" type="image/svg+xml" href="logo-mark.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Share+Tech+Mono&display=swap" rel="stylesheet">
<link rel="stylesheet" href="hud-static.css">
<link rel="stylesheet" href="tutorial.css">
<style>
.tutorial-main { max-width: 72rem; }
.docs-build-line {
margin: 0.35rem 0 0;
font-family: 'Share Tech Mono', ui-monospace, monospace;
font-size: 11px; color: var(--text-dim);
letter-spacing: 0.03em; max-width: 42rem; opacity: 0.75;
}
.hub-scheme-strip {
border-bottom: 1px dashed var(--border);
background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
padding: 0.55rem 1.5rem 0.65rem; position: relative;
}
.hub-scheme-strip-inner {
max-width: 72rem; margin: 0 auto;
display: flex; align-items: center; gap: 0.85rem;
}
.hub-scheme-strip .hud-scheme-label {
flex: 0 0 auto;
font-family: 'Orbitron', sans-serif; font-size: 9px; font-weight: 700;
letter-spacing: 2px; text-transform: uppercase; color: var(--accent);
}
.hub-scheme-strip .scheme-grid {
flex: 1 1 auto;
display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px;
}
@media (max-width: 720px) {
.hub-scheme-strip-inner { flex-direction: column; align-items: stretch; }
.hub-scheme-strip .scheme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.chapter-index {
list-style: none; padding: 0; margin: 0;
display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
gap: 0.3rem;
}
.chapter-index li {
border: 1px solid var(--border); padding: 0.45rem 0.65rem; border-radius: 2px;
background: color-mix(in srgb, var(--bg-card) 92%, transparent);
display: flex; justify-content: space-between; align-items: baseline;
}
.chapter-index li a {
color: var(--cyan); text-decoration: none; font-size: 13px;
font-family: 'Share Tech Mono', ui-monospace, monospace;
}
.chapter-index li a:hover { color: var(--accent-light); }
.chapter-count {
font-size: 10px; color: var(--text-muted);
font-family: 'Share Tech Mono', ui-monospace, monospace;
}
.chapter-meta {
font-size: 11px; color: var(--text-muted); margin: -0.3rem 0 0.8rem;
font-family: 'Share Tech Mono', ui-monospace, monospace;
}
.doc-entry {
margin: 1rem 0 1.4rem;
padding: 0.75rem 0.9rem 0.5rem;
border-left: 2px solid var(--cyan);
background: color-mix(in srgb, var(--bg) 94%, transparent);
border-radius: 2px;
}
.doc-entry h3 {
margin: 0 0 0.45rem;
font-family: 'Orbitron', sans-serif;
font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
text-transform: uppercase; color: var(--cyan);
}
.doc-entry h3 code {
color: var(--accent-light); background: transparent; border: none;
padding: 0; font-size: 1em; letter-spacing: 0.5px;
}
.doc-entry .doc-anchor {
color: var(--text-muted); font-size: 0.85em; margin-right: 0.25rem;
text-decoration: none;
}
.doc-entry .doc-anchor:hover { color: var(--accent); }
.doc-entry h4 {
font-family: 'Orbitron', sans-serif;
font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
text-transform: uppercase; color: var(--accent-light);
margin: 0.8rem 0 0.3rem;
}
.doc-entry p {
font-size: 13px; line-height: 1.6; color: var(--text-dim);
margin: 0.35rem 0;
}
.doc-entry p code, .doc-entry li code {
color: var(--accent-light); font-size: 12px;
}
.doc-entry ul { margin: 0.3rem 0 0.5rem; padding-left: 1.25rem; }
.doc-entry li { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin: 0.2rem 0; }
.doc-entry pre {
font-family: 'Share Tech Mono', ui-monospace, monospace;
font-size: 12px;
background: var(--bg); border: 1px solid var(--border);
border-radius: 2px;
padding: 0.7rem 0.9rem; overflow-x: auto;
color: var(--text); margin: 0.5rem 0;
box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35);
}
.doc-entry pre code { color: var(--text); background: transparent; border: none; padding: 0; }
[data-theme="light"] .doc-entry pre { box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05); }
kbd {
font-family: 'Share Tech Mono', ui-monospace, monospace;
font-size: 11px;
padding: 1px 6px;
background: var(--bg-secondary);
border: 1px solid var(--border);
border-bottom-width: 2px;
border-radius: 3px;
color: var(--cyan);
}
</style>
</head>
<body>
<div class="app tutorial-app" id="docsApp">
<div class="crt-scanline" id="crtH" aria-hidden="true"></div>
<div class="crt-scanline-v" id="crtV" aria-hidden="true"></div>
<header class="tutorial-header">
<div class="tutorial-header-inner">
<img class="tutorial-logo" src="logo-mark.svg" alt="zshrs" width="48" height="48">
<div>
<h1 class="tutorial-brand">// ZSHRS — FULL REFERENCE</h1>
<nav class="tutorial-crumbs" aria-label="Breadcrumb">
<a href="index.html">Docs</a>
<span class="sep">/</span>
<span class="current">Reference</span>
<span class="sep">/</span>
<a href="https://github.com/MenkeTechnologies/zshrs" target="_blank" rel="noopener noreferrer">GitHub</a>
</nav>
<p class="docs-build-line">zshrs v0.13.52 · 14 chapters · every supported builtin, keyword, expansion form & AOP primitive</p>
</div>
<div class="tutorial-toolbar">
<button type="button" class="btn btn-secondary" id="btnTheme" title="Toggle light/dark">Theme</button>
<button type="button" class="btn btn-secondary active" id="btnCrt" title="CRT scanline overlay">CRT</button>
<button type="button" class="btn btn-secondary active" id="btnNeon" title="Neon border pulse">Neon</button>
<a class="btn btn-secondary" href="index.html">Hub</a>
<a class="btn btn-secondary" href="https://github.com/MenkeTechnologies/zshrs" target="_blank" rel="noopener noreferrer">GitHub</a>
</div>
</div>
</header>
<div class="hub-scheme-strip">
<div class="hub-scheme-strip-inner">
<span class="hud-scheme-label">// Color scheme</span>
<div class="scheme-grid" id="hudSchemeGrid"></div>
</div>
</div>
<main class="tutorial-main">
<h2 class="tutorial-title"><span class="step-hash">>_</span>SHELL REFERENCE</h2>
<p class="tutorial-subtitle">Every builtin, keyword, parameter-expansion form, ZshFlag, array shape, AOP primitive, parallel primitive, and anti-fork coreutils replacement that zshrs ships. Each entry shows what it does and a runnable example. Jump via the chapter index, or <kbd>Ctrl+F</kbd> for a specific name.</p>
<section class="tutorial-section">
<h2>Chapters</h2>
<ul class="chapter-index">
<li><a href="#ch-control-flow">Control Flow</a> <span class="chapter-count">14</span></li>
<li><a href="#ch-arrays-hashes">Arrays & Associative Arrays</a> <span class="chapter-count">14</span></li>
<li><a href="#ch-param-expansion">Parameter Expansion</a> <span class="chapter-count">21</span></li>
<li><a href="#ch-zsh-flags">Zsh Parameter Flags</a> <span class="chapter-count">21</span></li>
<li><a href="#ch-redirects-pipes">Redirection & Pipelines</a> <span class="chapter-count">15</span></li>
<li><a href="#ch-shell-builtins">POSIX / Zsh Builtins</a> <span class="chapter-count">52</span></li>
<li><a href="#ch-job-control">Job Control & Background</a> <span class="chapter-count">11</span></li>
<li><a href="#ch-coreutils">Anti-Fork Coreutils</a> <span class="chapter-count">23</span></li>
<li><a href="#ch-parallel">Parallel Primitives</a> <span class="chapter-count">5</span></li>
<li><a href="#ch-aop">AOP Intercept</a> <span class="chapter-count">3</span></li>
<li><a href="#ch-diagnostics">Diagnostics & Profiling</a> <span class="chapter-count">5</span></li>
<li><a href="#ch-completion">Completion System</a> <span class="chapter-count">10</span></li>
<li><a href="#ch-zle">ZLE Line Editor</a> <span class="chapter-count">4</span></li>
<li><a href="#ch-pcre">PCRE & Regex</a> <span class="chapter-count">4</span></li>
<li><a href="#ch-lsp-compat">Compat Builtin Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-keywords">Keyword Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-options">Option Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-specials">Special Variable Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-compsys">Compsys Function Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-extensions">Extension Builtin Index</a> <span class="chapter-count">LSP</span></li>
<li><a href="#ch-lsp-operators">Operator / Punctuation Index</a> <span class="chapter-count">LSP</span></li>
</ul>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-control-flow">
<h2>Control Flow</h2>
<p class="chapter-meta">14 topics</p>
<article class="doc-entry" id="doc-if">
<h3><a class="doc-anchor" href="#doc-if">#</a> <code>if … then … fi</code></h3>
<p>Standard POSIX conditional. <code>elif</code> branches and an optional <code>else</code> are supported.</p>
<pre><code>if [[ -d "$dir" ]]; then
cd "$dir"
elif [[ -f "$dir" ]]; then
echo "regular file"
else
echo "no such path"
fi</code></pre>
</article>
<article class="doc-entry" id="doc-while">
<h3><a class="doc-anchor" href="#doc-while">#</a> <code>while … do … done</code></h3>
<p>Loops while the condition exits 0. Loop-body status is preserved across iterations via a dedicated slot — the loop's exit status is the body's last-command status (or 0 if the body never ran), matching POSIX.</p>
<pre><code>i=0
while (( i < 5 )); do
echo "iter $i"
(( i++ ))
done</code></pre>
</article>
<article class="doc-entry" id="doc-until">
<h3><a class="doc-anchor" href="#doc-until">#</a> <code>until … do … done</code></h3>
<p>Inverse of <code>while</code> — loops while the condition is non-zero.</p>
<pre><code>until ping -c1 -W1 example.com >/dev/null; do
sleep 1
done
echo "online"</code></pre>
</article>
<article class="doc-entry" id="doc-for">
<h3><a class="doc-anchor" href="#doc-for">#</a> <code>for var in words; do … done</code></h3>
<p>Iterates <code>var</code> over the word list.</p>
<pre><code>for f in *.rs; do
echo "compiling $f"
done
arr=(alpha beta gamma)
for x in ${arr[@]}; do
echo "got $x"
done</code></pre>
</article>
<article class="doc-entry" id="doc-for-arith">
<h3><a class="doc-anchor" href="#doc-for-arith">#</a> <code>for ((init; cond; step)); do … done</code></h3>
<p>C-style arithmetic for loop.</p>
<pre><code>for ((i = 0; i < 10; i++)); do
echo "i=$i"
done</code></pre>
</article>
<article class="doc-entry" id="doc-case">
<h3><a class="doc-anchor" href="#doc-case">#</a> <code>case … esac</code></h3>
<p>Pattern-matched dispatch. The patterns keep <code>$</code>-expansion but are not glob-expanded against the current directory.</p>
<pre><code>case "$1" in
start) echo starting ;;
stop) echo stopping ;;
*) echo "usage: $0 {start|stop}"; exit 1 ;;
esac</code></pre>
</article>
<article class="doc-entry" id="doc-select">
<h3><a class="doc-anchor" href="#doc-select">#</a> <code>select var in words; do … done</code></h3>
<p>Interactive numbered-menu loop. Prints <code>1) word1\n2) word2\n…</code> to stderr, prompts via <code>$PROMPT3</code> (default <code>?# </code>), reads stdin, sets <code>var</code> to the chosen word, runs the body. <code>$REPLY</code> contains the raw input. EOF on stdin exits the loop.</p>
<pre><code>select choice in build test deploy quit; do
case $choice in
build) cargo build ;;
test) cargo test ;;
deploy) ./deploy.sh ;;
quit) break ;;
esac
done</code></pre>
</article>
<article class="doc-entry" id="doc-anon-fn">
<h3><a class="doc-anchor" href="#doc-anon-fn">#</a> <code>() { body } args…</code></h3>
<p>Anonymous function. Defined and immediately invoked with the trailing words as <code>$1…$N</code>. The <code>function</code> keyword with no name (<code>function { body } args…</code>, any separator after it) is the same anonymous function. A <code>()</code> with no body is a parse error, as in zsh.</p>
<pre><code>() { echo "hi $1, $2 args"; } world 1
# → hi world, 1 args</code></pre>
</article>
<article class="doc-entry" id="doc-case-fall">
<h3><a class="doc-anchor" href="#doc-case-fall">#</a> <code>case;&</code> fall-through, <code>;|</code> test-next</h3>
<p>Per-arm separators after a case body. <code>;;</code> exits (default), <code>;&</code> falls through to the next arm <em>without</em> re-testing its pattern, <code>;|</code> falls through and <em>does</em> re-test.</p>
<pre><code>case "$x" in
a) print A ;& # falls into b's body
b) print B ;;
*) print other ;;
esac</code></pre>
</article>
<article class="doc-entry" id="doc-coproc">
<h3><a class="doc-anchor" href="#doc-coproc">#</a> <code>coproc [name] { body }</code></h3>
<p>Forks the body with bidirectional pipes. Two pipes are created (parent→child stdin, child→parent stdout); child <code>setsid</code>s and runs the body, parent stores <code>[read_fd, write_fd]</code> in <code>$COPROC</code> (or the given name as an array). Read child output via <code>/dev/fd/${COPROC[1]}</code>, write to its stdin via <code>/dev/fd/${COPROC[2]}</code>.</p>
<pre><code>coproc { while read line; do echo "ECHO: $line"; done }
echo hello > /dev/fd/${COPROC[2]}
read reply < /dev/fd/${COPROC[1]}
echo "$reply" # ECHO: hello</code></pre>
</article>
<article class="doc-entry" id="doc-break">
<h3><a class="doc-anchor" href="#doc-break">#</a> <code>break</code></h3>
<p>Exits the innermost <code>for</code>/<code>while</code>/<code>until</code>.</p>
<pre><code>for f in *.log; do
[[ -s $f ]] || break # stop on first empty
process "$f"
done</code></pre>
</article>
<article class="doc-entry" id="doc-continue">
<h3><a class="doc-anchor" href="#doc-continue">#</a> <code>continue</code></h3>
<p>Skip to the next iteration. Same patch mechanism as <code>break</code> — patches into the loop's <em>continue target</em> which is the iteration step (e.g. <code>PreIncSlotVoid</code> in the for-loop).</p>
<pre><code>for n in 1 2 3 4 5; do
(( n % 2 == 0 )) || continue
echo "even: $n"
done</code></pre>
</article>
<article class="doc-entry" id="doc-return">
<h3><a class="doc-anchor" href="#doc-return">#</a> <code>return [n]</code></h3>
<p>Return from a function with the given status (default last-status).</p>
<pre><code>greet() {
[[ -z "$1" ]] && return 1
echo "hello, $1"
}</code></pre>
</article>
<article class="doc-entry" id="doc-list-ops">
<h3><a class="doc-anchor" href="#doc-list-ops">#</a> <code>;</code> <code>&&</code> <code>||</code> <code>&</code></h3>
<p>Sequential, conditional, and background separators. <code>cmd1 && cmd2</code> runs <code>cmd2</code> only if <code>cmd1</code> succeeded; <code>||</code> is the inverse.</p>
<pre><code>git pull && cargo test || echo "test failed"
sleep 30 &
echo "going to bg"</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-arrays-hashes">
<h2>Arrays & Associative Arrays</h2>
<p class="chapter-meta">13 topics</p>
<article class="doc-entry" id="doc-arr-literal">
<h3><a class="doc-anchor" href="#doc-arr-literal">#</a> <code>arr=(a b c)</code></h3>
<p>Indexed-array literal assignment.</p>
<pre><code>arr=(alpha beta "two words" gamma)
echo ${#arr[@]} # 4</code></pre>
</article>
<article class="doc-entry" id="doc-arr-append">
<h3><a class="doc-anchor" href="#doc-arr-append">#</a> <code>arr+=(d e)</code></h3>
<p>Append elements to an existing array (or create if missing).</p>
<pre><code>arr=(a b)
arr+=(c d)
echo ${arr[@]} # a b c d</code></pre>
</article>
<article class="doc-entry" id="doc-arr-index">
<h3><a class="doc-anchor" href="#doc-arr-index">#</a> <code>${arr[N]}</code></h3>
<p>Indexed access. zsh is 1-based for positive indices; negative indices count from the end (<code>${arr[-1]}</code> = last). For assoc arrays the same form does string-key lookup.</p>
<pre><code>arr=(alpha beta gamma)
echo ${arr[1]} # alpha
echo ${arr[-1]} # gamma</code></pre>
</article>
<article class="doc-entry" id="doc-arr-splice-all">
<h3><a class="doc-anchor" href="#doc-arr-splice-all">#</a> <code>${arr[@]}</code></h3>
<p>Splice all elements as separate argv slots. Without the splice, the array would collapse to one space-joined scalar.</p>
<pre><code>arr=(--verbose --color=always /etc /var)
ls "${arr[@]}" # ls --verbose --color=always /etc /var</code></pre>
</article>
<article class="doc-entry" id="doc-arr-length">
<h3><a class="doc-anchor" href="#doc-arr-length">#</a> <code>${#arr[@]}</code></h3>
<p>Number of elements.</p>
<pre><code>arr=(a b c d)
echo ${#arr[@]} # 4</code></pre>
</article>
<article class="doc-entry" id="doc-arr-iterate">
<h3><a class="doc-anchor" href="#doc-arr-iterate">#</a> <code>for x in ${arr[@]}</code></h3>
<p>Iterate over array elements.</p>
<pre><code>arr=(red green blue)
for c in ${arr[@]}; do
echo "color: $c"
done</code></pre>
</article>
<article class="doc-entry" id="doc-arr-empty">
<h3><a class="doc-anchor" href="#doc-arr-empty">#</a> <code>arr=()</code></h3>
<p>Empty-array literal. <code>${#arr[@]}</code> returns 0; iteration runs zero times.</p>
<pre><code>arr=()
for x in ${arr[@]}; do echo "never"; done
echo "len=${#arr[@]}" # len=0</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-decl">
<h3><a class="doc-anchor" href="#doc-assoc-decl">#</a> <code>typeset -A name</code> / <code>declare -A name</code></h3>
<p>Declare an associative array. Optional — <code>name[key]=val</code> creates the assoc on demand too.</p>
<pre><code>typeset -A user
user[name]=Alice
user[role]=eng
echo "${user[name]}" # Alice</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-set">
<h3><a class="doc-anchor" href="#doc-assoc-set">#</a> <code>name[key]=value</code></h3>
<p>Assoc-array key set.</p>
<pre><code>db[host]=localhost
db[port]=5432
db[user]=admin
echo "${db[host]}:${db[port]}"</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-get">
<h3><a class="doc-anchor" href="#doc-assoc-get">#</a> <code>${name[key]}</code></h3>
<p>Assoc-array lookup. Missing keys return empty string.</p>
<pre><code>typeset -A m
m[a]=1; m[b]=2
echo "a=${m[a]} b=${m[b]}"
echo "missing=[${m[nope]}]" # missing=[]</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-keys">
<h3><a class="doc-anchor" href="#doc-assoc-keys">#</a> <code>${(k)name}</code></h3>
<p>List the keys of an associative array. See the <a href="#ch-zsh-flags">Zsh Parameter Flags</a> chapter for the full flag set.</p>
<pre><code>typeset -A m
m[apple]=1; m[banana]=2
for k in "${(k)m}"; do echo $k; done | sort</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-values">
<h3><a class="doc-anchor" href="#doc-assoc-values">#</a> <code>${(v)name}</code></h3>
<p>List the values of an associative array. <code>${name[@]}</code> on an assoc returns the same value list.</p>
<pre><code>typeset -A m
m[apple]=1; m[banana]=2
for v in "${(v)m}"; do echo $v; done | sort</code></pre>
</article>
<article class="doc-entry" id="doc-arr-set-assoc-overwrite">
<h3><a class="doc-anchor" href="#doc-arr-set-assoc-overwrite">#</a> <code>m[k]=new</code> overwrites</h3>
<p>Re-assigning a key replaces the prior value. The set-builtin always inserts; use <code>+=</code> for append-on-existing-key semantics.</p>
<pre><code>m[k]=first
m[k]=second
echo "${m[k]}" # second</code></pre>
</article>
<article class="doc-entry" id="doc-assoc-append">
<h3><a class="doc-anchor" href="#doc-assoc-append">#</a> <code>m[k]+=tail</code></h3>
<p>Append onto an existing assoc value (string concat). If the key is missing, behaves like a plain set.</p>
<pre><code>m[host]=localhost
m[host]+=":5432"
echo "${m[host]}" # localhost:5432</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-param-expansion">
<h2>Parameter Expansion</h2>
<p class="chapter-meta">21 topics</p>
<article class="doc-entry" id="doc-pe-default">
<h3><a class="doc-anchor" href="#doc-pe-default">#</a> <code>${var:-default}</code></h3>
<p>Use <code>default</code> if <code>var</code> is unset or empty. The default expression is itself compiled (variables, command substitution, etc. all expand at use time).</p>
<pre><code>name=${1:-anonymous}
log_level=${LOG_LEVEL:-info}
target=${1:-$(date +%Y%m%d)}</code></pre>
</article>
<article class="doc-entry" id="doc-pe-assign">
<h3><a class="doc-anchor" href="#doc-pe-assign">#</a> <code>${var:=default}</code></h3>
<p>Assign <code>default</code> to <code>var</code> if unset/empty, then expand.</p>
<pre><code>: ${CACHE_DIR:=$HOME/.cache}
echo "$CACHE_DIR" # CACHE_DIR is now set</code></pre>
</article>
<article class="doc-entry" id="doc-pe-error">
<h3><a class="doc-anchor" href="#doc-pe-error">#</a> <code>${var:?msg}</code></h3>
<p>Print error and exit if <code>var</code> is unset/empty. Common in script preamble for required env vars.</p>
<pre><code>: ${API_TOKEN:?must be set}
: ${DEPLOY_TARGET:?usage: deploy <target>}</code></pre>
</article>
<article class="doc-entry" id="doc-pe-alternate">
<h3><a class="doc-anchor" href="#doc-pe-alternate">#</a> <code>${var:+alt}</code></h3>
<p>Expand to <code>alt</code> if <code>var</code> is set and non-empty, else empty.</p>
<pre><code>flag=${VERBOSE:+--verbose}
cargo build $flag</code></pre>
</article>
<article class="doc-entry" id="doc-pe-length">
<h3><a class="doc-anchor" href="#doc-pe-length">#</a> <code>${#var}</code></h3>
<p>String length of scalar (or via <code>${(#)arr}</code> the element count of an array — see Zsh Flags).</p>
<pre><code>name=Alice
echo ${#name} # 5</code></pre>
</article>
<article class="doc-entry" id="doc-pe-substring">
<h3><a class="doc-anchor" href="#doc-pe-substring">#</a> <code>${var:offset:length}</code></h3>
<p>Substring extraction. Negative offsets count from the end. Length is optional (omitted = to end).</p>
<pre><code>s=abcdefgh
echo ${s:2:3} # cde
echo ${s:-3} # fgh (last 3 chars)
echo ${s:2} # cdefgh (offset 2 to end)</code></pre>
</article>
<article class="doc-entry" id="doc-pe-strip-prefix">
<h3><a class="doc-anchor" href="#doc-pe-strip-prefix">#</a> <code>${var#pat}</code> / <code>${var##pat}</code></h3>
<p>Strip shortest / longest matching prefix. <code>#</code> = shortest, <code>##</code> = longest. Lowers to <code>STRIP_SHORT</code> / <code>STRIP_LONG</code>.</p>
<pre><code>path=/usr/local/bin/zshrs
echo ${path##*/} # zshrs (basename via longest-prefix-strip)
echo ${path#*/} # usr/local/bin/zshrs</code></pre>
</article>
<article class="doc-entry" id="doc-pe-strip-suffix">
<h3><a class="doc-anchor" href="#doc-pe-strip-suffix">#</a> <code>${var%pat}</code> / <code>${var%%pat}</code></h3>
<p>Strip shortest / longest matching suffix. <code>%</code> = shortest, <code>%%</code> = longest. Lowers to <code>RSTRIP_SHORT</code> / <code>RSTRIP_LONG</code>.</p>
<pre><code>file=archive.tar.gz
echo ${file%.gz} # archive.tar
echo ${file%%.*} # archive (dirname via longest-suffix-strip)</code></pre>
</article>
<article class="doc-entry" id="doc-pe-replace-first">
<h3><a class="doc-anchor" href="#doc-pe-replace-first">#</a> <code>${var/pat/repl}</code></h3>
<p>Replace first match of <code>pat</code> with <code>repl</code>. Lowers to <code>SUBST_FIRST</code>. <code>repl</code> may use <code>&</code> for the matched text in some shells; zshrs follows zsh's literal-replace semantics.</p>
<pre><code>s="foo bar foo"
echo ${s/foo/baz} # baz bar foo</code></pre>
</article>
<article class="doc-entry" id="doc-pe-replace-all">
<h3><a class="doc-anchor" href="#doc-pe-replace-all">#</a> <code>${var//pat/repl}</code></h3>
<p>Replace <em>all</em> matches. Lowers to <code>SUBST_ALL</code>. Heavily used by zpwr-style idioms (path normalization, sigil replacement).</p>
<pre><code>s="hello world hello"
echo ${s//hello/HI} # HI world HI
path="/a/b/c"
echo ${path//\//.} # .a.b.c</code></pre>
</article>
<article class="doc-entry" id="doc-pe-upper">
<h3><a class="doc-anchor" href="#doc-pe-upper">#</a> <code>${var:u}</code> / <code>${(U)var}</code></h3>
<p>Uppercase.</p>
<pre><code>x=hello
echo ${x:u} # HELLO
echo ${(U)x} # HELLO</code></pre>
</article>
<article class="doc-entry" id="doc-pe-lower">
<h3><a class="doc-anchor" href="#doc-pe-lower">#</a> <code>${var:l}</code> / <code>${(L)var}</code></h3>
<p>Lowercase. Same dual-form pattern as upper.</p>
<pre><code>x=HELLO
echo ${x:l} # hello
echo ${(L)x} # hello</code></pre>
</article>
<article class="doc-entry" id="doc-pe-special-q">
<h3><a class="doc-anchor" href="#doc-pe-special-q">#</a> <code>$?</code></h3>
<p>Exit status of the last command.</p>
<pre><code>cargo test
if (( $? != 0 )); then echo "tests failed"; fi</code></pre>
</article>
<article class="doc-entry" id="doc-pe-special-pid">
<h3><a class="doc-anchor" href="#doc-pe-special-pid">#</a> <code>$$</code></h3>
<pre><code>tmpdir=/tmp/build_$$
mkdir -p "$tmpdir"</code></pre>
</article>
<article class="doc-entry" id="doc-pe-special-positional">
<h3><a class="doc-anchor" href="#doc-pe-special-positional">#</a> <code>$1 $2 … $@ $* $#</code></h3>
<p>Positional parameters. <code>$@</code> / <code>$*</code> expand to the full list (joined by IFS), <code>$#</code> is the count, numeric <code>$N</code> is the Nth positional.</p>
<pre><code>greet() {
echo "got $# args"
for arg in "$@"; do echo "- $arg"; done
}
greet alpha "two words" gamma</code></pre>
</article>
<article class="doc-entry" id="doc-pe-special-misc">
<h3><a class="doc-anchor" href="#doc-pe-special-misc">#</a> <code>$! $_ $-</code></h3>
<p>Auxiliary special params. <code>$!</code> = PID of the most recent backgrounded job. <code>$_</code> = last argument of the previous command (or empty at script start). <code>$-</code> = current shell flag set as a single string.</p>
</article>
<article class="doc-entry" id="doc-pe-random">
<h3><a class="doc-anchor" href="#doc-pe-random">#</a> <code>$RANDOM $SECONDS $EPOCHSECONDS $LINENO</code></h3>
<p>Dynamic special parameters resolved on each read in <code>get_variable</code>:</p>
<ul>
<li><code>$RANDOM</code> — 15-bit pseudorandom int. Mixes nanos+pid via Knuth's hash, masked to 15 bits. No seedable state today (independent draws).</li>
<li><code>$SECONDS</code> — seconds since shell start, derived from <code>__zshrs_start_secs</code> baseline.</li>
<li><code>$EPOCHSECONDS</code> — Unix time, <code>SystemTime::now()</code>.</li>
</ul>
<pre><code>tmp="/tmp/build_$$_$RANDOM"
echo "elapsed: $SECONDS s"
echo "now: $EPOCHSECONDS"</code></pre>
</article>
<article class="doc-entry" id="doc-pe-pipestatus">
<h3><a class="doc-anchor" href="#doc-pe-pipestatus">#</a> <code>$PIPESTATUS</code> / <code>$pipestatus</code></h3>
<p>Per-stage exit codes of the most recent pipeline. Useful for <code>set -e</code>-style scripts that need to differentiate which stage failed.</p>
<pre><code>seq 100 | grep '^5' | wc -l
echo "${pipestatus[@]}" # 0 0 0
false | true
echo "${pipestatus[1]}" # 1 (zsh: 1-indexed)</code></pre>
</article>
<article class="doc-entry" id="doc-pe-var-exists">
<h3><a class="doc-anchor" href="#doc-pe-var-exists">#</a> <code>[[ -v var ]]</code> — existence test</h3>
<p>Useful for "set but empty" vs "unset" disambiguation that <code>-z</code> conflates.</p>
<pre><code>x=""
[[ -v x ]] && echo "set" # set (even though empty)
[[ -z $x ]] && echo "empty" # empty
unset x
[[ -v x ]] || echo "unset" # unset</code></pre>
</article>
<article class="doc-entry" id="doc-pe-arith-sub">
<h3><a class="doc-anchor" href="#doc-pe-arith-sub">#</a> <code>$((expr))</code></h3>
<p>Arithmetic substitution. Integers are 64-bit; supports <code>+ - * / % ** & | ^ << >> && ||</code> and pre/post inc/dec.</p>
<pre><code>(( total = 1 + 2 * 3 ))
echo $((2 ** 16)) # 65536
echo $((0xff & 0x0f))</code></pre>
</article>
<article class="doc-entry" id="doc-pe-cmd-sub">
<h3><a class="doc-anchor" href="#doc-pe-cmd-sub">#</a> <code>$(cmd)</code> / <code>` cmd `</code></h3>
<p>Command substitution. Captures the command's stdout without forking. Trailing newlines are stripped per POSIX.</p>
<pre><code>now=$(date +%s)
files=$(ls *.rs | wc -l)
echo "$files files at $now"</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-zsh-flags">
<h2>Zsh Parameter Flags</h2>
<p class="chapter-meta">12 topics</p>
<article class="doc-entry" id="doc-flag-L">
<h3><a class="doc-anchor" href="#doc-flag-L">#</a> <code>(L)</code> — lowercase</h3>
<p>Lowercases the value. For arrays, lowercases each element.</p>
<pre><code>x=Hello
echo ${(L)x} # hello
arr=(One Two Three)
echo ${(L)arr} # one two three</code></pre>
</article>
<article class="doc-entry" id="doc-flag-U">
<h3><a class="doc-anchor" href="#doc-flag-U">#</a> <code>(U)</code> — uppercase</h3>
<p>Uppercases.</p>
<pre><code>echo ${(U)x} # HELLO</code></pre>
</article>
<article class="doc-entry" id="doc-flag-j">
<h3><a class="doc-anchor" href="#doc-flag-j">#</a> <code>(j:sep:)</code> — join</h3>
<p>Join array elements with <code>sep</code>. The delimiter char following <code>j</code> sets the bracket — <code>:</code>, <code>.</code>, <code>,</code>, <code>|</code> are common. <code>j</code> with no delimiter joins with a single space (IFS-default).</p>
<pre><code>arr=(one two three)
echo ${(j:-:)arr} # one-two-three
echo ${(j:|:)arr} # one|two|three
echo ${(j)arr} # one two three</code></pre>
</article>
<article class="doc-entry" id="doc-flag-s">
<h3><a class="doc-anchor" href="#doc-flag-s">#</a> <code>(s:sep:)</code> — split</h3>
<p>Split a scalar on <code>sep</code> into an array. The result splices into argv via the standard array-flatten path.</p>
<pre><code>csv="alpha,beta,gamma"
for x in "${(s:,:)csv}"; do
echo "[$x]"
done</code></pre>
</article>
<article class="doc-entry" id="doc-flag-f">
<h3><a class="doc-anchor" href="#doc-flag-f">#</a> <code>(f)</code> — split on newlines</h3>
<p>Shorthand for <code>(s:\n:)</code> — split on newlines. Common with command substitution.</p>
<pre><code>for line in "${(f)$(ls)}"; do
echo "FILE: $line"
done</code></pre>
</article>
<article class="doc-entry" id="doc-flag-o">
<h3><a class="doc-anchor" href="#doc-flag-o">#</a> <code>(o)</code> — sort ascending</h3>
<p>Lexicographic sort.</p>
<pre><code>arr=(charlie alpha bravo)
echo ${(o)arr} # alpha bravo charlie</code></pre>
</article>
<article class="doc-entry" id="doc-flag-O">
<h3><a class="doc-anchor" href="#doc-flag-O">#</a> <code>(O)</code> — sort descending</h3>
<p>Reverse lexicographic sort.</p>
<pre><code>echo ${(O)arr} # charlie bravo alpha</code></pre>
</article>
<article class="doc-entry" id="doc-flag-P">
<h3><a class="doc-anchor" href="#doc-flag-P">#</a> <code>(P)</code> — indirect</h3>
<p>Use the value of the variable as <em>another</em> variable name and look that up. Useful for dynamic dispatch tables.</p>
<pre><code>real=42
ref=real
echo ${(P)ref} # 42</code></pre>
</article>
<article class="doc-entry" id="doc-flag-at">
<h3><a class="doc-anchor" href="#doc-flag-at">#</a> <code>(@)</code> — force array</h3>
<p>Coerce a scalar to a single-element array (so subsequent flags treat it as array-shape).</p>
<pre><code>x=hello
echo ${#x} # 5 (string length)
echo ${(#)${(@)x}} # 1 (array length after @-coerce)</code></pre>
</article>
<article class="doc-entry" id="doc-flag-k">
<h3><a class="doc-anchor" href="#doc-flag-k">#</a> <code>(k)</code> — keys of assoc</h3>
<p>Returns the keys of an associative array as an array.</p>
<pre><code>typeset -A m
m[apple]=1; m[banana]=2
for k in "${(k)m}"; do echo "$k"; done</code></pre>
</article>
<article class="doc-entry" id="doc-flag-v">
<h3><a class="doc-anchor" href="#doc-flag-v">#</a> <code>(v)</code> — values of assoc</h3>
<p>Returns the values of an associative array as an array.</p>
<pre><code>echo ${(v)m} # 1 2</code></pre>
</article>
<article class="doc-entry" id="doc-flag-pound">
<h3><a class="doc-anchor" href="#doc-flag-pound">#</a> <code>(#)</code> — count</h3>
<p>Element count for arrays, character count for scalars. Different from <code>${#var}</code> in that it can be combined with other flags via stacking.</p>
<pre><code>arr=(a b c d)
echo ${(#)arr} # 4
echo ${(#L)x} # length after lowercasing</code></pre>
</article>
<article class="doc-entry" id="doc-flag-q">
<h3><a class="doc-anchor" href="#doc-flag-q">#</a> <code>(q)</code> / <code>(qq)</code> / <code>(qqq)</code> — quote</h3>
<p>Wrap each value with shell-safe quoting. Consecutive <code>q</code>s raise the quoting level: <code>q</code> = POSIX single-quote (escaping inner <code>'</code>), <code>qq</code> = double-quote (escaping <code>$</code>/<code>`</code>/<code>"</code>/<code>\</code>), <code>qqq</code> = ANSI-C <code>$'…'</code> form (escaping control chars + backslashes).</p>
<pre><code>x="hi 'world'"
echo ${(q)x} # 'hi '\''world'\'''
echo ${(qq)x} # "hi 'world'"
s=$(printf 'a\tb')
echo ${(qqq)s} # $'a\tb'</code></pre>
</article>
<article class="doc-entry" id="doc-flag-g">
<h3><a class="doc-anchor" href="#doc-flag-g">#</a> <code>(g)</code> — backslash-escape unwrap</h3>
<p>Process backslash escapes (<code>\n</code>, <code>\t</code>, <code>\r</code>, <code>\\</code>, <code>\xNN</code>). Useful when reading lines from a config that stored real newlines as literal <code>\n</code>.</p>
<pre><code>s='hello\nworld'
echo "${(g)s}"
# hello
# world</code></pre>
</article>
<article class="doc-entry" id="doc-flag-n">
<h3><a class="doc-anchor" href="#doc-flag-n">#</a> <code>(n)</code> — natural-numeric sort</h3>
<p>Compare digit runs as integers and other runs lexicographically. <code>file2</code> sorts before <code>file10</code> (vs lex order which would put <code>file10</code> first). Combine with <code>(o)</code>/<code>(O)</code> for ascending/descending.</p>
<pre><code>arr=(file10 file2 file1 file20)
echo ${(on)arr} # file1 file2 file10 file20</code></pre>
</article>
<article class="doc-entry" id="doc-flag-i">
<h3><a class="doc-anchor" href="#doc-flag-i">#</a> <code>(i)</code> — case-insensitive sort</h3>
<p>Sort comparing lowercase forms while preserving original case in the output.</p>
<pre><code>arr=(Banana apple Cherry)
echo ${(i)arr} # apple Banana Cherry</code></pre>
</article>
<article class="doc-entry" id="doc-flag-t">
<h3><a class="doc-anchor" href="#doc-flag-t">#</a> <code>(t)</code> — type query</h3>
<p>Returns the variable's typeset shape: <code>scalar</code>, <code>array</code>, <code>association</code>, or empty (unset). Useful in scripts that branch on whether a name is an indexed vs assoc array.</p>
<pre><code>arr=(a b)
typeset -A m; m[k]=v
sc=str
echo "${(t)arr}|${(t)m}|${(t)sc}"
# array|association|scalar</code></pre>
</article>
<article class="doc-entry" id="doc-flag-percent">
<h3><a class="doc-anchor" href="#doc-flag-percent">#</a> <code>(%)</code> — prompt expansion</h3>
<p>Process <code>%F</code>/<code>%B</code>/<code>%f</code>/<code>%{</code>/<code>%}</code> etc. via <code>expand_prompt_string</code>. Useful for storing prompt fragments in variables and rendering them at use time.</p>
<pre><code>fragment='%F{cyan}>>%f '
echo "${(%)fragment}"</code></pre>
</article>
<article class="doc-entry" id="doc-flag-e">
<h3><a class="doc-anchor" href="#doc-flag-e">#</a> <code>(e)</code> — re-evaluate</h3>
<p>Run the value as a shell command and return its captured stdout. Equivalent to <code>$(eval "$value")</code> but uses the in-process pipe-capture path (no fork). Late-bound config strings.</p>
<pre><code>cmd='echo "user is $(whoami)"'
echo "${(e)cmd}" # user is alice</code></pre>
</article>
<article class="doc-entry" id="doc-flag-p">
<h3><a class="doc-anchor" href="#doc-flag-p">#</a> <code>(p)</code> — print-style escapes</h3>
<p>Process backslash escapes the same way <code>print -e</code> does. Same set as <code>(g)</code> with <code>\e</code> / <code>\E</code> mapped to <code>ESC</code>.</p>
<pre><code>fmt='\e[36mcolor\e[0m'
echo "${(p)fmt}" # cyan "color"</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-redirects-pipes">
<h2>Redirection & Pipelines</h2>
<p class="chapter-meta">14 topics</p>
<article class="doc-entry" id="doc-redir-write">
<h3><a class="doc-anchor" href="#doc-redir-write">#</a> <code>cmd > file</code> — write</h3>
<p>Truncates and writes stdout to file. Bracketed in a redirect scope so subsequent commands see the original fd 1.</p>
<pre><code>echo hello > out.txt</code></pre>
</article>
<article class="doc-entry" id="doc-redir-append">
<h3><a class="doc-anchor" href="#doc-redir-append">#</a> <code>cmd >> file</code> — append</h3>
<p>Appends stdout. Creates the file if missing.</p>
<pre><code>date >> access.log</code></pre>
</article>
<article class="doc-entry" id="doc-redir-read">
<h3><a class="doc-anchor" href="#doc-redir-read">#</a> <code>cmd < file</code> — read</h3>
<p>Connects file to stdin.</p>
<pre><code>sort < data.txt</code></pre>
</article>
<article class="doc-entry" id="doc-redir-stderr">
<h3><a class="doc-anchor" href="#doc-redir-stderr">#</a> <code>cmd 2> file</code> — stderr</h3>
<p>Redirect stderr (fd 2). Use <code>2>&1</code> to merge into stdout.</p>
<pre><code>cargo build 2> build.err
make 2>&1 | tee build.log</code></pre>
</article>
<article class="doc-entry" id="doc-redir-write-both">
<h3><a class="doc-anchor" href="#doc-redir-write-both">#</a> <code>cmd &> file</code> — write both</h3>
<p>Redirect both stdout and stderr (zsh/bash extension). <code>&>></code> appends.</p>
<pre><code>./run.sh &> combined.log</code></pre>
</article>
<article class="doc-entry" id="doc-redir-heredoc">
<h3><a class="doc-anchor" href="#doc-redir-heredoc">#</a> <code>cmd <<EOF</code> — heredoc (with variants)</h3>
<p>Multi-line stdin literal. Three flavors:</p>
<ul style="margin-top: 0.4rem;">
<li><code><<EOF</code> — variables, command sub, arithmetic all expand inside the body. Body trailing newline trimmed before <code>HereString</code> emit so stdin is byte-identical to source.</li>
<li><code><<-EOF</code> — leading tabs stripped from each body line <em>and</em> from the closing-terminator-line check. Lets you indent the heredoc body inside a function body.</li>
<li><code><<'EOF'</code> / <code><<"EOF"</code> — quoted terminator → body is verbatim, <strong>no</strong> expansion.</li>
</ul>
<pre><code>cat <<EOF
hello $USER
host: $(hostname)
EOF
cat <<-EOF
indented
body
EOF
cat <<'EOF'
$USER stays literal
EOF</code></pre>
</article>
<article class="doc-entry" id="doc-redir-herestring">
<h3><a class="doc-anchor" href="#doc-redir-herestring">#</a> <code>cmd <<< "string"</code> — herestring</h3>
<p>Pass a single string (with trailing newline) as stdin.</p>
<pre><code>tr a-z A-Z <<< "hello" # HELLO</code></pre>
</article>
<article class="doc-entry" id="doc-redir-pipe">
<h3><a class="doc-anchor" href="#doc-redir-pipe">#</a> <code>cmd1 | cmd2</code> — pipeline</h3>
<p>SIGPIPE works correctly.</p>
<pre><code>seq 100 | sort | uniq | wc -l</code></pre>
</article>
<article class="doc-entry" id="doc-redir-pipe-stderr">
<h3><a class="doc-anchor" href="#doc-redir-pipe-stderr">#</a> <code>cmd1 |& cmd2</code> — pipe stdout+stderr</h3>
<p>zsh extension: pipes both fd 1 and fd 2 of the LHS to RHS.</p>
<pre><code>cargo test |& head -40</code></pre>
</article>
<article class="doc-entry" id="doc-redir-not">
<h3><a class="doc-anchor" href="#doc-redir-not">#</a> <code>! cmd</code> — invert status</h3>
<p>Negate the pipeline's exit status. <code>! cmd</code> exits 0 if cmd failed, 1 if cmd succeeded.</p>
<pre><code>! grep -q ERROR log # status 0 means no ERROR found</code></pre>
</article>
<article class="doc-entry" id="doc-redir-procsub-in">
<h3><a class="doc-anchor" href="#doc-redir-procsub-in">#</a> $1 <p>Spawn cmd, present its stdout as a path readable by the consumer.</p>
<pre><code>diff <(sort a.txt) <(sort b.txt)</code></pre>
</article>
<article class="doc-entry" id="doc-redir-procsub-out">
<h3><a class="doc-anchor" href="#doc-redir-procsub-out">#</a> <code>>(cmd)</code> — process sub (output)</h3>
<p>Spawn cmd, present its stdin as a path writable by the producer.</p>
<pre><code>tar c . | tee >(gzip > backup.tgz) > backup.tar</code></pre>
</article>
<article class="doc-entry" id="doc-redir-fd-dup">
<h3><a class="doc-anchor" href="#doc-redir-fd-dup">#</a> <code>cmd N>&M</code> — duplicate fd</h3>
<p>Duplicate fd M to fd N. Common idiom: <code>2>&1</code> merges stderr into stdout. <code><&fd</code> defaults the destination to fd 0; <code>>&fd</code> defaults to fd 1. Variable-expanded fd targets work: <code>read line <&${COPROC[1]}</code>.</p>
<pre><code>find / 2>&1 | grep '\.zsh$' | head
coproc { echo from-child; }
read reply <&${COPROC[1]}
echo "$reply" # from-child</code></pre>
</article>
<article class="doc-entry" id="doc-redir-fd-close">
<h3><a class="doc-anchor" href="#doc-redir-fd-close">#</a> <code>cmd N<&-</code> / <code>cmd N>&-</code> — close fd</h3>
<p>Close fd N. POSIX form for explicitly tearing down a previously-opened fd (typically after <code>exec FD< file</code>).</p>
<pre><code>exec 5< data.txt
read line <&5
exec 5<&- # close fd 5</code></pre>
</article>
<article class="doc-entry" id="doc-redir-with-redirects">
<h3><a class="doc-anchor" href="#doc-redir-with-redirects">#</a> <code>{ cmds; } > file</code> — block redirect</h3>
<p>Apply a redirect to a compound command.</p>
<pre><code>{
echo header
date
uname -a
} > report.txt</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-shell-builtins">
<h2>POSIX / Zsh Builtins</h2>
<p class="chapter-meta">52 topics</p>
<article class="doc-entry" id="doc-cd">
<h3><a class="doc-anchor" href="#doc-cd">#</a> <code>cd [dir]</code></h3>
<p>Change directory. With no argument, goes to <code>$HOME</code>. <code>cd -</code> jumps to <code>$OLDPWD</code>. Updates <code>$PWD</code>.</p>
<pre><code>cd ~/repos/zshrs
cd - # back to previous</code></pre>
</article>
<article class="doc-entry" id="doc-pwd">
<h3><a class="doc-anchor" href="#doc-pwd">#</a> <code>pwd</code></h3>
<p>Print working directory.</p>
<pre><code>echo "now in $(pwd)"</code></pre>
</article>
<article class="doc-entry" id="doc-echo">
<h3><a class="doc-anchor" href="#doc-echo">#</a> <code>echo [args]</code></h3>
<p>Print arguments space-separated with trailing newline. <code>-n</code> suppresses newline; <code>-e</code> enables backslash escapes.</p>
<pre><code>echo hello world
echo -n "no newline"
echo -e "tab:\there"</code></pre>
</article>
<article class="doc-entry" id="doc-print">
<h3><a class="doc-anchor" href="#doc-print">#</a> <code>print</code></h3>
<p>zsh's enhanced echo. <code>-r</code> raw, <code>-n</code> no newline, <code>-l</code> one arg per line, <code>-z</code> push to history.</p>
<pre><code>print -l alpha beta gamma # one per line
print -P "%F{cyan}cyan%f" # prompt expansion</code></pre>
</article>
<article class="doc-entry" id="doc-printf">
<h3><a class="doc-anchor" href="#doc-printf">#</a> <code>printf format args…</code></h3>
<p>C-style formatted output. Format directives: <code>%s %d %f %x %o %b</code>; backslash escapes <code>\n \t</code> etc.</p>
<pre><code>printf "%-10s %5d\n" "items" 42</code></pre>
</article>
<article class="doc-entry" id="doc-export">
<h3><a class="doc-anchor" href="#doc-export">#</a> <code>export VAR=value</code></h3>
<p>Mark a variable for export to subprocesses (writes to <code>std::env</code>).</p>
<pre><code>export PATH="/opt/bin:$PATH"
export RUST_LOG=debug</code></pre>
</article>
<article class="doc-entry" id="doc-unset">
<h3><a class="doc-anchor" href="#doc-unset">#</a> <code>unset VAR…</code></h3>
<p>Remove a variable. Removes from <code>variables</code>, <code>arrays</code>, <code>assoc_arrays</code>, and exported env.</p>
<pre><code>unset DEBUG_FLAG
unset -f myfunc # remove function</code></pre>
</article>
<article class="doc-entry" id="doc-source">
<h3><a class="doc-anchor" href="#doc-source">#</a> <code>source file</code> / <code>. file</code></h3>
<p>Plugin delta cache replays state changes (functions, aliases, vars, hooks, zstyles, options) in microseconds.</p>
<pre><code>source ~/.zshrc
. /etc/profile.d/lang.sh</code></pre>
</article>
<article class="doc-entry" id="doc-exit">
<h3><a class="doc-anchor" href="#doc-exit">#</a> <code>exit [n]</code></h3>
<p>Exit the shell with status <em>n</em> (default last status). Aliases: <code>bye</code>, <code>logout</code>. EXIT trap fires before halt.</p>
<pre><code>[[ -z $1 ]] && { echo "missing arg"; exit 2; }</code></pre>
</article>
<article class="doc-entry" id="doc-true-false">
<h3><a class="doc-anchor" href="#doc-true-false">#</a> <code>true</code> / <code>false</code> / <code>:</code></h3>
<p>Status helpers. <code>true</code> and <code>:</code> exit 0; <code>false</code> exits 1. <code>:</code> is also the no-op for argument expansion side effects.</p>
<pre><code>: ${VAR:=default} # set if unset; expansion side effect, no command
while true; do …; done</code></pre>
</article>
<article class="doc-entry" id="doc-test">
<h3><a class="doc-anchor" href="#doc-test">#</a> <code>test EXPR</code> / <code>[ EXPR ]</code></h3>
<p>POSIX conditional test. Use <code>[[ … ]]</code> for the zsh extended form (in-shell, no fork). Operators: <code>-f -d -e -r -w -x -s -z -n = != < > -eq -ne -lt -le -gt -ge</code>.</p>
<pre><code>[ -f /etc/passwd ] && echo "exists"
[[ $count -gt 10 && -n $name ]]</code></pre>
</article>
<article class="doc-entry" id="doc-local">
<h3><a class="doc-anchor" href="#doc-local">#</a> <code>local VAR[=value]</code></h3>
<p>Function-local scope. zshrs's local-scope semantics: declared vars are pushed onto a scope stack at function entry, popped at return. Assignment-without-declare-at-top-of-function is allowed (zsh idiom) but a bare <code>local var</code> re-declaration inside a loop prints the current value when <code>TYPESET_SILENT</code> is unset, so declare locals once at the top of the function.</p>
<pre><code>my_func() {
local count=0
local result
…
}</code></pre>
</article>
<article class="doc-entry" id="doc-typeset">
<h3><a class="doc-anchor" href="#doc-typeset">#</a> <code>typeset</code> / <code>declare</code></h3>
<p>Declare a variable with attributes. <code>-a</code> indexed array, <code>-A</code> assoc array, <code>-i</code> integer, <code>-r</code> readonly, <code>-x</code> exported, <code>-l</code> lowercase, <code>-u</code> uppercase, <code>-g</code> global (in func scope), <code>-f</code> function-scoped.</p>
<pre><code>typeset -i count=0
typeset -A config
typeset -r APP_VERSION=1.0
declare -a names=(alice bob carol)</code></pre>
</article>
<article class="doc-entry" id="doc-readonly">
<h3><a class="doc-anchor" href="#doc-readonly">#</a> <code>readonly VAR=val</code></h3>
<p>Mark a variable read-only. Subsequent assignments error.</p>
<pre><code>readonly RELEASE_BRANCH=main</code></pre>
</article>
<article class="doc-entry" id="doc-integer">
<h3><a class="doc-anchor" href="#doc-integer">#</a> <code>integer VAR=expr</code></h3>
<p>Declare an integer-typed variable. Subsequent assignments evaluate as arithmetic.</p>
<pre><code>integer i=10
i=i+5
echo $i # 15</code></pre>
</article>
<article class="doc-entry" id="doc-float">
<h3><a class="doc-anchor" href="#doc-float">#</a> <code>float VAR=expr</code></h3>
<p>Declare a float-typed variable.</p>
<pre><code>float pi=3.14159
echo $((pi * 2))</code></pre>
</article>
<article class="doc-entry" id="doc-read">
<h3><a class="doc-anchor" href="#doc-read">#</a> <code>read VAR…</code></h3>
<p>Read a line from stdin into one or more variables. Flags: <code>-r</code> raw (no backslash escapes), <code>-n N</code> N chars, <code>-t SEC</code> timeout, <code>-s</code> silent, <code>-p prompt</code>, <code>-A arr</code> read into array.</p>
<pre><code>echo -n "name? "
read name
read -r line < /etc/hostname
read -A words <<< "alpha beta gamma"</code></pre>
</article>
<article class="doc-entry" id="doc-mapfile">
<h3><a class="doc-anchor" href="#doc-mapfile">#</a> <code>mapfile</code> / <code>readarray</code></h3>
<p>Read each line of a file (or stdin) into successive elements of an array. Bash compat alias.</p>
<pre><code>mapfile -t lines < /etc/hosts
echo "${#lines[@]} hosts"</code></pre>
</article>
<article class="doc-entry" id="doc-shift">
<h3><a class="doc-anchor" href="#doc-shift">#</a> <code>shift [n]</code></h3>
<p>Remove the first <em>n</em> positional parameters (default 1).</p>
<pre><code>process() {
cmd=$1; shift
do_thing "$cmd" "$@"
}</code></pre>
</article>
<article class="doc-entry" id="doc-eval">
<h3><a class="doc-anchor" href="#doc-eval">#</a> <code>eval string</code></h3>
<p>Re-parse and execute the joined-args string as shell code.</p>
<pre><code>x=10
eval 'echo $x' # 10 (expansion deferred to eval-time)
eval "$(starship init zsh)"</code></pre>
</article>
<article class="doc-entry" id="doc-exec">
<h3><a class="doc-anchor" href="#doc-exec">#</a> <code>exec [cmd args]</code></h3>
<p>Replace the current shell with <em>cmd</em>. With no command, applies redirections to the current shell (e.g. <code>exec > log</code> redirects subsequent output).</p>
<pre><code>exec > build.log 2>&1
exec /usr/local/bin/newshell</code></pre>
</article>
<article class="doc-entry" id="doc-command">
<h3><a class="doc-anchor" href="#doc-command">#</a> <code>command [-pvV] cmd</code></h3>
<p>Bypass functions/aliases and run the underlying command. <code>-v</code> prints how the name would resolve; <code>-V</code> verbose form.</p>
<pre><code>command rm /tmp/junk # bypass user's `rm` function
command -v cargo # /Users/wizard/.cargo/bin/cargo</code></pre>
</article>
<article class="doc-entry" id="doc-builtin">
<h3><a class="doc-anchor" href="#doc-builtin">#</a> <code>builtin cmd</code></h3>
<p>Force builtin dispatch (skip functions/aliases).</p>
<pre><code>builtin cd /tmp # zshrs's cd, never a user override</code></pre>
</article>
<article class="doc-entry" id="doc-let">
<h3><a class="doc-anchor" href="#doc-let">#</a> <code>let "expr"</code></h3>
<p>Evaluate arithmetic expression(s); exit 0 if last result is non-zero.</p>
<pre><code>let "i = 1 + 2"
let "i++"</code></pre>
</article>
<article class="doc-entry" id="doc-set">
<h3><a class="doc-anchor" href="#doc-set">#</a> <code>set [-eux] [args…]</code></h3>
<p>Set shell options or positional parameters. <code>-e</code> exit on error, <code>-u</code> nounset, <code>-x</code> trace, <code>-o pipefail</code> propagate pipeline status.</p>
<pre><code>set -euo pipefail
set -- alpha beta gamma # set $1 $2 $3</code></pre>
</article>
<article class="doc-entry" id="doc-setopt-unsetopt">
<h3><a class="doc-anchor" href="#doc-setopt-unsetopt">#</a> <code>setopt</code> / <code>unsetopt</code></h3>
<p>Toggle zsh-style options.</p>
<pre><code>setopt extended_glob
setopt null_glob
unsetopt nomatch</code></pre>
</article>
<article class="doc-entry" id="doc-shopt">
<h3><a class="doc-anchor" href="#doc-shopt">#</a> <code>shopt</code></h3>
<p>Bash-compat option toggling. Maps onto the same options table as <code>setopt</code>.</p>
<pre><code>shopt -s globstar</code></pre>
</article>
<article class="doc-entry" id="doc-emulate">
<h3><a class="doc-anchor" href="#doc-emulate">#</a> <code>emulate [-LR] [shell]</code></h3>
<p>Switch emulation mode (<code>zsh</code>, <code>sh</code>, <code>ksh</code>, <code>csh</code>). <code>-L</code> local-to-function, <code>-R</code> reset all options to that shell's defaults.</p>
<pre><code>emulate -L zsh # function-local zsh defaults</code></pre>
</article>
<article class="doc-entry" id="doc-getopts">
<h3><a class="doc-anchor" href="#doc-getopts">#</a> <code>getopts spec var</code></h3>
<p>POSIX option parsing. Iterates flags from <code>$@</code>, sets <code>$var</code> to each option, <code>$OPTARG</code> to its value.</p>
<pre><code>while getopts "vh:" opt; do
case $opt in
v) verbose=1 ;;
h) host=$OPTARG ;;
esac
done</code></pre>
</article>
<article class="doc-entry" id="doc-zparseopts">
<h3><a class="doc-anchor" href="#doc-zparseopts">#</a> <code>zparseopts</code></h3>
<p>zsh's richer option parser. <code>-A arr</code> stores into an assoc array; supports long options.</p>
<pre><code>zparseopts -A opts -- v h: c::
echo "${opts[-h]}"</code></pre>
</article>
<article class="doc-entry" id="doc-autoload">
<h3><a class="doc-anchor" href="#doc-autoload">#</a> $1 <p>Mark a function for lazy loading from <code>$fpath</code>.</p>
<pre><code>autoload -Uz compinit
compinit</code></pre>
</article>
<article class="doc-entry" id="doc-functions">
<h3><a class="doc-anchor" href="#doc-functions">#</a> <code>functions [name]</code></h3>
<p>List defined functions, or print a function's body. <code>+f</code> prints names only.</p>
<pre><code>functions # all functions
functions my_func # body of my_func</code></pre>
</article>
<article class="doc-entry" id="doc-unfunction">
<h3><a class="doc-anchor" href="#doc-unfunction">#</a> <code>unfunction name</code></h3>
<p>Remove a function definition. Same as <code>unset -f</code>.</p>
<pre><code>unfunction old_helper</code></pre>
</article>
<article class="doc-entry" id="doc-trap">
<h3><a class="doc-anchor" href="#doc-trap">#</a> <code>trap 'cmd' SIG</code></h3>
<p>Install a signal handler. Special pseudo-signals: <code>EXIT</code> (run at shell exit), <code>DEBUG</code> (before each command), <code>ERR</code> (on non-zero status), <code>ZERR</code> (zsh-specific).</p>
<pre><code>trap 'rm -rf $tmpdir' EXIT
trap 'echo got SIGINT' INT</code></pre>
</article>
<article class="doc-entry" id="doc-pushd-popd">
<h3><a class="doc-anchor" href="#doc-pushd-popd">#</a> <code>pushd</code> / <code>popd</code> / <code>dirs</code></h3>
<p>Directory stack manipulation. <code>pushd dir</code> changes to <em>dir</em> and pushes onto the stack; <code>popd</code> pops and changes back. <code>dirs -v</code> lists.</p>
<pre><code>pushd ~/work/proj
…
popd</code></pre>
</article>
<article class="doc-entry" id="doc-alias">
<h3><a class="doc-anchor" href="#doc-alias">#</a> <code>alias name='cmd'</code></h3>
<p>Define a command alias. With no args lists all aliases. <code>alias -g</code> creates a global alias (substitutes anywhere on the command line).</p>
<pre><code>alias ll='ls -lAh'
alias -g G='| grep'</code></pre>
</article>
<article class="doc-entry" id="doc-unalias">
<h3><a class="doc-anchor" href="#doc-unalias">#</a> <code>unalias [-m pattern] name</code></h3>
<p>Remove an alias. <code>-m</code> matches by glob pattern.</p>
<pre><code>unalias ll
unalias -m 'g*' # remove all aliases starting with g</code></pre>
</article>
<article class="doc-entry" id="doc-type-whence-which">
<h3><a class="doc-anchor" href="#doc-type-whence-which">#</a> <code>type</code> / <code>whence</code> / <code>where</code> / <code>which</code></h3>
<p>Resolve a name to its source: alias, function, builtin, or external. <code>whence -p</code> shows path only; <code>whence -a</code> shows all matches.</p>
<pre><code>type ls
whence -a cargo
which gcc</code></pre>
</article>
<article class="doc-entry" id="doc-hash">
<h3><a class="doc-anchor" href="#doc-hash">#</a> <code>hash</code> / <code>rehash</code> / <code>unhash</code></h3>
<p>Command-name → path cache. <code>rehash</code> rebuilds the cache from <code>$PATH</code> (parallel scan across worker pool). <code>unhash -dm 'pat'</code> removes named-directory entries by glob.</p>
<pre><code>rehash # after installing new binaries
hash # show cache
unhash -dm 'tmp*' # remove tmp* hashed dir refs</code></pre>
</article>
<article class="doc-entry" id="doc-ulimit">
<h3><a class="doc-anchor" href="#doc-ulimit">#</a> <code>ulimit</code> / <code>limit</code> / <code>unlimit</code></h3>
<p>Resource limit query/set. <code>-n</code> open files, <code>-s</code> stack size, <code>-u</code> max processes, <code>-c</code> core dump.</p>
<pre><code>ulimit -n 65536
ulimit -a # show all</code></pre>
</article>
<article class="doc-entry" id="doc-umask">
<h3><a class="doc-anchor" href="#doc-umask">#</a> <code>umask [mask]</code></h3>
<p>Set/show file-creation mask.</p>
<pre><code>umask 077 # owner-only by default</code></pre>
</article>
<article class="doc-entry" id="doc-times">
<h3><a class="doc-anchor" href="#doc-times">#</a> <code>times</code></h3>
<p>Print user + system times for the shell and its children.</p>
<pre><code>times</code></pre>
</article>
<article class="doc-entry" id="doc-caller">
<h3><a class="doc-anchor" href="#doc-caller">#</a> <code>caller</code></h3>
<p>Print the line + filename of the caller of the current function. Useful in error reporters and debuggers.</p>
<pre><code>my_assert() {
[[ $1 -eq $2 ]] || { echo "assertion failed at $(caller)"; exit 1; }
}</code></pre>
</article>
<article class="doc-entry" id="doc-help">
<h3><a class="doc-anchor" href="#doc-help">#</a> <code>help [name]</code></h3>
<p>Print help for a builtin (or list builtins).</p>
<pre><code>help echo
help</code></pre>
</article>
<article class="doc-entry" id="doc-enable-disable">
<h3><a class="doc-anchor" href="#doc-enable-disable">#</a> <code>enable</code> / <code>disable</code></h3>
<p>Enable/disable a builtin by name. Useful for testing external-vs-builtin behavior.</p>
<pre><code>disable cat # falls back to /bin/cat
enable cat # restore zshrs's cat builtin</code></pre>
</article>
<article class="doc-entry" id="doc-noglob">
<h3><a class="doc-anchor" href="#doc-noglob">#</a> <code>noglob cmd</code></h3>
<p>Run cmd with glob expansion disabled for its arguments. Equivalent to <code>setopt noglob; cmd; unsetopt noglob</code> as a one-liner.</p>
<pre><code>noglob find . -name '*.rs' # don't pre-glob *.rs</code></pre>
</article>
<article class="doc-entry" id="doc-ttyctl">
<h3><a class="doc-anchor" href="#doc-ttyctl">#</a> <code>ttyctl -f</code> / <code>ttyctl -u</code></h3>
<p>Freeze / unfreeze the tty state. Used by completion code that reads stdin.</p>
<pre><code>ttyctl -f # freeze
ttyctl -u # unfreeze</code></pre>
</article>
<article class="doc-entry" id="doc-sync">
<h3><a class="doc-anchor" href="#doc-sync">#</a> <code>sync</code></h3>
<p>Force the OS to flush its buffer cache to disk. Direct <code>sync(2)</code> syscall.</p>
<pre><code>cp big.iso /mnt/usb/
sync</code></pre>
</article>
<article class="doc-entry" id="doc-zmodload">
<h3><a class="doc-anchor" href="#doc-zmodload">#</a> <code>zmodload [-i] mod</code></h3>
<p>Load a zsh module. zshrs's modules are statically linked, so <code>zmodload</code> is a no-op-and-succeed for compat (<code>-i</code> idempotent flag).</p>
<pre><code>zmodload zsh/datetime
zmodload zsh/regex</code></pre>
</article>
<article class="doc-entry" id="doc-zsleep">
<h3><a class="doc-anchor" href="#doc-zsleep">#</a> <code>zsleep n</code></h3>
<p>Subsecond-precision sleep. <code>zsleep 0.5</code> sleeps 500ms. Different from coreutils <code>sleep</code> only in supporting fractional seconds reliably across implementations.</p>
<pre><code>zsleep 0.25 # 250ms</code></pre>
</article>
<article class="doc-entry" id="doc-zsystem">
<h3><a class="doc-anchor" href="#doc-zsystem">#</a> <code>zsystem subcmd</code></h3>
<p>zsh/system module operations. <code>zsystem flock file</code> for file locking; <code>zsystem getflags</code> for flag dumps.</p>
<pre><code>zsystem flock /tmp/lockfile</code></pre>
</article>
<article class="doc-entry" id="doc-strftime">
<h3><a class="doc-anchor" href="#doc-strftime">#</a> <code>strftime fmt [time]</code></h3>
<p>Format a unix timestamp using <code>strftime(3)</code> directives. Default time is <em>now</em>.</p>
<pre><code>strftime "%Y-%m-%d %H:%M:%S"</code></pre>
</article>
<article class="doc-entry" id="doc-mkdir">
<h3><a class="doc-anchor" href="#doc-mkdir">#</a> <code>mkdir [-p] dirs…</code></h3>
<p>Create directories. <code>-p</code> creates parents and doesn't fail if exists.</p>
<pre><code>mkdir -p ~/.config/myapp/{cache,logs}</code></pre>
</article>
<article class="doc-entry" id="doc-vared">
<h3><a class="doc-anchor" href="#doc-vared">#</a> <code>vared VAR</code></h3>
<p>Edit a variable's value via the line editor. Handy for interactive config edits.</p>
<pre><code>vared PATH</code></pre>
</article>
<article class="doc-entry" id="doc-zformat">
<h3><a class="doc-anchor" href="#doc-zformat">#</a> <code>zformat -f var fmt args…</code></h3>
<p>Sprintf with <code>%X:value</code> argument bindings; common in completion display formatting.</p>
<pre><code>zformat -f line "%name (%size)" name:foo size:42</code></pre>
</article>
<article class="doc-entry" id="doc-zregexparse">
<h3><a class="doc-anchor" href="#doc-zregexparse">#</a> <code>zregexparse</code></h3>
<p>State-machine regex parser used by completion and filename rewriting.</p>
<pre><code>zregexparse vname tname regex</code></pre>
</article>
<article class="doc-entry" id="doc-zcompile">
<h3><a class="doc-anchor" href="#doc-zcompile">#</a> $1 <p>Pre-compile a zsh script to <code>.zwc</code>.</p>
<pre><code>zcompile ~/.zshrc</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-job-control">
<h2>Job Control & Background</h2>
<p class="chapter-meta">11 topics</p>
<article class="doc-entry" id="doc-amp">
<h3><a class="doc-anchor" href="#doc-amp">#</a> <code>cmd &</code> — background</h3>
<p>Run cmd in the background.</p>
<pre><code>sleep 30 &
make all & make docs & wait</code></pre>
</article>
<article class="doc-entry" id="doc-jobs">
<h3><a class="doc-anchor" href="#doc-jobs">#</a> <code>jobs</code></h3>
<p>List background jobs known to the shell.</p>
<pre><code>jobs # active jobs
jobs -l # with pids</code></pre>
</article>
<article class="doc-entry" id="doc-fg">
<h3><a class="doc-anchor" href="#doc-fg">#</a> <code>fg [%jobspec]</code></h3>
<p>Bring a background/stopped job to the foreground. <code>%1</code>, <code>%2</code> select by job number; <code>%name</code> by command-name prefix.</p>
<pre><code>fg %1
fg %vim</code></pre>
</article>
<article class="doc-entry" id="doc-bg">
<h3><a class="doc-anchor" href="#doc-bg">#</a> <code>bg [%jobspec]</code></h3>
<p>Resume a stopped job in the background.</p>
<pre><code>bg %1</code></pre>
</article>
<article class="doc-entry" id="doc-kill">
<h3><a class="doc-anchor" href="#doc-kill">#</a> <code>kill [-SIG] pid|%job</code></h3>
<p>Send a signal. Default is <code>SIGTERM</code>. Builtin form supports both PID and jobspec.</p>
<pre><code>kill -INT 12345
kill %1
kill -l # list signals</code></pre>
</article>
<article class="doc-entry" id="doc-wait">
<h3><a class="doc-anchor" href="#doc-wait">#</a> <code>wait [pid|%job]</code></h3>
<p>Wait for a child to exit; with no args, waits for all bg children. Status is the wait-on'd child's exit code.</p>
<pre><code>worker1.sh & pid1=$!
worker2.sh & pid2=$!
wait $pid1 $pid2</code></pre>
</article>
<article class="doc-entry" id="doc-disown">
<h3><a class="doc-anchor" href="#doc-disown">#</a> <code>disown [%job]</code></h3>
<p>Remove a job from the job table without killing it. The process keeps running but is no longer tracked.</p>
<pre><code>long_task &
disown %1</code></pre>
</article>
<article class="doc-entry" id="doc-suspend">
<h3><a class="doc-anchor" href="#doc-suspend">#</a> <code>suspend</code></h3>
<p>Stop the current shell (sends <code>SIGTSTP</code> to itself). Common idiom in nested shells.</p>
<pre><code>suspend</code></pre>
</article>
<article class="doc-entry" id="doc-async">
<h3><a class="doc-anchor" href="#doc-async">#</a> <code>async 'cmd'</code></h3>
<p>Ship work to the worker pool and return an opaque ID. Unlike <code>&</code>, this runs on a thread within the same process — no fork, no setsid.</p>
<pre><code>id=$(async 'sleep 5; curl https://api.example.com')</code></pre>
</article>
<article class="doc-entry" id="doc-await">
<h3><a class="doc-anchor" href="#doc-await">#</a> <code>await ID</code></h3>
<p>Wait for an async task by ID and capture its stdout.</p>
<pre><code>id=$(async 'expensive-job')
result=$(await $id)</code></pre>
</article>
<article class="doc-entry" id="doc-bang-pid">
<h3><a class="doc-anchor" href="#doc-bang-pid">#</a> <code>$!</code> — last bg pid</h3>
<p>PID of the most-recently-backgrounded command. Used to wait/signal it later.</p>
<pre><code>long_task &
echo "spawned $!"
wait $!</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-coreutils">
<h2>Anti-Fork Coreutils</h2>
<p class="chapter-meta">23 topics · <strong>2000-5000x faster</strong> than forking to /bin — every invocation runs in-process via direct syscalls.</p>
<article class="doc-entry" id="doc-cu-cat">
<h3><a class="doc-anchor" href="#doc-cu-cat">#</a> <code>cat [files…]</code></h3>
<p>Concatenate files to stdout. With no args, copies stdin. <code>-n</code> numbers lines; <code>-A</code> shows non-printable. No fork.</p>
<pre><code>cat /etc/hosts
cat *.log | grep ERROR</code></pre>
</article>
<article class="doc-entry" id="doc-cu-head">
<h3><a class="doc-anchor" href="#doc-cu-head">#</a> <code>head [-n N] [files…]</code></h3>
<p>First N lines (default 10). <code>-c N</code> first N bytes.</p>
<pre><code>head -20 /var/log/system.log</code></pre>
</article>
<article class="doc-entry" id="doc-cu-tail">
<h3><a class="doc-anchor" href="#doc-cu-tail">#</a> <code>tail [-n N] [-f] [files…]</code></h3>
<p>Last N lines. <code>-f</code> follow (in-process).</p>
<pre><code>tail -f access.log</code></pre>
</article>
<article class="doc-entry" id="doc-cu-wc">
<h3><a class="doc-anchor" href="#doc-cu-wc">#</a> <code>wc [-lwc] [files…]</code></h3>
<p>Line / word / char count.</p>
<pre><code>wc -l *.rs # total Rust LOC</code></pre>
</article>
<article class="doc-entry" id="doc-cu-sort">
<h3><a class="doc-anchor" href="#doc-cu-sort">#</a> <code>sort [-n -r -u -k] [files…]</code></h3>
<p>Sort lines. <code>-n</code> numeric, <code>-r</code> reverse, <code>-u</code> unique, <code>-k N</code> sort on key.</p>
<pre><code>du -h * | sort -hr</code></pre>
</article>
<article class="doc-entry" id="doc-cu-find">
<h3><a class="doc-anchor" href="#doc-cu-find">#</a> <code>find path [predicates]</code></h3>
<p>Walk directories applying predicates. <code>-name</code>, <code>-type</code>, <code>-size</code>, <code>-mtime</code>, <code>-exec</code>. In-process walk.</p>
<pre><code>find . -name '*.rs' -size +1k</code></pre>
</article>
<article class="doc-entry" id="doc-cu-uniq">
<h3><a class="doc-anchor" href="#doc-cu-uniq">#</a> <code>uniq [-c -d -u] [files…]</code></h3>
<p>Filter adjacent duplicates. <code>-c</code> prefix counts, <code>-d</code> show duplicates only.</p>
<pre><code>cat history.log | sort | uniq -c | sort -nr</code></pre>
</article>
<article class="doc-entry" id="doc-cu-cut">
<h3><a class="doc-anchor" href="#doc-cu-cut">#</a> <code>cut [-d delim] -f fields</code></h3>
<p>Extract fields from each line.</p>
<pre><code>cut -d: -f1 /etc/passwd # all usernames</code></pre>
</article>
<article class="doc-entry" id="doc-cu-tr">
<h3><a class="doc-anchor" href="#doc-cu-tr">#</a> <code>tr SET1 SET2</code></h3>
<p>Translate or delete characters.</p>
<pre><code>echo HELLO | tr A-Z a-z
tr -d '\r' < crlf.txt > lf.txt</code></pre>
</article>
<article class="doc-entry" id="doc-cu-seq">
<h3><a class="doc-anchor" href="#doc-cu-seq">#</a> <code>seq [start] [step] end</code></h3>
<p>Print a sequence of numbers.</p>
<pre><code>for i in $(seq 1 10); do …; done
seq 0 0.5 5</code></pre>
</article>
<article class="doc-entry" id="doc-cu-rev">
<h3><a class="doc-anchor" href="#doc-cu-rev">#</a> <code>rev</code></h3>
<p>Reverse each line character-wise.</p>
<pre><code>echo hello | rev # olleh</code></pre>
</article>
<article class="doc-entry" id="doc-cu-tee">
<h3><a class="doc-anchor" href="#doc-cu-tee">#</a> <code>tee [-a] file…</code></h3>
<p>Copy stdin to stdout AND to one or more files. <code>-a</code> appends.</p>
<pre><code>build.sh 2>&1 | tee build.log</code></pre>
</article>
<article class="doc-entry" id="doc-cu-basename">
<h3><a class="doc-anchor" href="#doc-cu-basename">#</a> <code>basename path [suffix]</code></h3>
<p>Strip directory and optionally a trailing suffix.</p>
<pre><code>basename /tmp/file.txt # file.txt
basename /tmp/file.txt .txt # file</code></pre>
</article>
<article class="doc-entry" id="doc-cu-dirname">
<h3><a class="doc-anchor" href="#doc-cu-dirname">#</a> <code>dirname path</code></h3>
<p>Strip the trailing component.</p>
<pre><code>dirname /tmp/file.txt # /tmp</code></pre>
</article>
<article class="doc-entry" id="doc-cu-touch">
<h3><a class="doc-anchor" href="#doc-cu-touch">#</a> <code>touch [-a -m -t time] file…</code></h3>
<p>Update file timestamps; create empty file if missing.</p>
<pre><code>touch deploy.lock</code></pre>
</article>
<article class="doc-entry" id="doc-cu-realpath">
<h3><a class="doc-anchor" href="#doc-cu-realpath">#</a> <code>realpath path</code></h3>
<p>Resolve symlinks and relative paths to a canonical absolute path.</p>
<pre><code>realpath ./src/exec.rs</code></pre>
</article>
<article class="doc-entry" id="doc-cu-sleep">
<h3><a class="doc-anchor" href="#doc-cu-sleep">#</a> <code>sleep seconds</code></h3>
<p>Pause for <em>seconds</em> (fractional supported).</p>
<pre><code>sleep 0.5</code></pre>
</article>
<article class="doc-entry" id="doc-cu-whoami">
<h3><a class="doc-anchor" href="#doc-cu-whoami">#</a> <code>whoami</code></h3>
<p>Effective username (direct <code>geteuid</code> + <code>getpwuid</code> syscalls).</p>
<pre><code>echo "running as $(whoami)"</code></pre>
</article>
<article class="doc-entry" id="doc-cu-id">
<h3><a class="doc-anchor" href="#doc-cu-id">#</a> <code>id [-u -g -n] [user]</code></h3>
<p>User/group ID info.</p>
<pre><code>id -u # numeric uid
id -un # username</code></pre>
</article>
<article class="doc-entry" id="doc-cu-hostname">
<h3><a class="doc-anchor" href="#doc-cu-hostname">#</a> <code>hostname [-s -f]</code></h3>
<p>System hostname. Direct syscall.</p>
<pre><code>hostname # short
hostname -f # FQDN</code></pre>
</article>
<article class="doc-entry" id="doc-cu-uname">
<h3><a class="doc-anchor" href="#doc-cu-uname">#</a> <code>uname [-a -s -r -m]</code></h3>
<p>Kernel name / release / arch. Direct <code>uname(3)</code>.</p>
<pre><code>uname -srm</code></pre>
</article>
<article class="doc-entry" id="doc-cu-date">
<h3><a class="doc-anchor" href="#doc-cu-date">#</a> <code>date [+fmt]</code></h3>
<p>Print current date/time. <code>+fmt</code> uses <code>strftime</code> directives. Direct syscall.</p>
<pre><code>date
date +%s
date "+%Y-%m-%d %H:%M:%S"</code></pre>
</article>
<article class="doc-entry" id="doc-cu-mktemp">
<h3><a class="doc-anchor" href="#doc-cu-mktemp">#</a> <code>mktemp [-d] [template]</code></h3>
<p>Atomic temp file/dir creation.</p>
<pre><code>tmp=$(mktemp)
tmpdir=$(mktemp -d)</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-parallel">
<h2>Parallel Primitives</h2>
<p class="chapter-meta">12 topics · scheduled on a per-process <code>rayon</code> worker pool (safe inside <code>$(…)</code> and pipeline stages).</p>
<article class="doc-entry" id="doc-pmap">
<h3><a class="doc-anchor" href="#doc-pmap">#</a> <code>pmap 'cmd {}' args…</code></h3>
<p>Parallel map across worker pool. Output preserves input order. The <code>{}</code> placeholder gets each arg.</p>
<pre><code>pmap 'gzip {}' *.log
pmap 'sha256sum {}' **/*.iso</code></pre>
</article>
<article class="doc-entry" id="doc-pgrep">
<h3><a class="doc-anchor" href="#doc-pgrep">#</a> <code>pgrep 'pred {}' args…</code></h3>
<p>Parallel filter. Predicate runs concurrently; matching args are collected in input order.</p>
<pre><code>pgrep 'grep -q TODO {}' **/*.rs # files containing TODO</code></pre>
</article>
<article class="doc-entry" id="doc-peach">
<h3><a class="doc-anchor" href="#doc-peach">#</a> <code>peach 'cmd {}' args…</code></h3>
<p>Parallel for-each, unordered. Fire each task and don't preserve order — useful when output order doesn't matter.</p>
<pre><code>peach 'convert {} {}.png' *.svg</code></pre>
</article>
<article class="doc-entry" id="doc-puniq">
<h3><a class="doc-anchor" href="#doc-puniq">#</a> <code>puniq [ITEM…]</code></h3>
<p>Distinct items in first-occurrence order, hash-partitioned across the worker pool. Reads stdin lines when no ITEM is given.</p>
<pre><code>puniq a b a c
cat big.log | puniq</code></pre>
</article>
<article class="doc-entry" id="doc-psort">
<h3><a class="doc-anchor" href="#doc-psort">#</a> <code>psort [-n] [-r] [ITEM…]</code></h3>
<p>Parallel stable sort of the operands or of stdin lines. <code>-n</code> compares numerically, <code>-r</code> reverses.</p>
<pre><code>psort -nr 10 9 100
cat big.txt | psort</code></pre>
</article>
<article class="doc-entry" id="doc-pfirst">
<h3><a class="doc-anchor" href="#doc-pfirst">#</a> <code>pfirst 'cmd {}' args…</code></h3>
<p>Prints the first argument (lowest position) for which the command succeeds; status 1 when none does. Arguments past the best match found so far are not tested, and the winner is the lowest position, not the first to finish.</p>
<pre><code>pfirst 'test -x {}/zsh' /usr/bin /opt/homebrew/bin</code></pre>
</article>
<article class="doc-entry" id="doc-pany">
<h3><a class="doc-anchor" href="#doc-pany">#</a> <code>pany 'cmd {}' args…</code></h3>
<p>Status 0 as soon as the command succeeds for some argument, else 1; prints nothing. Remaining arguments are skipped once one passes.</p>
<pre><code>pany 'grep -q TODO {}' *.rs && echo has-todos</code></pre>
</article>
<article class="doc-entry" id="doc-pmap_chunked">
<h3><a class="doc-anchor" href="#doc-pmap_chunked">#</a> <code>pmap_chunked N 'cmd {}' args…</code></h3>
<p>Like <code>pmap</code>, but arguments go to the pool in chunks of N and each chunk runs in one shell process, paying process startup once per N items. Output is in argument order.</p>
<pre><code>pmap_chunked 50 'gzip {}' *.log</code></pre>
</article>
<article class="doc-entry" id="doc-par_lines">
<h3><a class="doc-anchor" href="#doc-par_lines">#</a> <code>par_lines 'cmd {}' FILE</code></h3>
<p>Runs the command once per line of FILE, <code>{}</code> replaced by the line. FILE is memory-mapped and cut into line-aligned ranges that run in parallel; output is in file order.</p>
<pre><code>par_lines 'echo got {}' access.log</code></pre>
</article>
<article class="doc-entry" id="doc-par_walk">
<h3><a class="doc-anchor" href="#doc-par_walk">#</a> <code>par_walk 'cmd {}' PATH…</code></h3>
<p>Runs the command once per file and directory under each PATH (the PATHs included), <code>{}</code> replaced by the path. The tree is walked in parallel with names sorted within a directory; output is in walk order.</p>
<pre><code>par_walk 'test -f {} && wc -l {}' src</code></pre>
</article>
<article class="doc-entry" id="doc-barrier">
<h3><a class="doc-anchor" href="#doc-barrier">#</a> <code>barrier 'cmd1' ::: 'cmd2' ::: 'cmd3'</code></h3>
<p>Run all commands in parallel; wait for all to complete. Final status is the worst (highest) of all child statuses.</p>
<pre><code>barrier 'cargo test' ::: 'cargo doc' ::: 'cargo audit'</code></pre>
</article>
<article class="doc-entry" id="doc-barrier-fail-fast">
<h3><a class="doc-anchor" href="#doc-barrier-fail-fast">#</a> <code>barrier --fail-fast …</code></h3>
<p>Cancel remaining tasks as soon as one fails. Useful for guarded fan-out (<em>compile, test, lint</em>) where one failure makes the rest moot.</p>
<pre><code>barrier --fail-fast 'rustfmt --check src/' ::: 'cargo clippy'</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-aop">
<h2>AOP Intercept</h2>
<p class="chapter-meta">3 topics · the first shell with aspect-oriented programming. <code>before</code>/<code>after</code>/<code>around</code> advice. Routes through <code>host_exec_external</code> → <code>run_intercepts</code>.</p>
<p>The body is <em>not</em> expanded at registration — <code>$INTERCEPT_ARGS</code>, <code>$(…)</code> and globs resolve each time the advice fires — and it keeps its own redirections, pipelines and here-documents. Under <code>zshrs --zsh</code> the extension is off and the form is rejected exactly as <code>/bin/zsh</code> rejects it; the quoted equivalent, <code>intercept before git 'code'</code>, works in every mode.</p>
<article class="doc-entry" id="doc-intercept-before">
<h3><a class="doc-anchor" href="#doc-intercept-before">#</a> <code>intercept before pat { code }</code></h3>
<p>Run <em>code</em> before any command matching <em>pat</em>. <code>$INTERCEPT_NAME</code>, <code>$INTERCEPT_ARGS</code>, <code>$INTERCEPT_CMD</code> are bound. Pattern is glob: <code>git</code>, <code>git*</code>, <code>_*</code>.</p>
<pre><code>intercept before git { echo "[$(date)] $INTERCEPT_CMD" >> ~/git.log }</code></pre>
</article>
<article class="doc-entry" id="doc-intercept-after">
<h3><a class="doc-anchor" href="#doc-intercept-after">#</a> <code>intercept after pat { code }</code></h3>
<p>Run after the matched command finishes. Adds <code>$INTERCEPT_MS</code> (elapsed) and <code>$INTERCEPT_STATUS</code>.</p>
<pre><code>intercept after '_*' {
echo "$INTERCEPT_NAME took ${INTERCEPT_MS}ms"
}</code></pre>
</article>
<article class="doc-entry" id="doc-intercept-around">
<h3><a class="doc-anchor" href="#doc-intercept-around">#</a> <code>intercept around pat { code }</code> + <code>intercept_proceed</code></h3>
<p>Wrap the command. Call <code>intercept_proceed</code> from inside to invoke the original; skip it to suppress the original entirely. Replaces <code>defer</code>, <code>profile</code>, <code>memo</code>, <code>retry</code>, <code>timeout</code> with one primitive.</p>
<pre><code>intercept around expensive_func {
local cache=/tmp/cache_${INTERCEPT_ARGS// /_}
if [[ -f $cache ]]; then
cat $cache
else
intercept_proceed | tee $cache
fi
}</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-diagnostics">
<h2>Diagnostics & Profiling</h2>
<p class="chapter-meta">6 topics · zshrs-exclusive observability builtins.</p>
<article class="doc-entry" id="doc-doctor">
<h3><a class="doc-anchor" href="#doc-doctor">#</a> <code>doctor</code></h3>
<p>Full diagnostic dump: worker-pool metrics, cache stats, registered intercepts, history db size, options table.</p>
<pre><code>doctor</code></pre>
</article>
<article class="doc-entry" id="doc-dbview">
<h3><a class="doc-anchor" href="#doc-dbview">#</a> <code>dbview [table] [filter]</code></h3>
<p>Browse SQLite caches without writing SQL. Lists tables + row counts; with arguments shows specific entries.</p>
<pre><code>dbview # tables + row counts
dbview autoloads _git # one autoload entry
dbview comps git # completion search
dbview history docker # history search</code></pre>
</article>
<article class="doc-entry" id="doc-profile">
<h3><a class="doc-anchor" href="#doc-profile">#</a> <code>profile cmd</code></h3>
<p>In-process profiling with nanosecond accuracy. No fork, no <code>strace</code>. Reports CPU time, syscalls, allocations.</p>
<pre><code>profile cargo build</code></pre>
</article>
<article class="doc-entry" id="doc-provenance">
<h3><a class="doc-anchor" href="#doc-provenance">#</a> <code>provenance [-m|-u|-j|-l|-c] [NAME…]</code></h3>
<p>Value lineage: where a parameter's bytes came from, and every operation that produced or consumed them. <code>-m</code> arms tracking for a parameter, <code>-j</code> prints the chain as JSON, <code>-u</code> untracks, <code>-c</code> clears. The engine records nothing until armed; <code>[provenance] enabled = false</code> in <code>~/.zshrs/zshrs.toml</code> (or <code>ZSHRS_PROVENANCE=0</code>) refuses arming outright.</p>
<pre><code>provenance -m ARCHIVE
REPORT=$(date +%Y-%m-%d)
ARCHIVE=${REPORT}.tar.gz
provenance ARCHIVE
# ARCHIVE
# origin: cmdsubst "date +%Y-%m-%d" (line 2)
# ops:
# 1. concat "2026-08-18" ".tar.gz" line 3
# 2. assign ARCHIVE "2026-08-18.tar.gz" line 3</code></pre>
</article>
<article class="doc-entry" id="doc-zprof">
<h3><a class="doc-anchor" href="#doc-zprof">#</a> <code>zprof</code></h3>
<p>Function-level profile (zsh module compat). Enable with <code>zmodload zsh/zprof</code>; print accumulated stats with <code>zprof</code>.</p>
<pre><code>zmodload zsh/zprof
source ~/.zshrc
zprof | head -20</code></pre>
</article>
<article class="doc-entry" id="doc-history">
<h3><a class="doc-anchor" href="#doc-history">#</a> <code>history [-n N] [pattern]</code></h3>
<p>Browse command history. Backed by SQLite + FTS5 — full-text search, frequency-ranked, with timestamps and exit status per command.</p>
<pre><code>history -10 # last 10
history docker # FTS search</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-completion">
<h2>Completion System</h2>
<p class="chapter-meta">10 topics · <code>compinit</code> pre-warms the autoload index across the worker pool.</p>
<article class="doc-entry" id="doc-compinit">
<h3><a class="doc-anchor" href="#doc-compinit">#</a> $1 <p>Initialize the completion system.</p>
$2><code>autoload -Uz compinit && compinit</code></pre>
</article>
<article class="doc-entry" id="doc-compdef">
<h3><a class="doc-anchor" href="#doc-compdef">#</a> <code>compdef func cmd</code></h3>
<p>Bind a completion function to a command name.</p>
<pre><code>compdef _docker docker
compdef _kubectl kubectl k</code></pre>
</article>
<article class="doc-entry" id="doc-compadd">
<h3><a class="doc-anchor" href="#doc-compadd">#</a> <code>compadd [-J group] words…</code></h3>
<p>Add candidate completions. <code>-J</code> groups them; <code>-d desc</code> attaches descriptions.</p>
<pre><code>compadd -J commands start stop status restart</code></pre>
</article>
<article class="doc-entry" id="doc-compset">
<h3><a class="doc-anchor" href="#doc-compset">#</a> <code>compset</code></h3>
<p>Manipulate the completion state — peel off prefixes, set the position, etc.</p>
<pre><code>compset -P 'http://'
compset -S '*.com'</code></pre>
</article>
<article class="doc-entry" id="doc-compopt">
<h3><a class="doc-anchor" href="#doc-compopt">#</a> <code>compopt</code></h3>
<p>Toggle completion options for the current invocation.</p>
<pre><code>compopt -o nospace</code></pre>
</article>
<article class="doc-entry" id="doc-compgen">
<h3><a class="doc-anchor" href="#doc-compgen">#</a> <code>compgen [opts] word</code></h3>
<p>Bash-compat completion candidate generator.</p>
<pre><code>compgen -c git # all commands starting with "git"</code></pre>
</article>
<article class="doc-entry" id="doc-complete">
<h3><a class="doc-anchor" href="#doc-complete">#</a> <code>complete</code></h3>
<p>Bash-compat completion definition.</p>
<pre><code>complete -W "start stop status" myservice</code></pre>
</article>
<article class="doc-entry" id="doc-zstyle">
<h3><a class="doc-anchor" href="#doc-zstyle">#</a> <code>zstyle</code></h3>
<p>Style configuration for completion + prompt. zsh's universal config DSL.</p>
<pre><code>zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'</code></pre>
</article>
<article class="doc-entry" id="doc-cdreplay">
<h3><a class="doc-anchor" href="#doc-cdreplay">#</a> <code>cdreplay</code></h3>
<p>Replay deferred <code>compdef</code> calls accumulated during async <code>compinit</code>.</p>
<pre><code>compinit; cdreplay -q</code></pre>
</article>
<article class="doc-entry" id="doc-promptinit">
<h3><a class="doc-anchor" href="#doc-promptinit">#</a> <code>promptinit</code> + <code>prompt</code></h3>
<p>Theme system for prompts.</p>
<pre><code>autoload -Uz promptinit && promptinit
prompt redhat</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-zle">
<h2>ZLE Line Editor</h2>
<p class="chapter-meta">4 topics · 26 ZLE widgets, syntax highlighting, autosuggestions, abbreviations.</p>
<article class="doc-entry" id="doc-zle">
<h3><a class="doc-anchor" href="#doc-zle">#</a> <code>zle widget [-N name handler]</code></h3>
<p>Manipulate the line editor. <code>-N name handler</code> defines a user widget; <code>zle name</code> invokes one.</p>
<pre><code>my-widget() { LBUFFER+=" --verbose"; }
zle -N my-widget
bindkey '^Xv' my-widget</code></pre>
</article>
<article class="doc-entry" id="doc-bindkey">
<h3><a class="doc-anchor" href="#doc-bindkey">#</a> <code>bindkey [seq widget]</code></h3>
<p>Bind a key sequence to a widget. <code>-M map</code> targets a specific keymap.</p>
<pre><code>bindkey '^R' history-incremental-search-backward
bindkey -M vicmd 'k' up-line-or-beginning-search</code></pre>
</article>
<article class="doc-entry" id="doc-vared-zle">
<h3><a class="doc-anchor" href="#doc-vared-zle">#</a> <code>vared VAR</code> (line-edit form)</h3>
<p>Use ZLE to edit a variable's value interactively.</p>
<pre><code>vared LS_COLORS</code></pre>
</article>
<article class="doc-entry" id="doc-abbrev">
<h3><a class="doc-anchor" href="#doc-abbrev">#</a> Abbreviations</h3>
<p>Fish-style abbreviations: type the abbrev + space, the full command expands inline.</p>
<pre><code>abbr gco='git checkout'
abbr -g G='| grep'</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-pcre">
<h2>PCRE & Regex</h2>
<p class="chapter-meta">4 topics · zsh/pcre module support; the <code>=~</code> operator inside <code>[[ … ]]</code> uses PCRE2.</p>
<article class="doc-entry" id="doc-pcre-compile">
<h3><a class="doc-anchor" href="#doc-pcre-compile">#</a> <code>pcre_compile pattern</code></h3>
<p>Compile a PCRE pattern; bound to <code>$ZPCRE_OP</code>.</p>
<pre><code>pcre_compile '^(\d+)\s+(\w+)$'</code></pre>
</article>
<article class="doc-entry" id="doc-pcre-match">
<h3><a class="doc-anchor" href="#doc-pcre-match">#</a> <code>pcre_match string</code></h3>
<p>Match against the most-recently compiled pattern. Captures land in <code>$match</code>, <code>$mbegin</code>, <code>$mend</code>.</p>
<pre><code>pcre_compile '(\w+)@(\w+\.\w+)'
if pcre_match "alice@example.com"; then
echo "user: ${match[1]}, domain: ${match[2]}"
fi</code></pre>
</article>
<article class="doc-entry" id="doc-pcre-study">
<h3><a class="doc-anchor" href="#doc-pcre-study">#</a> <code>pcre_study</code></h3>
<p>Optimize the compiled pattern for repeated use.</p>
<pre><code>pcre_compile '\b\d{4}-\d{2}-\d{2}\b'
pcre_study</code></pre>
</article>
<article class="doc-entry" id="doc-regex-tilde">
<h3><a class="doc-anchor" href="#doc-regex-tilde">#</a> <code>[[ string =~ pattern ]]</code></h3>
<p>POSIX/PCRE regex match inside the conditional.</p>
<pre><code>if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
major=${match[1]}; minor=${match[2]}; patch=${match[3]}
fi</code></pre>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-compat">
<h2>Compat Builtin Index</h2>
<p class="chapter-meta">157 entries</p>
<article class="doc-entry" id="doc-lsp-compat-dash">
<h3><code>-</code> <a class="doc-anchor" href="#doc-lsp-compat-dash">¶</a></h3>
<p>The command is executed with a "-" prepended to its <code>argv[0]</code> string.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-dot">
<h3><code>.</code> <a class="doc-anchor" href="#doc-lsp-compat-dot">¶</a></h3>
<p>Read commands from <em>file</em> and execute them in the current shell environment.</p>
<p>If <em>file</em> does not contain a slash, or if <code>PATH_DIRS</code> is set, the shell looks in the components of <code>$path</code> to find the directory containing <em>file</em>. Files in the current directory are not read unless "." appears somewhere in <code>$path</code>. If a file named <code>_file_</code>.zwc<code>' is found, is newer than _file_, and is the compiled form (created with the </code>zcompile<code> builtin) of _file_, then commands are read from that file instead of _file_.</code></p>
<p>If any arguments <em>arg</em> are given, they become the positional parameters; the old positional parameters are restored when the <em>file</em> is done executing. However, if no arguments are given, the positional parameters remain those of the calling context, and no restoring is done.</p>
<p>If <em>file</em> was not found the return status is 127; if <em>file</em> was found but contained a syntax error the return status is 126; else the return status is the exit status of the last command executed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-colon">
<h3><code>:</code> <a class="doc-anchor" href="#doc-lsp-compat-colon">¶</a></h3>
<p>Null command. Returns true. Side-effects of argument expansion still happen.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-lbracket">
<h3><code>[</code> <a class="doc-anchor" href="#doc-lsp-compat-lbracket">¶</a></h3>
<p>POSIX <code>test</code> command (also spelled <code>test</code>). Same conditional semantics as POSIX <code>test</code>. Prefer <code>[[ … ]]</code> in zsh — it's safer (no word splitting) and supports more operators.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-alias">
<h3><code>alias</code> <a class="doc-anchor" href="#doc-lsp-compat-alias">¶</a></h3>
<p>For each <em>name</em> with a corresponding <em>value</em>, define an alias with that value. A trailing space in <em>value</em> causes the next word to be checked for alias expansion. If the <code>-g</code> flag is present, define a global alias; global aliases are expanded even if they do not occur in command position:</p>
<p> % perldoc --help 2>&1 | grep 'built-in functions' -f Search Perl built-in functions % alias -g HG='--help 2>&1 | grep' % perldoc HG 'built-in functions' -f Search Perl built-in functions</p>
<p>If the <code>-s</code> flag is present, define a suffix alias: if the command word on a command line is in the form <code>_text_</code>."<em>name</em>", where <em>text</em> is any non-empty string, it is replaced by the text <code>_value_ _text_</code>."<em>name</em>". Note that <em>name</em> is treated as a literal string, not a pattern. A trailing space in <em>value</em> is not special in this case. For example,</p>
<p> alias -s ps='gv --'</p>
<p>will cause the command "*.ps" to be expanded to "gv -- *.ps". As alias expansion is carried out earlier than globbing, the "*.ps" will then be expanded. Suffix aliases constitute a different name space from other aliases (so in the above example it is still possible to create an alias for the command <code>ps</code>) and the two sets are never listed together.</p>
<p>For each <em>name</em> with no <em>value</em>, print the value of <em>name</em>, if any. With no arguments, print all currently defined aliases other than suffix aliases. If the <code>-m</code> flag is given the arguments are taken as patterns (they should be quoted to preserve them from being interpreted as glob patterns), and the aliases matching these patterns are printed. When printing aliases and one of the <code>-g</code>, <code>-r</code> or <code>-s</code> flags is present, restrict the printing to global, regular or suffix aliases, respectively; a regular alias is one which is neither a global nor a suffix alias. Using "+" instead of "-", or ending the option list with a single "+", prevents the values of the aliases from being printed.</p>
<p>If the <code>-L</code> flag is present, then print each alias in a manner suitable for putting in a startup script. The exit status is nonzero if a <em>name</em> (with no <em>value</em>) is given for which no alias has been defined.</p>
<p>For more on aliases, including common problems, see <em>Aliasing</em> (zshmisc).</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-autoload">
<h3><code>autoload</code> <a class="doc-anchor" href="#doc-lsp-compat-autoload">¶</a></h3>
<p>vindex(fpath, searching) See <em>Autoloading Functions</em> (zshmisc) for full details. The <code>fpath</code> parameter will be searched to find the function definition when the function is first referenced.</p>
<p>If <em>name</em> consists of an absolute path, the function is defined to load from the file given (searching as usual for dump files in the given location). The name of the function is the basename (non-directory part) of the file. It is normally an error if the function is not found in the given location; however, if the option <code>-d</code> is given, searching for the function defaults to <code>$fpath</code>. If a function is loaded by absolute path, any functions loaded from it that are marked for <code>autoload</code> without an absolute path have the load path of the parent function temporarily prepended to <code>$fpath</code>.</p>
<p>If the option <code>-r</code> or <code>-R</code> is given, the function is searched for immediately and the location is recorded internally for use when the function is executed; a relative path is expanded using the value of <code>$PWD</code>. This protects against a change to <code>$fpath</code> after the call to <code>autoload</code>. With <code>-r</code>, if the function is not found, it is silently left unresolved until execution; with <code>-R</code>, an error message is printed and command processing aborted immediately the search fails, i.e. at the <code>autoload</code> command rather than at function execution..</p>
<p>The flag <code>-X</code> may be used only inside a shell function. It 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. If an argument is given, it is used as a directory (i.e. it does not include the name of the function) in which the function is to be found; this may be combined with the <code>-d</code> option to allow the function search to default to <code>$fpath</code> if it is not in the given location.</p>
<p>The flag <code>+X</code> attempts to load each <em>name</em> as an autoloaded function, but does <em>not</em> execute it. The exit status is zero (success) if the function was not previously defined <em>and</em> a definition for it was found. This does <em>not</em> 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, thus giving normal ksh autoloading behaviour on the first call to the function. If the <code>-m</code> flag is also given each <em>name</em> is treated as a pattern and all functions already marked for autoload that match the pattern are loaded.</p>
<p>With the <code>-t</code> flag, turn on execution tracing; with <code>-T</code>, turn on execution tracing only for the current function, turning it off on entry to any called functions that do not also have tracing enabled.</p>
<p>With the <code>-U</code> flag, alias expansion is suppressed when the function is loaded.</p>
<p>With the <code>-w</code> flag, the _name_s are taken as names of files compiled with the <code>zcompile</code> builtin, and all functions defined in them are marked for autoloading.</p>
<p>The flags <code>-z</code> and <code>-k</code> mark the function to be autoloaded using the zsh or ksh style, as if the option <code>KSH_AUTOLOAD</code> were unset or were set, respectively. The flags override the setting of the option at the time the function is loaded.</p>
<p>Note that the <code>autoload</code> command makes no attempt to ensure the shell options set during the loading or execution of the file have any particular value. For this, the <code>emulate</code> command can be used:</p>
<p> emulate zsh -c 'autoload -Uz <em>func</em>'</p>
<p>arranges that when <em>func</em> is loaded the shell is in native <code>zsh</code> emulation, and this emulation is also applied when <em>func</em> is run.</p>
<p>Some of the functions of <code>autoload</code> are also provided by <code>functions -u</code> or <code>functions -U</code>, but <code>autoload</code> is a more comprehensive interface.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-bg">
<h3><code>bg</code> <a class="doc-anchor" href="#doc-lsp-compat-bg">¶</a></h3>
<p>Put each specified <em>job</em> in the background, or the current job if none is specified.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-bindkey">
<h3><code>bindkey</code> <a class="doc-anchor" href="#doc-lsp-compat-bindkey">¶</a></h3>
<p><code>bindkey</code>'s options can be divided into three categories: keymap selection for the current command, operation selection, and others. The keymap selection options are:</p>
<p>- <strong><code>-e</code></strong> — Selects keymap "emacs" for any operations by the current command, and also links "emacs" to "main" so that it is selected by default the next time the editor starts.</p>
<p>- <strong><code>-v</code></strong> — Selects keymap "viins" for any operations by the current command, and also links "viins" to "main" so that it is selected by default the next time the editor starts.</p>
<p>- <strong><code>-a</code></strong> — Selects keymap "vicmd" for any operations by the current command.</p>
<p>- <strong><code>-M</code> <em>keymap</em></strong> — The <em>keymap</em> specifies a keymap name that is selected for any operations by the current command.</p>
<p>If a keymap selection is required and none of the options above are used, the "main" keymap is used. Some operations do not permit a keymap to be selected, namely:</p>
<p>- <strong><code>-l</code></strong> — List all existing keymap names; if any arguments are given, list just those keymaps.</p>
<p>If the <code>-L</code> option is also used, list in the form of <code>bindkey</code> commands to create or link the keymaps. <code></code>bindkey -lL main<code>' shows which keymap is linked to "main", if any, and hence if the standard emacs or vi emulation is in effect. This option does not show the </code>.safe<code> keymap because it cannot be created in that fashion; however, neither is "bindkey -lL .safe" reported as an error, it simply outputs nothing.</code></p>
<p>- <strong><code>-d</code></strong> — Delete all existing keymaps and reset to the default state.</p>
<p>- <strong><code>-D</code> <em>keymap</em> ...</strong> — Delete the named _keymap_s.</p>
<p>- <strong><code>-A</code> <em>old-keymap new-keymap</em></strong> — Make the <em>new-keymap</em> name an alias for <em>old-keymap</em>, so that both names refer to the same keymap. The names have equal standing; if either is deleted, the other remains. If there is already a keymap with the <em>new-keymap</em> name, it is deleted.</p>
<p>- <strong><code>-N</code> <em>new-keymap</em> [ <em>old-keymap</em> ]</strong> — Create a new keymap, named <em>new-keymap</em>. If a keymap already has that name, it is deleted. If an <em>old-keymap</em> name is given, the new keymap is initialized to be a duplicate of it, otherwise the new keymap will be empty.</p>
<p>To use a newly created keymap, it should be linked to <code>main</code>. Hence the sequence of commands to create and use a new keymap "mymap" initialized from the <code>emacs</code> keymap (which remains unchanged) is:</p>
<p> bindkey -N mymap emacs bindkey -A mymap main</p>
<p>Note that while <code></code>bindkey -A<code> _newmap_ </code>main<code>' will work when _newmap_ is </code>emacs<code> or </code>viins<code>, it will not work for </code>vicmd<code>, as switching from vi insert to command mode becomes impossible.</code></p>
<p>The following operations act on the "main" keymap if no keymap selection option was given:</p>
<p>- <strong><code>-m</code></strong> — Add the built-in set of meta-key bindings to the selected keymap. Only keys that are unbound or bound to <code>self-insert</code> are affected.</p>
<p>- <strong><code>-r</code> <em>in-string</em> ...</strong> — Unbind the specified _in-string_s in the selected keymap. This is exactly equivalent to binding the strings to <code>undefined-key</code>.</p>
<p>When <code>-R</code> is also used, interpret the _in-string_s as ranges.</p>
<p>When <code>-p</code> is also used, the _in-string_s specify prefixes. Any binding that has the given <em>in-string</em> as a prefix, not including the binding for the <em>in-string</em> itself, if any, will be removed. For example,</p>
<p> bindkey -rpM viins '^['</p>
<p>will remove all bindings in the vi-insert keymap beginning with an escape character (probably cursor keys), but leave the binding for the escape character itself (probably <code>vi-cmd-mode</code>). This is incompatible with the option <code>-R</code>.</p>
<p>- <strong><code>-s</code> <em>in-string out-string</em> ...</strong> — Bind each <em>in-string</em> to each <em>out-string</em>. When <em>in-string</em> is typed, <em>out-string</em> will be pushed back and treated as input to the line editor. When <code>-R</code> is also used, interpret the _in-string_s as ranges.</p>
<p>Note that both <em>in-string</em> and <em>out-string</em> are subject to the same form of interpretation, as described below.</p>
<p>- <strong><em>in-string command</em> ...</strong> — Bind each <em>in-string</em> to each <em>command</em>. When <code>-R</code> is used, interpret the _in-string_s as ranges.</p>
<p>- <strong>[ <em>in-string</em> ]</strong> — List key bindings. If an <em>in-string</em> is specified, the binding of that string in the selected keymap is displayed. Otherwise, all key bindings in the selected keymap are displayed. (As a special case, if the <code>-e</code> or <code>-v</code> option is used alone, the keymap is <em>not</em> displayed - the implicit linking of keymaps is the only thing that happens.)</p>
<p>When the option <code>-p</code> is used, the <em>in-string</em> must be present. The listing shows all bindings which have the given key sequence as a prefix, not including any bindings for the key sequence itself.</p>
<p>When the <code>-L</code> option is used, the list is in the form of <code>bindkey</code> commands to create the key bindings.</p>
<p>When the <code>-R</code> option is used as noted above, a valid range consists of two characters, with an optional "-" between them. All characters between the two specified, inclusive, are bound as specified.</p>
<p>For either <em>in-string</em> or <em>out-string</em>, the following escape sequences are recognised:</p>
<p>- <code>\a</code> — bell character - <code>\b</code> — backspace - <code>\e</code>, <code>\E</code> — escape - <code>\f</code> — form feed</p>
<p>- <strong><code>\n</code></strong> — linefeed (newline)</p>
<p>- <code>\r</code> — carriage return - <code>\t</code> — horizontal tab - <code>\v</code> — vertical tab - <code>\</code><em>NNN</em> — character code in octal - <code>\x</code><em>NN</em> — character code in hexadecimal - <code>\u</code><em>NNNN</em> — unicode character code in hexadecimal - <code>\U</code><em>NNNNNNNN</em> — unicode character code in hexadecimal - <code>\M</code>[<code>-</code>]<em>X</em> — character with meta bit set - <code>\C</code>[<code>-</code>]<em>X</em> — control character - <code>^</code><em>X</em> — control character</p>
<p>In all other cases, "\" escapes the following character. Delete is written as "^?". Note that "\M^?" and "^\M?" are not the same, and that (unlike emacs), the bindings <code></code>\M-"<em>X</em>" and <code></code>\e"<em>X</em>" are entirely distinct, although they are initialized to the same bindings by "bindkey -m".</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-break">
<h3><code>break</code> <a class="doc-anchor" href="#doc-lsp-compat-break">¶</a></h3>
<p>Exit from an enclosing <code>for</code>, <code>while</code>, <code>until</code>, <code>select</code> or <code>repeat</code> loop. If an arithmetic expression <em>n</em> is specified, then break <em>n</em> levels instead of just one.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-builtin">
<h3><code>builtin</code> <a class="doc-anchor" href="#doc-lsp-compat-builtin">¶</a></h3>
<p>The command word is taken to be the name of a builtin command, rather than a shell function or external command.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-bye">
<h3><code>bye</code> <a class="doc-anchor" href="#doc-lsp-compat-bye">¶</a></h3>
<p>Alias for <code>exit</code>. Exit the shell with the given status.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-cap">
<h3><code>cap</code> <a class="doc-anchor" href="#doc-lsp-compat-cap">¶</a></h3>
<p>Change the shell's process capability sets to the specified <em>capabilities</em>, otherwise display the shell's current capabilities.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-cd">
<h3><code>cd</code> <a class="doc-anchor" href="#doc-lsp-compat-cd">¶</a></h3>
<p>Change the current directory. In the first form, change the current directory to <em>arg</em>, or to the value of <code>$HOME</code> if <em>arg</em> is not specified. If <em>arg</em> is "-", change to the previous directory.</p>
<p>Otherwise, if <em>arg</em> begins with a slash, attempt to change to the directory given by <em>arg</em>.</p>
<p>If <em>arg</em> does not begin with a slash, the behaviour depends on whether the current directory "." occurs in the list of directories contained in the shell parameter <code>cdpath</code>. If it does not, first attempt to change to the directory <em>arg</em> under the current directory, and if that fails but <code>cdpath</code> is set and contains at least one element attempt to change to the directory <em>arg</em> under each component of <code>cdpath</code> in turn until successful. If "." occurs in <code>cdpath</code>, then <code>cdpath</code> is searched strictly in order so that "." is only tried at the appropriate point.</p>
<p>The order of testing <code>cdpath</code> is modified if the option <code>POSIX_CD</code> is set, as described in the documentation for the option.</p>
<p>If no directory is found, the option <code>CDABLE_VARS</code> is set, and a parameter named <em>arg</em> exists whose value begins with a slash, treat its value as the directory. In that case, the parameter is added to the named directory hash table.</p>
<p>The second form of <code>cd</code> substitutes the string <em>new</em> for the string <em>old</em> in the name of the current directory, and tries to change to this new directory.</p>
<p>The third form of <code>cd</code> extracts an entry from the directory stack, and changes to that directory. An argument of the form <code></code>+"<em>n</em>" identifies a stack entry by counting from the left of the list shown by the <code>dirs</code> command, starting with zero. An argument of the form <code></code>-"<em>n</em>" counts from the right. If the <code>PUSHD_MINUS</code> option is set, the meanings of "+" and "-" in this context are swapped. If the <code>POSIX_CD</code> option is set, this form of <code>cd</code> is not recognised and will be interpreted as the first form.</p>
<p>If the <code>-q</code> (quiet) option is specified, the hook function <code>chpwd</code> and the functions in the array <code>chpwd_functions</code> are not called. This is useful for calls to <code>cd</code> that do not change the environment seen by an interactive user.</p>
<p>If the <code>-s</code> option is specified, <code>cd</code> refuses to change the current directory if the given pathname contains symlinks. If the <code>-P</code> option is given or the <code>CHASE_LINKS</code> option is set, symbolic links are resolved to their true values. If the <code>-L</code> option is given symbolic links are retained in the directory (and not resolved) regardless of the state of the <code>CHASE_LINKS</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-chdir">
<h3><code>chdir</code> <a class="doc-anchor" href="#doc-lsp-compat-chdir">¶</a></h3>
<p>Alias for <code>cd</code>. Change the working directory.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-chgrp">
<h3><code>chgrp</code> <a class="doc-anchor" href="#doc-lsp-compat-chgrp">¶</a></h3>
<p>Changes group of files specified. This is equivalent to <code>chown</code> with a <em>user-spec</em> argument of <code></code>:"<em>group</em>".</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-chmod">
<h3><code>chmod</code> <a class="doc-anchor" href="#doc-lsp-compat-chmod">¶</a></h3>
<p>Changes mode of files specified.</p>
<p>The specified <em>mode</em> must be in octal.</p>
<p>The <code>-R</code> option causes <code>chmod</code> to recursively descend into directories, changing the mode of all files in the directory after changing the mode of the directory itself.</p>
<p>The <code>-s</code> option is a zsh extension to <code>chmod</code> functionality. It enables paranoid behaviour, intended to avoid security problems involving a <code>chmod</code> being tricked into affecting files other than the ones intended. It will refuse to follow symbolic links, so that (for example) ""chmod 600 /tmp/foo/passwd"" can't accidentally chmod <code>/etc/passwd</code> if <code>/tmp/foo</code> happens to be a link to <code>/etc</code>. It will also check where it is after leaving directories, so that a recursive chmod of a deep directory tree can't end up recursively chmoding <code>/usr</code> as a result of directories being moved up the tree.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-chown">
<h3><code>chown</code> <a class="doc-anchor" href="#doc-lsp-compat-chown">¶</a></h3>
<p>Changes ownership and group of files specified.</p>
<p>The <em>user-spec</em> can be in four forms:</p>
<p>- <em>user</em> — change owner to <em>user</em>; do not change group - <em>user</em><code>::</code> — change owner to <em>user</em>; do not change group - <em>user</em><code>:" — change owner to _user_; change group to _user_"s primary group - _user_</code>:<code>_group_ — change owner to _user_; change group to _group_ - </code>:<code>_group_ — do not change owner; change group to _group_</code></p>
<p>In each case, the ":" may instead be a ".". The rule is that if there is a ":" then the separator is ":", otherwise if there is a "." then the separator is ".", otherwise there is no separator.</p>
<p>Each of <em>user</em> and <em>group</em> may be either a username (or group name, as appropriate) or a decimal user ID (group ID). Interpretation as a name takes precedence, if there is an all-numeric username (or group name).</p>
<p>If the target is a symbolic link, the <code>-h</code> option causes <code>chown</code> to set the ownership of the link instead of its target.</p>
<p>The <code>-R</code> option causes <code>chown</code> to recursively descend into directories, changing the ownership of all files in the directory after changing the ownership of the directory itself.</p>
<p>The <code>-s</code> option is a zsh extension to <code>chown</code> functionality. It enables paranoid behaviour, intended to avoid security problems involving a <code>chown</code> being tricked into affecting files other than the ones intended. It will refuse to follow symbolic links, so that (for example) ""chown luser /tmp/foo/passwd"" can't accidentally chown <code>/etc/passwd</code> if <code>/tmp/foo</code> happens to be a link to <code>/etc</code>. It will also check where it is after leaving directories, so that a recursive chown of a deep directory tree can't end up recursively chowning <code>/usr</code> as a result of directories being moved up the tree.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-clone">
<h3><code>clone</code> <a class="doc-anchor" href="#doc-lsp-compat-clone">¶</a></h3>
<p>Creates a forked instance of the current shell, attached to the specified <em>tty</em>. In the new shell, the <code>PID</code>, <code>PPID</code> and <code>TTY</code> special parameters are changed appropriately. <code>$!</code> is set to zero in the new shell, and to the new shell's PID in the original shell.</p>
<p>The return status of the builtin is zero in both shells if successful, and non-zero on error.</p>
<p>The target of <code>clone</code> should be an unused terminal, such as an unused virtual console or a virtual terminal created by</p>
<p> xterm -e sh -c 'trap : INT QUIT TSTP; tty; while :; do sleep 100000000; done'</p>
<p>Some words of explanation are warranted about this long xterm command line: when doing clone on a pseudo-terminal, some other session ("session" meant as a unix session group, or SID) is already owning the terminal. Hence the cloned zsh cannot acquire the pseudo-terminal as a controlling tty. That means two things:</p>
<p>startitemize() itemiz(the job control signals will go to the sh-started-by-xterm process group (that's why we disable INT QUIT and TSTP with trap; otherwise the while loop could get suspended or killed)) itemiz(the cloned shell will have job control disabled, and the job control keys (control-C, control-\ and control-Z) will not work.) enditemize()</p>
<p>This does not apply when cloning to an <em>unused</em> vc.</p>
<p>Cloning to a used (and unprepared) terminal will result in two processes reading simultaneously from the same terminal, with input bytes going randomly to either process.</p>
<p><code>clone</code> is mostly useful as a shell built-in replacement for openvt.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-command">
<h3><code>command</code> <a class="doc-anchor" href="#doc-lsp-compat-command">¶</a></h3>
<p>The command word is taken to be the name of an external command, rather than a shell function or builtin. If the <code>POSIX_BUILTINS</code> option is set, builtins will also be executed but certain special properties of them are suppressed. The <code>-p</code> flag causes a default path to be searched instead of that in <code>$path</code>. With the <code>-v</code> flag, <code>command</code> is similar to <code>whence</code> and with <code>-V</code>, it is equivalent to <code>whence -v</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compadd">
<h3><code>compadd</code> <a class="doc-anchor" href="#doc-lsp-compat-compadd">¶</a></h3>
<p>This builtin command can be used to add matches directly and control all the information the completion code stores with each possible completion. The return status is zero if at least one match was added and non-zero if no matches were added.</p>
<p>The completion code breaks each match into seven fields in the order:</p>
<p> <em><ipre><apre><hpre><body><hsuf><asuf><isuf></em></p>
<p>The first field is an ignored prefix taken from the command line, the contents of the <code>IPREFIX</code> parameter plus the string given with the <code>-i</code> option. With the <code>-U</code> option, only the string from the <code>-i</code> option is used. The field <em><apre></em> is an optional prefix string given with the <code>-P</code> option. The <em><hpre></em> field is a string that is considered part of the match but that should not be shown when listing completions, given with the <code>-p</code> option; for example, functions that do filename generation might specify a common path prefix this way. <em><body></em> is the part of the match that should appear in the list of matches shown to the user. The suffixes <em><hsuf></em>, <em><asuf></em> and <em><isuf></em> correspond to the prefixes <em><hpre></em>, <em><apre></em> and <em><ipre></em> and are given by the options <code>-s</code>, <code>-S</code> and <code>-I</code>, respectively.</p>
<p>The supported flags are:</p>
<p>- <strong><code>-P</code> <em>prefix</em></strong> — This gives a string to be inserted before each match. The string given is not considered as part of the match and any shell metacharacters in it will not be quoted when the string is inserted.</p>
<p>- <strong><code>-S</code> <em>suffix</em></strong> — Like <code>-P</code>, but gives a string to be inserted after each match.</p>
<p>- <strong><code>-p</code> <em>hidden-prefix</em></strong> — This gives a string that should be inserted before each match but that should not appear in the list of matches. Unless the <code>-U</code> option is given, this string must be matched as part of the string on the command line.</p>
<p>- <strong><code>-s</code> <em>hidden-suffix</em></strong> — Like "-p", but gives a string to insert after each match.</p>
<p>- <strong><code>-i</code> <em>ignored-prefix</em></strong> — This gives a string to insert just before any string given with the "-P" option. Without "-P" the string is inserted before the string given with "-p" or directly before each match.</p>
<p>- <strong><code>-I</code> <em>ignored-suffix</em></strong> — Like <code>-i</code>, but gives an ignored suffix.</p>
<p>- <strong><code>-a</code></strong> — With this flag the <em>completions</em> are taken as names of arrays and the actual completions are their values. If only some elements of the arrays are needed, the <em>completions</em> may also contain subscripts, as in "foo[2,-1]".</p>
<p>- <strong><code>-k</code></strong> — With this flag the <em>completions</em> are taken as names of associative arrays and the actual completions are their keys. As for <code>-a</code>, the <em>words</em> may also contain subscripts, as in "tt(foo[(R)*bar*])".</p>
<p>- <strong><code>-d</code> <em>array</em></strong> — This adds per-completion display strings. The <em>array</em> should contain one element per <em>completion</em> given. The completion code will then display the first element instead of the first <em>completion</em>, and so on. The <em>array</em> may be given as the name of an array parameter or directly as a space-separated list of words in parentheses.</p>
<p>If there are fewer display strings than <em>completions</em>, the leftover <em>completions</em> will be displayed unchanged and if there are more display strings than <em>completions</em>, the leftover display strings will be silently ignored.</p>
<p>- <strong><code>-l</code></strong> — This option only has an effect if used together with the <code>-d</code> option. If it is given, the display strings are listed one per line, not arrayed in columns.</p>
<p>- <strong><code>-o</code> [ <em>order</em> ]</strong> — This controls the order in which matches are sorted. <em>order</em> is a comma-separated list comprising the following possible values. These values can be abbreviated to their initial two or three characters. Note that the order forms part of the group name space so matches with different orderings will not be in the same group; additionally, since ordering flags are not respected on the default group, a group name must be given explicitly. See <code>-J</code> and <code>-V</code> below.</p>
<p>- <strong><code>match</code></strong> — If given, the order of the output is determined by the match strings; otherwise it is determined by the display strings (i.e. the strings given by the <code>-d</code> option). This is the default if "-o" is specified but the <em>order</em> argument is omitted.</p>
<p>- <strong><code>nosort</code></strong> — This specifies that the <em>completions</em> are pre-sorted and their order should be preserved. This value only makes sense alone and cannot be combined with any others.</p>
<p>- <strong><code>numeric</code></strong> — If the matches include numbers, sort them numerically rather than lexicographically.</p>
<p>- <strong><code>reverse</code></strong> — Arrange the matches backwards by reversing the sort ordering.</p>
<p>- <strong><code>-J</code> <em>group-name</em></strong> — Gives the name of the group that the matches should be stored in.</p>
<p>- <strong><code>-V</code> <em>group-name</em></strong> — Like <code>-J</code> but naming an unsorted group. This option is identical to the combination of <code>-J</code> and <code>-o nosort</code>.</p>
<p>- <strong><code>-1</code></strong> — If given together with the <code>-V</code> option, makes only consecutive duplicates in the group be removed. If combined with the <code>-J</code> option, this has no visible effect. Note that groups with and without this flag are in different name spaces.</p>
<p>- <strong><code>-2</code></strong> — If given together with the <code>-J</code> or <code>-V</code> option, makes all duplicates be kept. Again, groups with and without this flag are in different name spaces.</p>
<p>- <strong><code>-X</code> <em>explanation</em></strong> — The <em>explanation</em> string will be printed with the list of matches, above the group currently selected.</p>
<p>Within the <em>explanation</em>, the following sequences may be used to specify output attributes as described in <em>Expansion of Prompt Sequences</em> (zshmisc): "%B", "%S", "%U", "%F", "%K" and their lower case counterparts, as well as "%H" and <code></code>%{<code>...</code>%}<code>'. "%F", "%K", "%H" and </code><code>%{</code>...<code>%}</code>' take arguments in the same form as prompt expansion. (Note that the sequence "%G" is not available; an argument to "%{" should be used instead.) The sequence "%%" produces a literal "%".</p>
<p>These sequences are most often employed by users when customising the <code>format</code> style (see subref(Standard Styles)(zshcompsys)), but they must also be taken into account when writing completion functions, as passing descriptions with unescaped "%" characters to utility functions such as <code>_arguments</code> and <code>_message</code> may produce unexpected results. If arbitrary text is to be passed in a description, it can be escaped using e.g. <code>${my_str//\%/%%}</code>.</p>
<p>- <strong><code>-x</code> <em>message</em></strong> — Like <code>-X</code>, but the <em>message</em> will be printed even if there are no matches in the group.</p>
<p>- <strong><code>-q</code></strong> — The suffix given with <code>-S</code> will be automatically removed if the next character typed is a blank or does not insert anything, or if the suffix consists of only one character and the next character typed is the same character.</p>
<p>- <strong><code>-r</code> <em>remove-chars</em></strong> — This is a more versatile form of the <code>-q</code> option. The suffix given with <code>-S</code> or the slash automatically added after completing directories will be automatically removed if the next character typed inserts one of the characters given in the <em>remove-chars</em>. This string is parsed as a characters class and understands the backslash sequences used by the <code>print</code> command. For example, "-r "a-z\t"" removes the suffix if the next character typed inserts a lower case character or a TAB, and "-r "^0-9"" removes the suffix if the next character typed inserts anything but a digit. One extra backslash sequence is understood in this string: "\-" stands for all characters that insert nothing. Thus "-S "=" -q" is the same as "-S "=" -r "= \t\n\-"".</p>
<p>This option may also be used without the <code>-S</code> option; then any automatically added space will be removed when one of the characters in the list is typed.</p>
<p>- <strong><code>-R</code> <em>remove-func</em></strong> — This is another form of the <code>-r</code> option. When a match has been accepted and a suffix has been inserted, the function <em>remove-func</em> will be called after the next character typed. It is passed the length of the suffix as an argument and can use the special parameters available in ordinary (non-completion) zle widgets (see <em>User-Defined Widgets</em> (zshzle) ) to analyse and modify the command line.</p>
<p>- <strong><code>-f</code></strong> — If this flag is given, all of the matches built from the <em>completions</em> are marked as being the names of files. They are not required to be actual filenames, but if they are, and the option <code>LIST_TYPES</code> is set, the characters describing the types of the files in the completion lists will be shown. This also forces a slash to be added when the name of a directory is completed.</p>
<p>- <strong><code>-e</code></strong> — This flag can be used to tell the completion code that the matches added are parameter names for a parameter expansion. This will make the <code>AUTO_PARAM_SLASH</code> and <code>AUTO_PARAM_KEYS</code> options be used for the matches.</p>
<p>- <strong><code>-W</code> <em>file-prefix</em></strong> — This string is a pathname that will be prepended to each match together with any prefix specified by the <code>-p</code> option to form a complete filename for testing. Hence it is only useful if combined with the <code>-f</code> flag, as the tests will not otherwise be performed.</p>
<p>- <strong><code>-F</code> <em>array</em></strong> — Specifies an array containing patterns. <em>completions</em> that match one of these patterns are ignored, that is, not considered to be matches.</p>
<p>The <em>array</em> may be the name of an array parameter or a list of literal patterns enclosed in parentheses and quoted, as in <code>tt(-F "(*?.o *?.h)")'. If the name of an array is given, the elements of the array are taken as the patterns. )</code></p>
<p>- <strong><code>-Q</code></strong> — This flag instructs the completion code not to quote any metacharacters in the matches when inserting them into the command line.</p>
<p>- <strong><code>-M</code> <em>match-spec</em></strong> — This gives local match specifications as described below in (Completion Matching Control). This option may be given more than once. In this case all _match-spec_s given are concatenated with spaces between them to form the specification string to use. Note that they will only be used if the <code>-U</code> option is not given.</p>
<p>- <strong><code>-n</code></strong> — Specifies that matching <em>completions</em> are to be added to the set of matches, but are not to be listed to the user.</p>
<p>- <strong><code>-U</code></strong> — If this flag is given, all <em>completions</em> are added to the set of matches and no matching will be done by the completion code. Normally this is used in functions that do the matching themselves.</p>
<p>- <strong><code>-O</code> <em>array</em></strong> — If this option is given, the <em>completions</em> are <em>not</em> added to the set of matches. Instead, matching is done as usual and all of the <em>completions</em> that match will be stored in the array parameter whose name is given as <em>array</em>.</p>
<p>- <strong><code>-A</code> <em>array</em></strong> — As the <code>-O</code> option, except that instead of those of the <em>completions</em> which match being stored in <em>array</em>, the strings generated internally by the completion code are stored. For example, with a match specification of "-M "L:|no="", a current word of "nof" and <em>completions</em> of "foo", this option stores the string "nofoo" in the array, whereas the <code>-O</code> option stores the "foo" originally given.</p>
<p>- <strong><code>-D</code> <em>array</em></strong> — As with <code>-O</code>, the <em>completions</em> are not added to the set of matches. Instead, whenever the _n_th <em>completion</em> does not match, the _n_th element of the <em>array</em> is removed. Elements for which the corresponding <em>completion</em> matches are retained. This option can be used more than once to remove elements from multiple arrays.</p>
<p>- <strong><code>-C</code></strong> — This option adds a special match which expands to all other matches when inserted into the line, even those that are added after this option is used. Together with the <code>-d</code> option it is possible to specify a string that should be displayed in the list for this special match. If no string is given, it will be shown as a string containing the strings that would be inserted for the other matches, truncated to the width of the screen.</p>
<p>- <strong><code>-E</code> <em>number</em></strong> — This option adds <em>number</em> empty matches after matching <em>completions</em> have been added. An empty match takes up space in completion listings but will never be inserted in the line and can't be selected with menu completion or menu selection. This makes empty matches only useful to format completion lists and to make explanatory string be shown in completion lists (since empty matches can be given display strings with the <code>-d</code> option). And because all but one empty string would otherwise be removed, this option implies the <code>-V</code> and <code>-2</code> options (even if an explicit <code>-J</code> option is given). This can be important to note as it affects the name space into which matches are added.</p>
<p>- <strong><code>-</code></strong></p>
<p>- <strong><code>-</code><code>-</code></strong> — This flag ends the list of flags and options. All arguments after it will be taken as the <em>completions</em> even if they begin with hyphens.</p>
<p>Except for the <code>-M</code> flag, if any of these flags is given more than once, the first one (and its argument) will be used.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-comparguments">
<h3><code>comparguments</code> <a class="doc-anchor" href="#doc-lsp-compat-comparguments">¶</a></h3>
<p>This is used by the <code>_arguments</code> function to do the argument and command line parsing. Like <code>compdescribe</code> it has an option <code>-i</code> to do the parsing and initialize some internal state and various options to access the state information to decide what should be completed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compcall">
<h3><code>compcall</code> <a class="doc-anchor" href="#doc-lsp-compat-compcall">¶</a></h3>
<p>This allows the use of completions defined with the <code>compctl</code> builtin from within completion widgets. The list of matches will be generated as if one of the non-widget completion functions (<code>complete-word</code>, etc.) had been called, except that only <code>compctl</code>s given for specific commands are used. To force the code to try completions defined with the <code>-T</code> option of <code>compctl</code> and/or the default completion (whether defined by <code>compctl -D</code> or the builtin default) in the appropriate places, the <code>-T</code> and/or <code>-D</code> flags can be passed to <code>compcall</code>.</p>
<p>The return status can be used to test if a matching <code>compctl</code> definition was found. It is non-zero if a <code>compctl</code> was found and zero otherwise.</p>
<p>Note that this builtin is defined by the <code>zsh/compctl</code> module.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compctl">
<h3><code>compctl</code> <a class="doc-anchor" href="#doc-lsp-compat-compctl">¶</a></h3>
<p>Old completion control (compctl mechanism). Largely superseded by <code>compdef</code> / compsys.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compdescribe">
<h3><code>compdescribe</code> <a class="doc-anchor" href="#doc-lsp-compat-compdescribe">¶</a></h3>
<p>This is used by the <code>_describe</code> function to build the displays for the matches and to get the strings to add as matches with their options. On the first call one of the options <code>-i</code> or <code>-I</code> should be supplied as the first argument. In the first case, display strings without the descriptions will be generated, in the second case, the string used to separate the matches from their descriptions must be given as the second argument and the descriptions (if any) will be shown. All other arguments are like the definition arguments to <code>_describe</code> itself.</p>
<p>Once <code>compdescribe</code> has been called with either the <code>-i</code> or the <code>-I</code> option, it can be repeatedly called with the <code>-g</code> option and the names of four parameters as its arguments. This will step through the different sets of matches and store the value of <code>compstate[list]</code> in the first scalar, the options for <code>compadd</code> in the second array, the matches in the third array, and the strings to be displayed in the completion listing in the fourth array. The arrays may then be directly given to <code>compadd</code> to register the matches with the completion code.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compfiles">
<h3><code>compfiles</code> <a class="doc-anchor" href="#doc-lsp-compat-compfiles">¶</a></h3>
<p>Used by the <code>_path_files</code> function to optimize complex recursive filename generation (globbing). It does three things. With the <code>-p</code> and <code>-P</code> options it builds the glob patterns to use, including the paths already handled and trying to optimize the patterns with respect to the prefix and suffix from the line and the match specification currently used. The <code>-i</code> option does the directory tests for the <code>ignore-parents</code> style and the <code>-r</code> option tests if a component for some of the matches are equal to the string on the line and removes all other matches if that is true.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compgroups">
<h3><code>compgroups</code> <a class="doc-anchor" href="#doc-lsp-compat-compgroups">¶</a></h3>
<p>Used by the <code>_tags</code> function to implement the internals of the <code>group-order</code> style. This only takes its arguments as names of completion groups and creates the groups for it (all six types: sorted and unsorted, both without removing duplicates, with removing all duplicates and with removing consecutive duplicates).</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compquote">
<h3><code>compquote</code> <a class="doc-anchor" href="#doc-lsp-compat-compquote">¶</a></h3>
<p>There may be reasons to write completion functions that have to add the matches using the <code>-Q</code> option to <code>compadd</code> and perform quoting themselves. Instead of interpreting the first character of the <code>all_quotes</code> key of the <code>compstate</code> special association and using the <code>q</code> flag for parameter expansions, one can use this builtin command. The arguments are the names of scalar or array parameters and the values of these parameters are quoted as needed for the innermost quoting level. If the <code>-p</code> option is given, quoting is done as if there is some prefix before the values of the parameters, so that a leading equal sign will not be quoted.</p>
<p>The return status is non-zero in case of an error and zero otherwise.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compset">
<h3><code>compset</code> <a class="doc-anchor" href="#doc-lsp-compat-compset">¶</a></h3>
<p>This command simplifies modification of the special parameters, while its return status allows tests on them to be carried out.</p>
<p>The options are:</p>
<p>- <strong><code>-p</code> <em>number</em></strong> — If the value of the <code>PREFIX</code> parameter is at least <em>number</em> characters long, the first <em>number</em> characters are removed from it and appended to the contents of the <code>IPREFIX</code> parameter.</p>
<p>- <strong><code>-P</code> [ <em>number</em> ] <em>pattern</em></strong> — If the value of the <code>PREFIX</code> parameter begins with anything that matches the <em>pattern</em>, the matched portion is removed from <code>PREFIX</code> and appended to <code>IPREFIX</code>.</p>
<p>Without the optional <em>number</em>, the longest match is taken, but if <em>number</em> is given, anything up to the _number_th match is moved. If the <em>number</em> is negative, the _number_th longest match is moved. For example, if <code>PREFIX</code> contains the string "a=b=c", then "compset -P "*\='<code> will move the string "a=b=" into the </code>IPREFIX" parameter, but "compset -P 1 "*\="<code> will move only the string "a=".</code></p>
<p>- <strong><code>-s</code> <em>number</em></strong> — As <code>-p</code>, but transfer the last <em>number</em> characters from the value of <code>SUFFIX</code> to the front of the value of <code>ISUFFIX</code>.</p>
<p>- <strong><code>-S</code> [ <em>number</em> ] <em>pattern</em></strong> — As <code>-P</code>, but match the last portion of <code>SUFFIX</code> and transfer the matched portion to the front of the value of <code>ISUFFIX</code>.</p>
<p>- <strong><code>-n</code> <em>begin</em> [ <em>end</em> ]</strong> — If the current word position as specified by the parameter <code>CURRENT</code> is greater than or equal to <em>begin</em>, anything up to the _begin_th word is removed from the <code>words</code> array and the value of the parameter <code>CURRENT</code> is decremented by <em>begin</em>.</p>
<p>If the optional <em>end</em> is given, the modification is done only if the current word position is also less than or equal to <em>end</em>. In this case, the words from position <em>end</em> onwards are also removed from the <code>words</code> array.</p>
<p>Both <em>begin</em> and <em>end</em> may be negative to count backwards from the last element of the <code>words</code> array.</p>
<p>- <strong><code>-N</code> <em>beg-pat</em> [ <em>end-pat</em> ]</strong> — If one of the elements of the <code>words</code> array before the one at the index given by the value of the parameter <code>CURRENT</code> matches the pattern <em>beg-pat</em>, all elements up to and including the matching one are removed from the <code>words</code> array and the value of <code>CURRENT</code> is changed to point to the same word in the changed array.</p>
<p>If the optional pattern <em>end-pat</em> is also given, and there is an element in the <code>words</code> array matching this pattern, the parameters are modified only if the index of this word is higher than the one given by the <code>CURRENT</code> parameter (so that the matching word has to be after the cursor). In this case, the words starting with the one matching <code>end-pat</code> are also removed from the <code>words</code> array. If <code>words</code> contains no word matching <em>end-pat</em>, the testing and modification is performed as if it were not given.</p>
<p>- <strong><code>-q</code></strong> — The word currently being completed is split on spaces into separate words, respecting the usual shell quoting conventions. The resulting words are stored in the <code>words</code> array, and <code>CURRENT</code>, <code>PREFIX</code>, <code>SUFFIX</code>, <code>QIPREFIX</code>, and <code>QISUFFIX</code> are modified to reflect the word part that is completed.</p>
<p>In all the above cases the return status is zero if the test succeeded and the parameters were modified and non-zero otherwise. This allows one to use this builtin in tests such as:</p>
<p> if compset -P '*\='; then ...</p>
<p>This forces anything up to and including the last equal sign to be ignored by the completion code.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-comptags">
<h3><code>comptags</code> <a class="doc-anchor" href="#doc-lsp-compat-comptags">¶</a></h3>
<p>These implement the internals of the tags mechanism.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-comptry">
<h3><code>comptry</code> <a class="doc-anchor" href="#doc-lsp-compat-comptry">¶</a></h3>
<p>These implement the internals of the tags mechanism.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-compvalues">
<h3><code>compvalues</code> <a class="doc-anchor" href="#doc-lsp-compat-compvalues">¶</a></h3>
<p>Like <code>comparguments</code>, but for the <code>_values</code> function.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-continue">
<h3><code>continue</code> <a class="doc-anchor" href="#doc-lsp-compat-continue">¶</a></h3>
<p>Resume the next iteration of the enclosing <code>for</code>, <code>while</code>, <code>until</code>, <code>select</code> or <code>repeat</code> loop. If an arithmetic expression <em>n</em> is specified, break out of <em>n</em>-1 loops and resume at the _n_th enclosing loop.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-declare">
<h3><code>declare</code> <a class="doc-anchor" href="#doc-lsp-compat-declare">¶</a></h3>
<p>Alias for <code>typeset</code>. Set variable attributes. <code>-a</code> array, <code>-A</code> assoc, <code>-i</code> integer, <code>-r</code> readonly.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-dirs">
<h3><code>dirs</code> <a class="doc-anchor" href="#doc-lsp-compat-dirs">¶</a></h3>
<p>With no arguments, print the contents of the directory stack. Directories are added to this stack with the <code>pushd</code> command, and removed with the <code>cd</code> or <code>popd</code> commands. If arguments are specified, load them onto the directory stack, replacing anything that was there, and push the current directory onto the stack.</p>
<p>- <strong><code>-c</code></strong> — clear the directory stack.</p>
<p>- <strong><code>-l</code></strong> — print directory names in full instead of using <code>~</code> expressions (see <em>Filename Expansion</em> (zshexpn)).</p>
<p>- <strong><code>-p</code></strong> — print directory entries one per line.</p>
<p>- <strong><code>-v</code></strong> — number the directories in the stack when printing.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-disable">
<h3><code>disable</code> <a class="doc-anchor" href="#doc-lsp-compat-disable">¶</a></h3>
<p>Temporarily disable the _name_d hash table elements or patterns. The default is to disable builtin commands. This allows you to use an external command with the same name as a builtin command. The <code>-a</code> option causes <code>disable</code> to act on regular or global aliases. The <code>-s</code> option causes <code>disable</code> to act on suffix aliases. The <code>-f</code> option causes <code>disable</code> to act on shell functions. The <code>-r</code> options causes <code>disable</code> to act on reserved words. Without arguments all disabled hash table elements from the corresponding hash table are printed. With the <code>-m</code> flag the arguments are taken as patterns (which should be quoted to prevent them from undergoing filename expansion), and all hash table elements from the corresponding hash table matching these patterns are disabled. Disabled objects can be enabled with the <code>enable</code> command.</p>
<p>With the option <code>-p</code>, <em>name</em> ... refer to elements of the shell's pattern syntax as described in <em>Filename Generation</em> (zshexpn). Certain elements can be disabled separately, as given below.</p>
<p>Note that patterns not allowed by the current settings for the options <code>EXTENDED_GLOB</code>, <code>KSH_GLOB</code> and <code>SH_GLOB</code> are never enabled, regardless of the setting here. For example, if <code>EXTENDED_GLOB</code> is not active, the pattern <code>^</code> is ineffective even if "disable -p "^"" has not been issued. The list below indicates any option settings that restrict the use of the pattern. It should be noted that setting <code>SH_GLOB</code> has a wider effect than merely disabling patterns as certain expressions, in particular those involving parentheses, are parsed differently.</p>
<p>The following patterns may be disabled; all the strings need quoting on the command line to prevent them from being interpreted immediately as patterns and the patterns are shown below in single quotes as a reminder.</p>
<p>- <strong><code>'?'</code></strong> — The pattern character <code>?</code> wherever it occurs, including when preceding a parenthesis with <code>KSH_GLOB</code>.</p>
<p>- <strong><code>'*'</code></strong> — The pattern character <code>*</code> wherever it occurs, including recursive globbing and when preceding a parenthesis with <code>KSH_GLOB</code>.</p>
<p>- <strong><code>[</code></strong> — Character classes.</p>
<p>- <strong><code>'<'</code> (<code>NO_SH_GLOB</code>)</strong> — Numeric ranges.</p>
<p>- <strong><code>'|'</code> (<code>NO_SH_GLOB</code>)</strong> — Alternation in grouped patterns, case statements, or KSH_GLOB parenthesised expressions.</p>
<p>- <strong><code>(</code> (<code>NO_SH_GLOB</code>)</strong> — Grouping using single parentheses. Disabling this does not disable the use of parentheses for <code>KSH_GLOB</code> where they are introduced by a special character, nor for glob qualifiers (use <code></code>setopt NO_BARE_GLOB_QUAL<code>' to disable glob qualifiers that use parentheses only).</code></p>
<p>- <strong><code>'~'</code> (<code>EXTENDED_GLOB</code>)</strong> — Exclusion in the form <em>A</em><code>~</code><em>B</em>.</p>
<p>- <strong><code>'^'</code> (<code>EXTENDED_GLOB</code>)</strong> — Exclusion in the form <em>A</em><code>^</code><em>B</em>.</p>
<p>- <strong><code>'#'</code> (<code>EXTENDED_GLOB</code>)</strong> — The pattern character <code>#</code> wherever it occurs, both for repetition of a previous pattern and for indicating globbing flags.</p>
<p>- <strong><code>?(</code> (<code>KSH_GLOB</code>)</strong> — The grouping form <code>?(...)</code>. Note this is also disabled if <code>'?'</code> is disabled.</p>
<p>- <strong><code>*(</code> (<code>KSH_GLOB</code>)</strong> — The grouping form <code>*(...)</code>. Note this is also disabled if <code>'*'</code> is disabled.</p>
<p>- <strong><code>+(</code> (<code>KSH_GLOB</code>)</strong> — The grouping form <code>+(...)</code>.</p>
<p>- <strong><code>!(</code> (<code>KSH_GLOB</code>)</strong> — The grouping form <code>!(...)</code>.</p>
<p>- <strong><code>@(</code> (<code>KSH_GLOB</code>)</strong> — The grouping form <code>@(...)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-disown">
<h3><code>disown</code> <a class="doc-anchor" href="#doc-lsp-compat-disown">¶</a></h3>
<p>Remove the specified _job_s from the job table; the shell will no longer report their status, and will not complain if you try to exit an interactive shell with them running or stopped. If no <em>job</em> is specified, disown the current job.</p>
<p>If the _job_s are currently stopped and the <code>AUTO_CONTINUE</code> option is not set, a warning is printed containing information about how to make them running after they have been disowned. If one of the latter two forms is used, the _job_s will automatically be made running, independent of the setting of the <code>AUTO_CONTINUE</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-echo">
<h3><code>echo</code> <a class="doc-anchor" href="#doc-lsp-compat-echo">¶</a></h3>
<p>Write each <em>arg</em> on the standard output, with a space separating each one. If the <code>-n</code> flag is not present, print a newline at the end. <code>echo</code> recognizes the following escape sequences:</p>
<p>- <code>\a</code> — bell character - <code>\b</code> — backspace - <code>\c</code> — suppress subsequent characters and final newline - <code>\e</code> — escape - <code>\f</code> — form feed</p>
<p>- <strong><code>\n</code></strong> — linefeed (newline)</p>
<p>- <code>\r</code> — carriage return - <code>\t</code> — horizontal tab - <code>\v</code> — vertical tab - <code>\\</code> — backslash - <code>\0</code><em>NNN</em> — character code in octal - <code>\x</code><em>NN</em> — character code in hexadecimal - <code>\u</code><em>NNNN</em> — unicode character code in hexadecimal - <code>\U</code><em>NNNNNNNN</em> — unicode character code in hexadecimal</p>
<p>pindex(BSD_ECHO, use of) The <code>-E</code> flag, or the <code>BSD_ECHO</code> option, can be used to disable these escape sequences. In the latter case, <code>-e</code> flag can be used to enable them.</p>
<p>Note that for standards compliance a double dash does not terminate option processing; instead, it is printed directly. However, a single dash does terminate option processing, so the first dash, possibly following options, is not printed, but everything following it is printed as an argument. The single dash behaviour is different from other shells. For a more portable way of printing text, see <code>printf</code>, and for a more controllable way of printing text within zsh, see <code>print</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-echotc">
<h3><code>echotc</code> <a class="doc-anchor" href="#doc-lsp-compat-echotc">¶</a></h3>
<p>Output the termcap value corresponding to the capability <em>cap</em>, with optional arguments.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-echoti">
<h3><code>echoti</code> <a class="doc-anchor" href="#doc-lsp-compat-echoti">¶</a></h3>
<p>Output the terminfo value corresponding to the capability <em>cap</em>, instantiated with <em>arg</em> if applicable.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-emulate">
<h3><code>emulate</code> <a class="doc-anchor" href="#doc-lsp-compat-emulate">¶</a></h3>
<p>Without any argument print current emulation mode.</p>
<p>With single argument set up zsh options to emulate the specified shell as much as possible. <strong>csh</strong> will never be fully emulated. If the argument is not one of the shells listed above, <code>zsh</code> will be used as a default; more precisely, the tests performed on the argument are the same as those used to determine the emulation at startup based on the shell name, see <em>Compatibility</em> (zsh). In addition to setting shell options, the command also restores the pristine state of pattern enables, as if all patterns had been enabled using <code>enable -p</code>.</p>
<p>If the <code>emulate</code> command occurs inside a function that has been marked for execution tracing with <code>functions -t</code> then the <code>xtrace</code> option will be turned on regardless of emulation mode or other options. Note that code executed inside the function by the <code>.</code>, <code>source</code>, or <code>eval</code> commands is not considered to be running directly from the function, hence does not provoke this behaviour.</p>
<p>If the <code>-R</code> switch is given, all settable options are reset to their default value corresponding to the specified emulation mode, except for certain options describing the interactive environment; otherwise, only those options likely to cause portability problems in scripts and functions are altered. If the <code>-L</code> switch is given, the options <code>LOCAL_OPTIONS</code>, <code>LOCAL_PATTERNS</code> and <code>LOCAL_TRAPS</code> will be set as well, causing the effects of the <code>emulate</code> command and any <code>setopt</code>, <code>disable -p</code> or <code>enable -p</code>, and <code>trap</code> commands to be local to the immediately surrounding shell function, if any; normally these options are turned off in all emulation modes except <code>ksh</code>. The <code>-L</code> switch is mutually exclusive with the use of <code>-c</code> in <em>flags</em>.</p>
<p>If there is a single argument and the <code>-l</code> switch is given, the options that would be set or unset (the latter indicated with the prefix "no") are listed. <code>-l</code> can be combined with <code>-L</code> or <code>-R</code> and the list will be modified in the appropriate way. Note the list does not depend on the current setting of options, i.e. it includes all options that may in principle change, not just those that would actually change.</p>
<p>The <em>flags</em> may be any of the invocation-time flags described in <em>Invocation</em> (zsh), except that "-o EMACS" and "-o VI" may not be used.</p>
<p>If <code>-c</code> <em>arg</em> appears in <em>flags</em>, <em>arg</em> is evaluated while the requested emulation is temporarily in effect. In this case the emulation mode and all options are restored to their previous values before <code>emulate</code> returns. The <code>-R</code> switch may precede the name of the shell to emulate; note this has a meaning distinct from including <code>-R</code> in <em>flags</em>.</p>
<p>Use of <code>-c</code> enables "sticky" emulation mode for functions defined within the evaluated expression: the emulation mode is associated thereafter with the function so that whenever the function is executed the emulation (respecting the <code>-R</code> switch, if present) and all options are set (and pattern disables cleared) before entry to the function, and the state is restored after exit. If the function is called when the sticky emulation is already in effect, either within an <code></code>emulate<code> _shell_ </code>-c<code>' expression or within another function with the same sticky emulation, entry and exit from the function do not cause options to be altered (except due to standard processing such as the </code>LOCAL_OPTIONS<code> option). This also applies to functions marked for autoload within the sticky emulation; the appropriate set of options will be applied at the point the function is loaded as well as when it is run.</code></p>
<p>For example:</p>
<p>example(emulate sh -c 'fni+() { setopt cshnullglob; } fno+() { fni; }' fno)</p>
<p>The two functions <code>fni</code> and <code>fno</code> are defined with sticky <code>sh</code> emulation. <code>fno</code> is then executed, causing options associated with emulations to be set to their values in <code>sh</code>. <code>fno</code> then calls <code>fni</code>; because <code>fni</code> is also marked for sticky <code>sh</code> emulation, no option changes take place on entry to or exit from it. Hence the option <code>cshnullglob</code>, turned off by <code>sh</code> emulation, will be turned on within <code>fni</code> and remain on return to <code>fno</code>. On exit from <code>fno</code>, the emulation mode and all options will be restored to the state they were in before entry to the temporary emulation.</p>
<p>The documentation above is typically sufficient for the intended purpose of executing code designed for other shells in a suitable environment. More detailed rules follow.</p>
<p>- 1. — The sticky emulation environment provided by <code></code>emulate<code> _shell_ </code>-c<code>' is identical to that provided by entry to a function marked for sticky emulation as a consequence of being defined in such an environment. Hence, for example, the sticky emulation is inherited by subfunctions defined within functions with sticky emulation. - 2. — No change of options takes place on entry to or exit from functions that are not marked for sticky emulation, other than those that would normally take place, even if those functions are called within sticky emulation. - 3. — No special handling is provided for functions marked for </code>autoload<code> nor for functions present in wordcode created by the </code>zcompile<code> command. - 4. — The presence or absence of the </code>-R<code> switch to </code>emulate<code> corresponds to different sticky emulation modes, so for example "emulate sh -c", "emulate -R sh -c" and "emulate csh -c" are treated as three distinct sticky emulations. - 5. — Difference in shell options supplied in addition to the basic emulation also mean the sticky emulations are different, so for example "emulate zsh -c" and "emulate zsh -o cbases -c" are treated as distinct sticky emulations.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-compat-enable">
<h3><code>enable</code> <a class="doc-anchor" href="#doc-lsp-compat-enable">¶</a></h3>
<p>Enable the _name_d hash table elements, presumably disabled earlier with <code>disable</code>. The default is to enable builtin commands. The <code>-a</code> option causes <code>enable</code> to act on regular or global aliases. The <code>-s</code> option causes <code>enable</code> to act on suffix aliases. The <code>-f</code> option causes <code>enable</code> to act on shell functions. The <code>-r</code> option causes <code>enable</code> to act on reserved words. Without arguments all enabled hash table elements from the corresponding hash table are printed. With the <code>-m</code> flag the arguments are taken as patterns (should be quoted) and all hash table elements from the corresponding hash table matching these patterns are enabled. Enabled objects can be disabled with the <code>disable</code> builtin command.</p>
<p><code>enable -p</code> reenables patterns disabled with <code>disable -p</code>. Note that it does not override globbing options; for example, <code></code>enable -p "~"<code>' does not cause the pattern character </code>~<code> to be active unless the </code>EXTENDED_GLOB<code> option is also set. To enable all possible patterns (so that they may be individually disabled with </code>disable -p<code>), use "setopt EXTENDED_GLOB KSH_GLOB NO_SH_GLOB".</code></p>
</article>
<article class="doc-entry" id="doc-lsp-compat-eval">
<h3><code>eval</code> <a class="doc-anchor" href="#doc-lsp-compat-eval">¶</a></h3>
<p>Read the arguments as input to the shell and execute the resulting command+(s+) in the current shell process. The return status is the same as if the commands had been executed directly by the shell; if there are no <em>args</em> or they contain no commands (i.e. are an empty string or whitespace) the return status is zero.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-example">
<h3><code>example</code> <a class="doc-anchor" href="#doc-lsp-compat-example">¶</a></h3>
<p>Displays the flags and arguments it is invoked with.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-exec">
<h3><code>exec</code> <a class="doc-anchor" href="#doc-lsp-compat-exec">¶</a></h3>
<p>The following command together with any arguments is run in place of the current process, rather than as a sub-process. The shell does not fork and is replaced. The shell does not invoke <code>TRAPEXIT</code>, nor does it source <code>zlogout</code> files. The options are provided for compatibility with other shells.</p>
<p>The <code>-c</code> option clears the environment.</p>
<p>The <code>-l</code> option is equivalent to the <code>-</code> precommand modifier, to treat the replacement command as a login shell; the command is executed with a <code>-</code> prepended to its <code>argv[0]</code> string. This flag has no effect if used together with the <code>-a</code> option.</p>
<p>The <code>-a</code> option is used to specify explicitly the <code>argv[0]</code> string (the name of the command as seen by the process itself) to be used by the replacement command and is directly equivalent to setting a value for the <code>ARGV0</code> environment variable.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-exit">
<h3><code>exit</code> <a class="doc-anchor" href="#doc-lsp-compat-exit">¶</a></h3>
<p>Exit the shell with the exit status specified by an arithmetic expression <em>n</em>; if none is specified, use the exit status from the last command executed. pindex(IGNORE_EOF, use of) An EOF condition will also cause the shell to exit, unless the <code>IGNORE_EOF</code> option is set.</p>
<p>See notes at the end of <em>Signals</em> (zshmisc) for some possibly unexpected interactions of the <code>exit</code> command with jobs.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-export">
<h3><code>export</code> <a class="doc-anchor" href="#doc-lsp-compat-export">¶</a></h3>
<p>The specified _name_s are marked for automatic export to the environment of subsequently executed commands. Equivalent to <code>typeset -gx</code>. If a parameter specified does not already exist, it is created in the global scope.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-false">
<h3><code>false</code> <a class="doc-anchor" href="#doc-lsp-compat-false">¶</a></h3>
<p>Do nothing and return an exit status of 1.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-fc">
<h3><code>fc</code> <a class="doc-anchor" href="#doc-lsp-compat-fc">¶</a></h3>
<p>The <code>fc</code> command controls the interactive history mechanism. Note that reading and writing of history options is only performed if the shell is interactive. Usually this is detected automatically, but it can be forced by setting the <code>interactive</code> option when starting the shell.</p>
<p>The first two forms of this command select a range of events from <em>first</em> to <em>last</em> from the history list. The arguments <em>first</em> and <em>last</em> may be specified as a number or as a string. A negative number is used as an offset to the current history event number. A string specifies the most recent event beginning with the given string. All substitutions <em>old</em><code>=</code><em>new</em>, if any, are then performed on the text of the events.</p>
<p>The range of events selected by numbers can be narrowed further by the following flags.</p>
<p>- <strong><code>-I</code></strong> — restricts to only internal events (not from <code>$HISTFILE</code>)</p>
<p>- <strong><code>-L</code></strong> — restricts to only local events (not from other shells, see <code>SHARE_HISTORY</code> in nmref(Description of Options)(zshoptions) -- note that <code>$HISTFILE</code> is considered local when read at startup)</p>
<p>- <strong><code>-m</code></strong> — takes the first argument as a pattern (which should be quoted) and only the history events matching this pattern are considered</p>
<p>If <em>first</em> is not specified, it will be set to -1 (the most recent event), or to -16 if the <code>-l</code> flag is given. If <em>last</em> is not specified, it will be set to <em>first</em>, or to -1 if the <code>-l</code> flag is given. However, if the current event has added entries to the history with "print -s" or "fc -R", then the default <em>last</em> for <code>-l</code> includes all new history entries since the current event began.</p>
<p>When the <code>-l</code> flag is given, the resulting events are listed on standard output. Otherwise the editor program specified by <code>-e</code> <em>ename</em> is invoked on a file containing these history events. If <code>-e</code> is not given, the value of the parameter <code>FCEDIT</code> is used; if that is not set the value of the parameter <code>EDITOR</code> is used; if that is not set a builtin default, usually "vi" is used. If <em>ename</em> is "-", no editor is invoked. When editing is complete, the edited command is executed.</p>
<p>The flag "-s" is equivalent to "-e -". The flag <code>-r</code> reverses the order of the events and the flag <code>-n</code> suppresses event numbers when listing.</p>
<p>Also when listing,</p>
<p>- <code>-d</code> — prints timestamps for each event - <code>-f</code> — prints full time-date stamps in the US <code>_MM_</code>/<code>_DD_</code>/<code>_YY_ _hh_</code>:"<em>mm</em>" format - <code>-E</code> — prints full time-date stamps in the European <code>_dd_</code>.<code>_mm_</code>.<code>_yyyy_ _hh_</code>:"<em>mm</em>" format - <code>-i</code> — prints full time-date stamps in ISO8601 <code>_yyyy_</code>-<code>_mm_</code>-<code>_dd_ _hh_</code>:"<em>mm</em>" format</p>
<p>- <strong><code>-t</code> <em>fmt</em></strong> — prints time and date stamps in the given format; <em>fmt</em> is formatted with the strftime function with the zsh extensions described for the <code>%D{</code><em>string</em><code>}</code> prompt format in <em>Simple Prompt Escapes</em> (zshmisc). The resulting formatted string must be no more than 256 characters or will not be printed</p>
<p>- <code>-D</code> — prints elapsed times; may be combined with one of the options above</p>
<p>cindex(history, stack) cindex(stack, history) "fc -p" pushes the current history list onto a stack and switches to a new history list. If the <code>-a</code> option is also specified, this history list will be automatically popped when the current function scope is exited, which is a much better solution than creating a trap function to call "fc -P" manually. If no arguments are specified, the history list is left empty, <code>$HISTFILE</code> is unset, and <code>$HISTSIZE</code> & <code>$SAVEHIST</code> are set to their default values. If one argument is given, <code>$HISTFILE</code> is set to that filename, <code>$HISTSIZE</code> & <code>$SAVEHIST</code> are left unchanged, and the history file is read in (if it exists) to initialize the new list. If a second argument is specified, <code>$HISTSIZE</code> & <code>$SAVEHIST</code> are instead set to the single specified numeric value. Finally, if a third argument is specified, <code>$SAVEHIST</code> is set to a separate value from <code>$HISTSIZE</code>. You are free to change these environment values for the new history list however you desire in order to manipulate the new history list.</p>
<p>"fc -P" pops the history list back to an older list saved by "fc -p". The current list is saved to its <code>$HISTFILE</code> before it is destroyed (assuming that <code>$HISTFILE</code> and <code>$SAVEHIST</code> are set appropriately, of course). The values of <code>$HISTFILE</code>, <code>$HISTSIZE</code>, and <code>$SAVEHIST</code> are restored to the values they had when "fc -p" was called. Note that this restoration can conflict with making these variables "local", so your best bet is to avoid local declarations for these variables in functions that use "fc -p". The one other guaranteed-safe combination is declaring these variables to be local at the top of your function and using the automatic option (<code>-a</code>) with "fc -p". Finally, note that it is legal to manually pop a push marked for automatic popping if you need to do so before the function exits.</p>
<p>cindex(history, file) cindex(file, history) "fc -R" reads the history from the given file, "fc -W" writes the history out to the given file, and "fc -A" appends the history out to the given file. If no filename is specified, the <code>$HISTFILE</code> is assumed. If the <code>-I</code> option is added to <code>-R</code>, only those events that are not already contained within the internal history list are added. If the <code>-I</code> option is added to <code>-A</code> or <code>-W</code>, only those events that are new since last incremental append/write to the history file are appended/written. In any case, the created file will have no more than <code>$SAVEHIST</code> entries.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-fg">
<h3><code>fg</code> <a class="doc-anchor" href="#doc-lsp-compat-fg">¶</a></h3>
<p>Bring each specified <em>job</em> in turn to the foreground. If no <em>job</em> is specified, resume the current job.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-float">
<h3><code>float</code> <a class="doc-anchor" href="#doc-lsp-compat-float">¶</a></h3>
<p>Equivalent to <code>typeset -E</code>, except that options irrelevant to floating point numbers are not permitted.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-functions">
<h3><code>functions</code> <a class="doc-anchor" href="#doc-lsp-compat-functions">¶</a></h3>
<p>Equivalent to <code>typeset -f</code>, with the exception of the <code>-c</code>, <code>-x</code>, <code>-M</code> and <code>-W</code> options. For <code>functions -u</code> and <code>functions -U</code>, see <code>autoload</code>, which provides additional options. For <code>functions -t</code> and <code>functions -T</code>, see <code>typeset -f</code>.</p>
<p>The <code>-x</code> option indicates that any functions output will have each leading tab for indentation, added by the shell to show syntactic structure, expanded to the given number <em>num</em> of spaces. <em>num</em> can also be 0 to suppress all indentation.</p>
<p>The <code>-W</code> option turns on the option <code>WARN_NESTED_VAR</code> for the named function or functions only. The option is turned off at the start of nested functions (apart from anonymous functions) unless the called function also has the <code>-W</code> attribute.</p>
<p>The <code>-c</code> option causes <em>oldfn</em> to be copied to <em>newfn</em>. The copy is efficiently handled internally by reference counting. If <em>oldfn</em> was marked for autoload it is first loaded and if this fails the copy fails. Either function may subsequently be redefined without affecting the other. A typical idiom is that <em>oldfn</em> is the name of a library shell function which is then redefined to call <code>newfn</code>, thereby installing a modified version of the function.</p>
<p><em>The </em><code>-M</code>_ and <em><code>+M</code></em> flags_ cindex(defining mathematical functions) cindex(functions, defining mathematical)</p>
<p>Use of the <code>-M</code> option may not be combined with any of the options handled by <code>typeset -f</code>.</p>
<p><code>functions -M</code> <em>mathfn</em> defines <em>mathfn</em> as the name of a mathematical function recognised in all forms of arithmetical expressions; see <em>Arithmetic Evaluation</em> (zshmisc). By default <em>mathfn</em> may take any number of comma-separated arguments. If <em>min</em> is given, it must have exactly <em>min</em> args; if <em>min</em> and <em>max</em> are both given, it must have at least <em>min</em> and at most <em>max</em> args. <em>max</em> may be -1 to indicate that there is no upper limit.</p>
<p>By default the function is implemented by a shell function of the same name; if <em>shellfn</em> is specified it gives the name of the corresponding shell function while <em>mathfn</em> remains the name used in arithmetical expressions. The name of the function in <code>$0</code> is <em>mathfn</em> (not <em>shellfn</em> as would usually be the case), provided the option <code>FUNCTION_ARGZERO</code> is in effect. The positional parameters in the shell function correspond to the arguments of the mathematical function call.</p>
<p>The result of the last arithmetical expression evaluated inside the shell function gives the result of the mathematical function. This is not limited to arithmetic substitutions of the form tt($+(+()<em>...</em><code>+</code>+)), but also includes arithmetical expressions evaluated in any other way, including by the <code>let</code> builtin, by tt(+(+()<em>...</em><code>+</code>+)) statements, and even by the <code>return</code> builtin and by array subscripts. Therefore, care must be taken not to use syntactical constructs that perform arithmetic evaluation after evaluating what is to be the result of the function. For example:</p>
<p>findex(zmath_cube) findex(cube) example(# WRONG zmath_cube+(+) { (( $1 * $1 * $1 )) return 0 } functions -M cube 1 1 zmath_cube print $(( cube+(3+) )))</p>
<p>This will print "0" because of the <code>return</code>.</p>
<p>Commenting the <code>return</code> out would lead to a different problem: the tt(+(+()<em>...</em><code>+</code>+)) statement would become the last statement in the function, so the <em>return status</em> (<code>$?</code>) of the function would be non-zero (indicating failure) whenever the <em>arithmetic result</em> of the function would happen to be zero (numerically):</p>
<p>example(# WRONG zmath_cube+(+) { (( $1 * $1 * $1 )) } functions -M cube 1 1 zmath_cube print $(( cube+(0+) )))</p>
<p>Instead, the <code>true</code> builtin can be used:</p>
<p>example(# RIGHT zmath_cube+(+) { (( $1 * $1 * $1 )) true } functions -M cube 1 1 zmath_cube print $(( cube+(3+) )))</p>
<p>If the additional option <code>-s</code> is given to <code>functions -M</code>, the argument to the function is a single string: anything between the opening and matching closing parenthesis is passed to the function as a single argument, even if it includes commas or white space. The minimum and maximum argument specifiers must therefore be 1 if given. An empty argument list is passed as a zero-length string. Thus, the following string function takes a single argument, including the commas, and prints 11:</p>
<p>example(stringfn+() { (( $#1 )); true } functions -Ms stringfn print $(( stringfn+(foo,bar,rod+) )))</p>
<p><code>functions -M</code> with no arguments lists all such user-defined functions in the same form as a definition. With the additional option <code>-m</code> and a list of arguments, all functions whose <em>mathfn</em> matches one of the pattern arguments are listed.</p>
<p><code>function +M</code> removes the list of mathematical functions; with the additional option <code>-m</code> the arguments are treated as patterns and all functions whose <em>mathfn</em> matches the pattern are removed. Note that the shell function implementing the behaviour is not removed (regardless of whether its name coincides with <em>mathfn</em>).</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-getcap">
<h3><code>getcap</code> <a class="doc-anchor" href="#doc-lsp-compat-getcap">¶</a></h3>
<p>This is a built-in implementation of the POSIX standard utility. It displays the capability sets on each specified <em>filename</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-getln">
<h3><code>getln</code> <a class="doc-anchor" href="#doc-lsp-compat-getln">¶</a></h3>
<p>Read the top value from the buffer stack and put it in the shell parameter <em>name</em>. Equivalent to <code>read -zr</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-getopts">
<h3><code>getopts</code> <a class="doc-anchor" href="#doc-lsp-compat-getopts">¶</a></h3>
<p>Checks the _arg_s for legal options. If the _arg_s are omitted, use the positional parameters. A valid option argument begins with a "+" or a "-". An argument not beginning with a "+" or a "-", or the argument <code></code>-"-", ends the options. Note that a single "-" is not considered a valid option argument. <em>optstring</em> contains the letters that <code>getopts</code> recognizes. If a letter is followed by a ":", that option requires an argument. The options can be separated from the argument by blanks.</p>
<p>Each time it is invoked, <code>getopts</code> places the option letter it finds in the shell parameter <em>name</em>, prepended with a "+" when <em>arg</em> begins with a "+". The index of the next <em>arg</em> is stored in <code>OPTIND</code>. The option argument, if any, is stored in <code>OPTARG</code>. vindex(OPTIND, use of) vindex(OPTARG, use of)</p>
<p>The first option to be examined may be changed by explicitly assigning to <code>OPTIND</code>. <code>OPTIND</code> has an initial value of <code>1</code>, and is normally set to <code>1</code> upon entry to a shell function and restored upon exit. (The <code>POSIX_BUILTINS</code> option disables this, and also changes the way the value is calculated to match other shells.) <code>OPTARG</code> is not reset and retains its value from the most recent call to <code>getopts</code>. If either of <code>OPTIND</code> or <code>OPTARG</code> is explicitly unset, it remains unset, and the index or option argument is not stored. The option itself is still stored in <em>name</em> in this case.</p>
<p>A leading ":" in <em>optstring</em> causes <code>getopts</code> to store the letter of any invalid option in <code>OPTARG</code>, and to set <em>name</em> to "?" for an unknown option and to ":" when a required argument is missing. Otherwise, <code>getopts</code> sets <em>name</em> to "?" and prints an error message when an option is invalid. The exit status is nonzero when there are no more options.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-hash">
<h3><code>hash</code> <a class="doc-anchor" href="#doc-lsp-compat-hash">¶</a></h3>
<p><code>hash</code> can be used to directly modify the contents of the command hash table, and the named directory hash table. Normally one would modify these tables by modifying one's <code>PATH</code> (for the command hash table) or by creating appropriate shell parameters (for the named directory hash table). The choice of hash table to work on is determined by the <code>-d</code> option; without the option the command hash table is used, and with the option the named directory hash table is used.</p>
<p>A command <em>name</em> starting with a <code>/</code> or with a relative path starting with <code>./</code> or <code>../</code> is never executed by lookup in the command hash table, and these can only be added to the table by explicit use of the <code>hash</code> command. Such a command is always found by direct look up in the file system.</p>
<p>Given no arguments, and neither the <code>-r</code> or <code>-f</code> options, the selected hash table will be listed in full.</p>
<p>The <code>-r</code> option causes the selected hash table to be emptied. It will be subsequently rebuilt in the normal fashion. The <code>-f</code> option causes the selected hash table to be fully rebuilt immediately. For the command hash table this hashes all (and <em>only</em>) the absolute directories in the <code>PATH</code>, and for the named directory hash table this adds all users' home directories. These two options cannot be used with any arguments. Both options remove any explicitly-added elements.</p>
<p>The <code>-m</code> option causes the arguments to be taken as patterns (which should be quoted) and the elements of the hash table matching those patterns are printed. This is the only way to display a limited selection of hash table elements.</p>
<p>For each <em>name</em> with a corresponding <em>value</em>, put "<em>name</em>" in the selected hash table, associating it with the pathname "<em>value</em>". In the command hash table, this means that whenever "<em>name</em>" is used as a command argument, the shell will try to execute the file given by "<em>value</em>". In the named directory hash table, this means that "<em>value</em>" may be referred to as <code></code>~"<em>name</em>".</p>
<p>For each <em>name</em> with no corresponding <em>value</em>, attempt to add <em>name</em> to the hash table, checking what the appropriate <code>value</code> is in the normal manner for that hash table. If an appropriate <code>value" can"t be found, then the hash table will be unchanged.</code></p>
<p>The <code>-v</code> option causes hash table entries to be listed as they are added by explicit specification. If has no effect if used with <code>-f</code>.</p>
<p>If the <code>-L</code> flag is present, then each hash table entry is printed in the form of a call to hash.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-hashinfo">
<h3><code>hashinfo</code> <a class="doc-anchor" href="#doc-lsp-compat-hashinfo">¶</a></h3>
<p>Print internal hash-table statistics. Debug builtin in <code>zsh/parameter</code>-adjacent code.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-history">
<h3><code>history</code> <a class="doc-anchor" href="#doc-lsp-compat-history">¶</a></h3>
<p>Search backward in the history for a line beginning with the current line up to the cursor. This leaves the cursor in its original position.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-integer">
<h3><code>integer</code> <a class="doc-anchor" href="#doc-lsp-compat-integer">¶</a></h3>
<p>Equivalent to <code>typeset -i</code>, except that options irrelevant to integers are not permitted.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-jobs">
<h3><code>jobs</code> <a class="doc-anchor" href="#doc-lsp-compat-jobs">¶</a></h3>
<p>Lists information about each given job, or all jobs if <em>job</em> is omitted. The <code>-l</code> flag lists process IDs, and the <code>-p</code> flag lists process groups. If the <code>-r</code> flag is specified only running jobs will be listed and if the <code>-s</code> flag is given only stopped jobs are shown. If the <code>-d</code> flag is given, the directory from which the job was started (which may not be the current directory of the job) will also be shown.</p>
<p>The <code>-Z" option replaces the shell"s argument and environment space with the given string, truncated if necessary to fit. This will normally be visible in </code>ps<code> (manref(ps)(1)) listings. This feature is typically used by daemons, to indicate their state.</code></p>
<p>Full job control is only available in the top-level interactive shell, not in commands run in the left hand side of pipelines or within the tt(()<em>...</em><code></code>) construct. However, a snapshot of the job state at that point is taken, so it is still possible to use the <code>jobs</code> builtin, or any parameter providing job information. This gives information about the state of jobs at the point the subshell was created. If background processes are created within the subshell, then instead information about those processes is provided.</p>
<p>For example,</p>
<p>example(sleep 10 & # Job in background ( # Shell forks jobs # Shows information about "sleep 10 &" sleep 5 & # Process in background (no job control) jobs # Shows information about "sleep 5 &" ))</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-kill">
<h3><code>kill</code> <a class="doc-anchor" href="#doc-lsp-compat-kill">¶</a></h3>
<p>Sends either <code>SIGTERM</code> or the specified signal to the given jobs or processes. Signals are given by number or by names, with or without the "SIG" prefix. If the signal being sent is not "KILL" or "CONT", then the job will be sent a "CONT" signal if it is stopped. The argument <em>job</em> can be the process ID of a job not in the job list. In the second form, <code>kill -l</code>, if <em>sig</em> is not specified the signal names are listed. Otherwise, for each <em>sig</em> that is a name, the corresponding signal number is listed. For each <em>sig</em> that is a signal number or a number representing the exit status of a process which was terminated or stopped by a signal the name of the signal is printed. The final form with <code>-L</code> lists each signal name with its corresponding number.</p>
<p>On some systems, alternative signal names are allowed for a few signals. Typical examples are <code>SIGCHLD</code> and <code>SIGCLD</code> or <code>SIGPOLL</code> and <code>SIGIO</code>, assuming they correspond to the same signal number. <code>kill -l</code> will only list the preferred form, however <code>kill -l</code> <em>alt</em> will show if the alternative form corresponds to a signal number. For example, under Linux <code>kill -l IO</code> and <code>kill -l POLL</code> both output 29, hence <code>kill -IO</code> and <code>kill -POLL</code> have the same effect.</p>
<p>Many systems will allow process IDs to be negative to kill a process group or zero to kill the current process group.</p>
<p>The <code>-q</code> option allows an integer value to be sent with the signal on systems that support tt(sigqueue+()).</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-let">
<h3><code>let</code> <a class="doc-anchor" href="#doc-lsp-compat-let">¶</a></h3>
<p>Evaluate each <em>arg</em> as an arithmetic expression. See <em>Arithmetic Evaluation</em> (zshmisc) for a description of arithmetic expressions. The exit status is 0 if the value of the last expression is nonzero, 1 if it is zero, and 2 if an error occurred.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-limit">
<h3><code>limit</code> <a class="doc-anchor" href="#doc-lsp-compat-limit">¶</a></h3>
<p>Set or display resource limits. Unless the <code>-s</code> flag is given, the limit applies only the children of the shell. If <code>-s</code> is given without other arguments, the resource limits of the current shell is set to the previously set resource limits of the children.</p>
<p>If <em>limit</em> is not specified, print the current limit placed on <em>resource</em>, otherwise set the limit to the specified value. If the <code>-h</code> flag is given, use hard limits instead of soft limits. If no <em>resource</em> is given, print all limits.</p>
<p>When looping over multiple resources, the shell will abort immediately if it detects a badly formed argument. However, if it fails to set a limit for some other reason it will continue trying to set the remaining limits.</p>
<p><em>resource</em> can be one of:</p>
<p>- <code>addressspace</code> — Maximum amount of address space used. - <code>aiomemorylocked</code> — Maximum amount of memory locked in RAM for AIO operations. - <code>aiooperations</code> — Maximum number of AIO operations. - <code>cachedthreads</code> — Maximum number of cached threads. - <code>coredumpsize</code> — Maximum size of a core dump. - <code>cputime</code> — Maximum CPU seconds per process.</p>
<p>- <strong><code>datasize</code></strong> — Maximum data size (including stack) for each process.</p>
<p>- <code>descriptors</code> — Maximum value for a file descriptor. - <code>filesize</code> — Largest single file allowed. - <code>kqueues</code> — Maximum number of kqueues allocated. - <code>maxfilelocks</code> — Maximum number of file locks. - <code>maxproc</code> — Maximum number of processes. - <code>maxpthreads</code> — Maximum number of threads per process. - <code>memorylocked</code> — Maximum amount of memory locked in RAM. - <code>memoryuse</code> — Maximum resident set size. - <code>msgqueue</code> — Maximum number of bytes in POSIX message queues. - <code>nice</code> — Maximum nice value. - <code>pipebuf</code> — Maximum size of buffers for pipes/fifos. - <code>posixlocks</code> — Maximum number of POSIX locks per user. - <code>pseudoterminals</code> — Maximum number of pseudo-terminals. - <code>resident</code> — Maximum resident set size. - <code>rt_priority</code> — Maximum real-time priority. - <code>rt_time</code> — Maximum CPU time without a blocking system call. - <code>sigpending</code> — Maximum number of pending signals. - <code>sockbufsize</code> — Maximum size of all socket buffers. - <code>stacksize</code> — Maximum stack size for each process. - <code>swapsize</code> — Maximum amount of swap used. - <code>umtxp</code> — Maximum number of POSIX thread library objects. - <code>vmemorysize</code> — Maximum amount of virtual memory. - <code>vnodemonitors</code> — Maximum number of open vnode monitors.</p>
<p>Which of these resource limits are available depends on the system. <em>resource</em> can be abbreviated to any unambiguous prefix. It can also be an integer, which corresponds to the integer defined for the resource by the operating system.</p>
<p>If argument corresponds to a number which is out of the range of the resources configured into the shell, the shell will try to read or write the limit anyway, and will report an error if this fails. As the shell does not store such resources internally, an attempt to set the limit will fail unless the <code>-s</code> option is present.</p>
<p><em>limit</em> is a number, with an optional scaling factor, as follows:</p>
<p>- <em>n</em><code>h</code> — hours</p>
<p>- <strong><em>n</em><code>k</code></strong> — kilobytes (default)</p>
<p>- <em>n</em><code>m</code> — megabytes or minutes - <em>n</em><code>g</code> — gigabytes - [<em>mm</em><code>:</code>]<em>ss</em> — minutes and seconds</p>
<p>The <code>limit</code> command is not made available by default when the shell starts in a mode emulating another shell. It can be made available with the command "zmodload -F zsh/rlimits b:limit".</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-ln">
<h3><code>ln</code> <a class="doc-anchor" href="#doc-lsp-compat-ln">¶</a></h3>
<p>for symbolic links. If this has the special value <code>target</code>, symbolic links are dereferenced and the target file used to determine the display format.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-local">
<h3><code>local</code> <a class="doc-anchor" href="#doc-lsp-compat-local">¶</a></h3>
<p>Same as <code>typeset</code>, except that the options <code>-g</code>, and <code>-f</code> are not permitted. In this case the <code>-x</code> option does not force the use of <code>-g</code>, i.e. exported variables will be local to functions.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-log">
<h3><code>log</code> <a class="doc-anchor" href="#doc-lsp-compat-log">¶</a></h3>
<p>List all users currently logged in who are affected by the current setting of the <code>watch</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-logout">
<h3><code>logout</code> <a class="doc-anchor" href="#doc-lsp-compat-logout">¶</a></h3>
<p>Same as <code>exit</code>, except that it only works in a login shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-mem">
<h3><code>mem</code> <a class="doc-anchor" href="#doc-lsp-compat-mem">¶</a></h3>
<p>Print zsh memory-allocator statistics. Debug builtin compiled only with <code>--enable-zsh-mem</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-mkdir">
<h3><code>mkdir</code> <a class="doc-anchor" href="#doc-lsp-compat-mkdir">¶</a></h3>
<p>Creates directories. With the <code>-p</code> option, non-existing parent directories are first created if necessary, and there will be no complaint if the directory already exists. The <code>-m</code> option can be used to specify (in octal) a set of file permissions for the created directories, otherwise mode 777 modified by the current <code>umask</code> (see manref(umask)(2)) is used.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-mv">
<h3><code>mv</code> <a class="doc-anchor" href="#doc-lsp-compat-mv">¶</a></h3>
<p>Moves files. In the first form, the specified <em>filename</em> is moved to the specified _dest_ination. In the second form, each of the _filename_s is taken in turn, and moved to a pathname in the specified _dir_ectory that has the same last pathname component.</p>
<p>By default, the user will be queried before replacing any file that the user cannot write to, but writable files will be silently removed. The <code>-i</code> option causes the user to be queried about replacing any existing files. The <code>-f</code> option causes any existing files to be silently deleted, without querying. <code>-f</code> takes precedence.</p>
<p>Note that this <code>mv</code> will not move files across devices. Historical versions of <code>mv</code>, when actual renaming is impossible, fall back on copying and removing files; if this behaviour is desired, use <code>cp</code> and <code>rm</code> manually. This may change in a future version.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-nameref">
<h3><code>nameref</code> <a class="doc-anchor" href="#doc-lsp-compat-nameref">¶</a></h3>
<p>Equivalent to <code>typeset -n </code><em>pname</em><code>=</code><em>rname</em></p>
<p>However, <code>nameref</code> is a builtin command rather than a reserved word, so when <em>rname</em> uses subscript syntax it must be quoted against globbing. Subscripts in referenced parameters are not supported in ksh93, so this is not a significant compatibility issue.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-noglob">
<h3><code>noglob</code> <a class="doc-anchor" href="#doc-lsp-compat-noglob">¶</a></h3>
<p>Filename generation (globbing) is not performed on any of the words.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-patdebug">
<h3><code>patdebug</code> <a class="doc-anchor" href="#doc-lsp-compat-patdebug">¶</a></h3>
<p>Print pattern-matcher internals for a glob/regex. Debug builtin from <code>zsh/pattern</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pcre_compile">
<h3><code>pcre_compile</code> <a class="doc-anchor" href="#doc-lsp-compat-pcre_compile">¶</a></h3>
<p>Compiles a perl-compatible regular expression.</p>
<p>Option <code>-a</code> will force the pattern to be anchored. Option <code>-i</code> will compile a case-insensitive pattern. Option <code>-m</code> will compile a multi-line pattern; that is, <code>^</code> and <code>$</code> will match newlines within the pattern. Option <code>-x</code> will compile an extended pattern, wherein whitespace and <code>#</code> comments are ignored. Option <code>-s</code> makes the dot metacharacter match all characters, including those that indicate newline.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pcre_match">
<h3><code>pcre_match</code> <a class="doc-anchor" href="#doc-lsp-compat-pcre_match">¶</a></h3>
<p>Returns successfully if <code>string</code> matches the previously-compiled PCRE.</p>
<p>Upon successful match, if the expression captures substrings within parentheses, <code>pcre_match</code> will set the array <code>match</code> to those substrings, unless the <code>-a</code> option is given, in which case it will set the array <em>arr</em>. Similarly, the variable <code>MATCH</code> will be set to the entire matched portion of the string, unless the <code>-v</code> option is given, in which case the variable <em>var</em> will be set. Furthermore, any named captures will be stored in the associative array <code>.pcre.match</code> unless an alternative is given with <code>-A</code>. No variables are altered if there is no successful match. A <code>-n</code> option starts searching for a match from the byte <em>offset</em> position in <em>string</em>. If the <code>-b</code> option is given, the variable <code>ZPCRE_OP</code> will be set to an offset pair string, representing the byte offset positions of the entire matched portion within the <em>string</em>. For example, a <code>ZPCRE_OP</code> set to "32 45" indicates that the matched portion began on byte offset 32 and ended on byte offset 44. Here, byte offset position 45 is the position directly after the matched portion. Keep in mind that the byte position isn't necessarily the same as the character position when UTF-8 characters are involved. Consequently, the byte offset positions are only to be relied on in the context of using them for subsequent searches on <em>string</em>, using an offset position as an argument to the <code>-n</code> option. This is mostly used to implement the "find all non-overlapping matches" functionality.</p>
<p>A simple example of "find all non-overlapping matches":</p>
<p>example(string="The following zip codes: 78884 90210 99513" pcre_compile -m "\d{5}" accum=() pcre_match -b -- $string while [[ $? -eq 0 ]] do b=($=ZPCRE_OP) accum+=$MATCH pcre_match -b -n $b[2] -- $string done print -l $accum)</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pcre_study">
<h3><code>pcre_study</code> <a class="doc-anchor" href="#doc-lsp-compat-pcre_study">¶</a></h3>
<p>Requests JIT compilation for the previously-compiled PCRE which may result in faster matching.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-popd">
<h3><code>popd</code> <a class="doc-anchor" href="#doc-lsp-compat-popd">¶</a></h3>
<p>Remove an entry from the directory stack, and perform a <code>cd</code> to the new top directory. With no argument, the current top entry is removed. An argument of the form <code></code>+"<em>n</em>" identifies a stack entry by counting from the left of the list shown by the <code>dirs</code> command, starting with zero. An argument of the form <code>-</code><em>n</em> counts from the right. pindex(PUSHD_MINUS, use of) If the <code>PUSHD_MINUS</code> option is set, the meanings of "+" and "-" in this context are swapped.</p>
<p>If the <code>-q</code> (quiet) option is specified, the hook function <code>chpwd</code> and the functions in the array <code>$chpwd_functions</code> are not called, and the new directory stack is not printed. This is useful for calls to <code>popd</code> that do not change the environment seen by an interactive user.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-print">
<h3><code>print</code> <a class="doc-anchor" href="#doc-lsp-compat-print">¶</a></h3>
<p>With the "-f" option the arguments are printed as described by <code>printf</code>. With no flags or with the flag "-", the arguments are printed on the standard output as described by <code>echo</code>, with the following differences: the escape sequence <code></code>\M-"<em>x</em>" (or <code></code>\M"<em>x</em>") metafies the character <em>x</em> (sets the highest bit), <code></code>\C-"<em>x</em>" (or <code></code>\C"<em>x</em>") produces a control character ("\C-@" and "\C-?" give the characters NULL and delete), a character code in octal is represented by <code></code>\"<em>NNN</em>" (instead of <code></code>\0"<em>NNN</em>"), and "\E" is a synonym for "\e". Finally, if not in an escape sequence, "\" escapes the following character and is not printed.</p>
<p>- <strong><code>-a</code></strong> — Print arguments with the column incrementing first. Only useful with the <code>-c</code> and <code>-C</code> options.</p>
<p>- <strong><code>-b</code></strong> — Recognize all the escape sequences defined for the <code>bindkey</code> command, see <em>Zle Builtins</em> (zshzle).</p>
<p>- <strong><code>-c</code></strong> — Print the arguments in columns. Unless <code>-a</code> is also given, arguments are printed with the row incrementing first.</p>
<p>- <strong><code>-C</code> <em>cols</em></strong> — Print the arguments in <em>cols</em> columns. Unless <code>-a</code> is also given, arguments are printed with the row incrementing first.</p>
<p>- <strong><code>-D</code></strong> — Treat the arguments as paths, replacing directory prefixes with <code>~</code> expressions corresponding to directory names, as appropriate.</p>
<p>- <strong><code>-i</code></strong> — If given together with <code>-o</code> or <code>-O</code>, sorting is performed case-independently.</p>
<p>- <strong><code>-l</code></strong> — Print the arguments separated by newlines instead of spaces. Note: if the list of arguments is empty, <code>print -l</code> will still output one empty line. To print a possibly-empty list of arguments one per line, use <code>print -C1</code>, as in "print -rC1 -- "$list[@]"".</p>
<p>- <strong><code>-m</code></strong> — Take the first argument as a pattern (should be quoted), and remove it from the argument list together with subsequent arguments that do not match this pattern.</p>
<p>- <strong><code>-n</code></strong> — Do not add a newline to the output.</p>
<p>- <strong><code>-N</code></strong> — Print the arguments separated and terminated by nulls. Again, <code>print -rNC1 -- "$list[@]"</code> is a canonical way to print an arbitrary list as null-delimited records.</p>
<p>- <strong><code>-o</code></strong> — Print the arguments sorted in ascending order.</p>
<p>- <strong><code>-O</code></strong> — Print the arguments sorted in descending order.</p>
<p>- <strong><code>-p</code></strong> — Print the arguments to the input of the coprocess.</p>
<p>- <strong><code>-P</code></strong> — Perform prompt expansion (see <em>Expansion of Prompt Sequences</em> (zshmisc)). In combination with "-f", prompt escape sequences are parsed only within interpolated arguments, not within the format string.</p>
<p>- <strong><code>-r</code></strong> — Ignore the escape conventions of <code>echo</code>.</p>
<p>- <strong><code>-R</code></strong> — Emulate the BSD <code>echo</code> command, which does not process escape sequences unless the <code>-e</code> flag is given. The <code>-n</code> flag suppresses the trailing newline. Only the <code>-e</code> and <code>-n</code> flags are recognized after <code>-R</code>; all other arguments and options are printed.</p>
<p>- <strong><code>-s</code></strong> — Place the results in the history list instead of on the standard output. Each argument to the <code>print</code> command is treated as a single word in the history, regardless of its content.</p>
<p>- <strong><code>-S</code></strong> — Place the results in the history list instead of on the standard output. In this case only a single argument is allowed; it will be split into words as if it were a full shell command line. The effect is similar to reading the line from a history file with the <code>HIST_LEX_WORDS</code> option active.</p>
<p>- <strong><code>-u</code> <em>n</em></strong> — Print the arguments to file descriptor <em>n</em>.</p>
<p>- <strong><code>-v</code> <em>name</em></strong> — Store the printed arguments as the value of the parameter <em>name</em>.</p>
<p>- <strong><code>-x</code> <em>tab-stop</em></strong> — Expand leading tabs on each line of output in the printed string assuming a tab stop every <em>tab-stop</em> characters. This is appropriate for formatting code that may be indented with tabs. Note that leading tabs of any argument to print, not just the first, are expanded, even if <code>print</code> is using spaces to separate arguments (the column count is maintained across arguments but may be incorrect on output owing to previous unexpanded tabs).</p>
<p>The start of the output of each print command is assumed to be aligned with a tab stop. Widths of multibyte characters are handled if the option <code>MULTIBYTE</code> is in effect. This option is ignored if other formatting options are in effect, namely column alignment or <code>printf</code> style, or if output is to a special location such as shell history or the command line editor.</p>
<p>- <strong><code>-X</code> <em>tab-stop</em></strong> — This is similar to <code>-x</code>, except that all tabs in the printed string are expanded. This is appropriate if tabs in the arguments are being used to produce a table format.</p>
<p>- <strong><code>-z</code></strong> — Push the arguments onto the editing buffer stack, separated by spaces.</p>
<p>If any of "-m", "-o" or "-O" are used in combination with "-f" and there are no arguments (after the removal process in the case of "-m") then nothing is printed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-printf">
<h3><code>printf</code> <a class="doc-anchor" href="#doc-lsp-compat-printf">¶</a></h3>
<p>Print the arguments according to the format specification. Formatting rules are the same as used in C. The same escape sequences as for <code>echo</code> are recognised in the format. All C conversion specifications ending in one of <code>csdiouxXeEfgGn</code> are handled. In addition to this, "%b" can be used instead of "%s" to cause escape sequences in the argument to be recognised and "%q" can be used to quote the argument in such a way that allows it to be reused as shell input. With the numeric format specifiers, if the corresponding argument starts with a quote character, the numeric value of the following character is used as the number to print; otherwise the argument is evaluated as an arithmetic expression. See <em>Arithmetic Evaluation</em> (zshmisc) for a description of arithmetic expressions. With "%n", the corresponding argument is taken as an identifier which is created as an integer parameter.</p>
<p>Normally, conversion specifications are applied to each argument in order but they can explicitly specify the _n_th argument is to be used by replacing "%" by <code></code>%<code>_n_</code>$<code>' and "*" by </code><code>*</code><em>n</em><code>$</code>'. It is recommended that you do not mix references of this explicit style with the normal style and the handling of such mixed styles may be subject to future change.</p>
<p>If arguments remain unused after formatting, the format string is reused until all arguments have been consumed. With the <code>print</code> builtin, this can be suppressed by using the <code>-r</code> option. If more arguments are required by the format than have been specified, the behaviour is as if zero or an empty string had been specified as the argument.</p>
<p>The <code>-v</code> option causes the output to be stored as the value of the parameter <em>name</em>, instead of printed. If <em>name</em> is an array and the format string is reused when consuming arguments then one array element will be used for each use of the format string.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-private">
<h3><code>private</code> <a class="doc-anchor" href="#doc-lsp-compat-private">¶</a></h3>
<p>The <code>private</code> builtin accepts all the same options and arguments as <code>local</code> (nmref(Shell Builtin Commands)(zshbuiltins)) except for the <code></code>-"T" option. Tied parameters may not be made private.</p>
<p>The <code></code>-"p" option is presently disabled because the state of private parameters cannot reliably be reloaded. When <code></code>typeset -"p" outputs a private parameter, it is treated as a local with the <code></code>-"h" (hide) option enabled.</p>
<p>If used at the top level (outside a function scope), <code>private</code> creates a normal parameter in the same manner as <code>declare</code> or <code>typeset</code>. A warning about this is printed if <code>WARN_CREATE_GLOBAL</code> is set (nmref(Options)(zshoptions)). Used inside a function scope, <code>private</code> creates a local parameter similar to one declared with <code>local</code>, except having special properties noted below.</p>
<p>Special parameters which expose or manipulate internal shell state, such as <code>ARGC</code>, <code>argv</code>, <code>COLUMNS</code>, <code>LINES</code>, <code>UID</code>, <code>EUID</code>, <code>IFS</code>, <code>PROMPT</code>, <code>RANDOM</code>, <code>SECONDS</code>, etc., cannot be made private unless the <code></code>-"h" option is used to hide the special meaning of the parameter. This may change in the future.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pushd">
<h3><code>pushd</code> <a class="doc-anchor" href="#doc-lsp-compat-pushd">¶</a></h3>
<p>Change the current directory, and push the old current directory onto the directory stack. In the first form, change the current directory to <em>arg</em>. If <em>arg</em> is not specified, change to the second directory on the stack (that is, exchange the top two entries), or change to <code>$HOME</code> if the <code>PUSHD_TO_HOME</code> option is set or if there is only one entry on the stack. Otherwise, <em>arg</em> is interpreted as it would be by <code>cd</code>. The meaning of <em>old</em> and <em>new</em> in the second form is also the same as for <code>cd</code>.</p>
<p>The third form of <code>pushd</code> changes directory by rotating the directory list. An argument of the form <code></code>+"<em>n</em>" identifies a stack entry by counting from the left of the list shown by the <code>dirs</code> command, starting with zero. An argument of the form <code></code>-"<em>n</em>" counts from the right. If the <code>PUSHD_MINUS</code> option is set, the meanings of "+" and "-" in this context are swapped.</p>
<p>If the <code>-q</code> (quiet) option is specified, the hook function <code>chpwd</code> and the functions in the array <code>$chpwd_functions</code> are not called, and the new directory stack is not printed. This is useful for calls to <code>pushd</code> that do not change the environment seen by an interactive user.</p>
<p>If the option <code>-q</code> is not specified and the shell option <code>PUSHD_SILENT</code> is not set, the directory stack will be printed after a <code>pushd</code> is performed.</p>
<p>The options <code>-s</code>, <code>-L</code> and <code>-P</code> have the same meanings as for the <code>cd</code> builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pushln">
<h3><code>pushln</code> <a class="doc-anchor" href="#doc-lsp-compat-pushln">¶</a></h3>
<p>Equivalent to <code>print -nz</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-pwd">
<h3><code>pwd</code> <a class="doc-anchor" href="#doc-lsp-compat-pwd">¶</a></h3>
<p>Print the absolute pathname of the current working directory. If the <code>-r</code> or the <code>-P</code> flag is specified, or the <code>CHASE_LINKS</code> option is set and the <code>-L</code> flag is not given, the printed path will not contain symbolic links.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-r">
<h3><code>r</code> <a class="doc-anchor" href="#doc-lsp-compat-r">¶</a></h3>
<p>Re-execute the previous command. Shorthand for <code>fc -e -</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-read">
<h3><code>read</code> <a class="doc-anchor" href="#doc-lsp-compat-read">¶</a></h3>
<p>vindex(REPLY, use of) vindex(reply, use of) Read one line and break it into fields using the characters in <code>$IFS</code> as separators, except as noted below. The first field is assigned to the first <em>name</em>, the second field to the second <em>name</em>, etc., with leftover fields assigned to the last <em>name</em>. If <em>name</em> is omitted then <code>REPLY</code> is used for scalars and <code>reply</code> for arrays.</p>
<p>- <strong><code>-r</code></strong> — Raw mode: a "\" at the end of a line does not signify line continuation and backslashes in the line don't quote the following character and are not removed.</p>
<p>- <strong><code>-s</code></strong> — Don't echo back characters if reading from the terminal.</p>
<p>- <strong><code>-q</code></strong> — Read only one character from the terminal and set <em>name</em> to "y" if this character was "y" or "Y" and to "n" otherwise. With this flag set the return status is zero only if the character was "y" or "Y". This option may be used with a timeout (see <code>-t</code>); if the read times out, or encounters end of file, status 2 is returned. Input is read from the terminal unless one of <code>-u</code> or <code>-p</code> is present. This option may also be used within zle widgets.</p>
<p>- <strong><code>-k</code> [ <em>num</em> ]</strong> — Read only one (or <em>num</em>) characters. All are assigned to the first <em>name</em>, without word splitting. This flag is ignored when <code>-q</code> is present. Input is read from the terminal unless one of <code>-u</code> or <code>-p</code> is present. This option may also be used within zle widgets.</p>
<p>Note that despite the mnemonic "key" this option does read full characters, which may consist of multiple bytes if the option <code>MULTIBYTE</code> is set.</p>
<p>- <strong><code>-z</code></strong> — Read one entry from the editor buffer stack and assign it to the first <em>name</em>, without word splitting. Text is pushed onto the stack with "print -z" or with <code>push-line</code> from the line editor (see nmref(Zsh Line Editor)(zshzle)). This flag is ignored when the <code>-k</code> or <code>-q</code> flags are present.</p>
<p>- <strong><code>-e</code></strong></p>
<p>- <strong><code>-E</code></strong> — The input read is printed (echoed) to the standard output. If the <code>-e</code> flag is used, no input is assigned to the parameters.</p>
<p>- <strong><code>-A</code></strong> — The first <em>name</em> is taken as the name of an array and all words are assigned to it.</p>
<p>- <strong><code>-c</code></strong></p>
<p>- <strong><code>-l</code></strong> — These flags are allowed only if called inside a function used for completion (specified with the <code>-K</code> flag to <code>compctl</code>). If the <code>-c</code> flag is given, the words of the current command are read. If the <code>-l</code> flag is given, the whole line is assigned as a scalar. If both flags are present, <code>-l</code> is used and <code>-c</code> is ignored.</p>
<p>- <strong><code>-n</code></strong> — Together with <code>-c</code>, the number of the word the cursor is on is read. With <code>-l</code>, the index of the character the cursor is on is read. Note that the command name is word number 1, not word 0, and that when the cursor is at the end of the line, its character index is the length of the line plus one.</p>
<p>- <strong><code>-u</code> <em>n</em></strong> — Input is read from file descriptor <em>n</em>.</p>
<p>- <strong><code>-p</code></strong> — Input is read from the coprocess.</p>
<p>- <strong><code>-d</code> <em>delim</em></strong> — Input is terminated by the first character of <em>delim</em> instead of by newline. For compatibility with other shells, if <em>delim</em> is an empty string, input is terminated at the first NUL.</p>
<p>- <strong><code>-t</code> [ <em>num</em> ]</strong> — Test if input is available before attempting to read. If <em>num</em> is present, it must begin with a digit and will be evaluated to give a number of seconds, which may be a floating point number; in this case the read times out if input is not available within this time. If <em>num</em> is not present, it is taken to be zero, so that <code>read</code> returns immediately if no input is available. If no input is available, return status 1 and do not set any variables. ifzman( ) This option is not available when reading from the editor buffer with <code>-z</code>, when called from within completion with <code>-c</code> or <code>-l</code>, with <code>-q</code> which clears the input queue before reading, or within zle where other mechanisms should be used to test for input. ifzman( ) Note that read does not attempt to alter the input processing mode. The default mode is canonical input, in which an entire line is read at a time, so usually "read -t" will not read anything until an entire line has been typed. However, when reading from the terminal with <code>-k</code> input is processed one key at a time; in this case, only availability of the first character is tested, so that e.g. "read -t -k 2" can still block on the second character. Use two instances of "read -t -k" if this is not what is wanted.</p>
<p>If the first argument contains a "?", the remainder of this word is used as a <em>prompt</em> on standard error when the shell is interactive.</p>
<p>The value (exit status) of <code>read</code> is 1 when an end-of-file is encountered, or when <code>-c</code> or <code>-l</code> is present and the command is not called from a <code>compctl</code> function, or as described for <code>-q</code>. Otherwise the value is 0.</p>
<p>The behavior of some combinations of the <code>-k</code>, <code>-p</code>, <code>-q</code>, <code>-u</code> and <code>-z</code> flags is undefined. Presently <code>-q</code> cancels all the others, <code>-p</code> cancels <code>-u</code>, <code>-k</code> cancels <code>-z</code>, and otherwise <code>-z</code> cancels both <code>-p</code> and <code>-u</code>.</p>
<p>The <code>-c</code> or <code>-l</code> flags cancel any and all of <code>-kpquz</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-readonly">
<h3><code>readonly</code> <a class="doc-anchor" href="#doc-lsp-compat-readonly">¶</a></h3>
<p>Same as <code>typeset -r</code>. With the <code>POSIX_BUILTINS</code> option set, same as <code>typeset -gr</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-rehash">
<h3><code>rehash</code> <a class="doc-anchor" href="#doc-lsp-compat-rehash">¶</a></h3>
<p>If this is set when completing external commands, the internal list (hash) of commands will be updated for each search by issuing the <code>rehash</code> command. There is a speed penalty for this which is only likely to be noticeable when directories in the path have slow file access.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-return">
<h3><code>return</code> <a class="doc-anchor" href="#doc-lsp-compat-return">¶</a></h3>
<p>Causes a shell function or "." script to return to the invoking script with the return status specified by an arithmetic expression <em>n</em>. Also causes a non-interactive shell to exit, allowing files containing shell code to be used both as scripts and as autoloadable shell functions. For example, the following prints "42":</p>
<p>example(() { integer foo=40; return "foo + 2" } echo $?)</p>
<p>If <em>n</em> is omitted, the return status is that of the last command executed.</p>
<p>If <code>return</code> was executed from a trap in a <code>TRAP</code><em>NAL</em> function, the effect is different for zero and non-zero return status. With zero status (or after an implicit return at the end of the trap), the shell will return to whatever it was previously processing; with a non-zero status, the shell will behave as interrupted except that the return status of the trap is retained. Note that the numeric value of the signal which caused the trap is passed as the first argument, so the statement "return "128+$1"" will return the same status as if the signal had not been trapped.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-rm">
<h3><code>rm</code> <a class="doc-anchor" href="#doc-lsp-compat-rm">¶</a></h3>
<p>Removes files and directories specified.</p>
<p>Normally, <code>rm</code> will not remove directories (except with the <code>-R</code> or <code>-r</code> options). The <code>-d</code> option causes <code>rm</code> to try removing directories with <code>unlink</code> (see manref(unlink)(2)), the same method used for files. Typically only the super-user can actually succeed in unlinking directories in this way. <code>-d</code> takes precedence over <code>-R</code> and <code>-r</code>.</p>
<p>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 <code>-i</code> option causes the user to be queried about removing any files. The <code>-f</code> option causes files to be silently deleted, without querying, and suppresses all error indications. <code>-f</code> takes precedence.</p>
<p>The <code>-R</code> and <code>-r</code> options cause <code>rm</code> to recursively descend into directories, deleting all files in the directory before removing the directory with the <code>rmdir</code> system call (see manref(rmdir)(2)).</p>
<p>The <code>-s</code> option is a zsh extension to <code>rm</code> functionality. It enables paranoid behaviour, intended to avoid common security problems involving a root-run <code>rm</code> 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 <code>/etc/passwd</code> if <code>/tmp/foo</code> happens to be a link to <code>/etc</code>. 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 <code>/usr</code> as a result of directories being moved up the tree.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-rmdir">
<h3><code>rmdir</code> <a class="doc-anchor" href="#doc-lsp-compat-rmdir">¶</a></h3>
<p>Removes empty directories specified.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-sched">
<h3><code>sched</code> <a class="doc-anchor" href="#doc-lsp-compat-sched">¶</a></h3>
<p>Make an entry in the scheduled list of commands to execute. The time may be specified in either absolute or relative time, and either as hours, minutes and (optionally) seconds separated by a colon, or seconds alone. An absolute number of seconds indicates the time since the epoch (1970/01/01 00:00); this is useful in combination with the features in the <code>zsh/datetime</code> module, see <em>The zsh/datetime Module</em> (zshmodules).</p>
<p>With no arguments, prints the list of scheduled commands. If the scheduled command has the <code>-o</code> flag set, this is shown at the start of the command.</p>
<p>With the argument <code></code>-"<em>item</em>", removes the given item from the list. The numbering of the list is continuous and entries are in time order, so the numbering can change when entries are added or deleted.</p>
<p>Commands are executed either immediately before a prompt, or while the shell's line editor is waiting for input. In the latter case it is useful to be able to produce output that does not interfere with the line being edited. Providing the option <code>-o</code> causes the shell to clear the command line before the event and redraw it afterwards. This should be used with any scheduled event that produces visible output to the terminal; it is not needed, for example, with output that updates a terminal emulator's title bar.</p>
<p>To effect changes to the editor buffer when an event executes, use the "zle" command with no arguments to test whether the editor is active, and if it is, then use <code></code>zle "<em>widget</em>" to access the editor via the named <em>widget</em>.</p>
<p>The <code>sched</code> builtin is not made available by default when the shell starts in a mode emulating another shell. It can be made available with the command "zmodload -F zsh/sched b:sched".</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-set">
<h3><code>set</code> <a class="doc-anchor" href="#doc-lsp-compat-set">¶</a></h3>
<p>Set the options for the shell and/or set the positional parameters, or declare and set an array. If the <code>-s</code> option is given, it causes the specified arguments to be sorted before assigning them to the positional parameters (or to the array <em>name</em> if <code>-A</code> is used). With <code>+s</code> sort arguments in descending order. For the meaning of the other flags, see nmref(Options)(zshoptions). Flags may be specified by name using the <code>-o</code> option. If no option name is supplied with <code>-o</code>, the current option states are printed: see the description of <code>setopt</code> below for more information on the format. With <code>+o</code> they are printed in a form that can be used as input to the shell.</p>
<p>If the <code>-A</code> flag is specified, <em>name</em> is set to an array containing the given _arg_s; if no <em>name</em> is specified, all arrays are printed together with their values.</p>
<p>If <code>+A</code> is used and <em>name</em> is an array, the given arguments will replace the initial elements of that array; if no <em>name</em> is specified, all arrays are printed without their values.</p>
<p>The behaviour of arguments after <code>-A</code> <em>name</em> or <code>+A</code> <em>name</em> depends on whether the option <code>KSH_ARRAYS</code> is set. If it is not set, all arguments following <em>name</em> are treated as values for the array, regardless of their form. If the option is set, normal option processing continues at that point; only regular arguments are treated as values for the array. This means that</p>
<p> set -A array -x -- foo</p>
<p>sets <code>array</code> to <code></code>-x -"- foo" if <code>KSH_ARRAYS</code> is not set, but sets the array to <code>foo</code> and turns on the option "-x" if it is set.</p>
<p>If the <code>-A</code> flag is not present, but there are arguments beyond the options, the positional parameters are set. If the option list (if any) is terminated by <code></code>-"-", and there are no further arguments, the positional parameters will be unset.</p>
<p>If no arguments and no <code></code>-"-" are given, then the names and values of all parameters are printed on the standard output. If the only argument is "+", the names of all parameters are printed.</p>
<p>For historical reasons, "set -" is treated as "set +xv" and <code></code>set -" <em>args</em>" as <code></code>set +xv --" <em>args</em>" when in any other emulation mode than zsh's native mode.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-setcap">
<h3><code>setcap</code> <a class="doc-anchor" href="#doc-lsp-compat-setcap">¶</a></h3>
<p>This is a built-in implementation of the POSIX standard utility. It sets the capability sets on each specified <em>filename</em> to the specified <em>capabilities</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-setopt">
<h3><code>setopt</code> <a class="doc-anchor" href="#doc-lsp-compat-setopt">¶</a></h3>
<p>Set the options for the shell. All options specified either with flags or by name are set.</p>
<p>If no arguments are supplied, the names of all options currently set are printed. The form is chosen so as to minimize the differences from the default options for the current emulation (the default emulation being native <code>zsh</code>, shown as <code><Z></code> in <em>Description of Options</em> (zshoptions)). Options that are on by default for the emulation are shown with the prefix <code>no</code> only if they are off, while other options are shown without the prefix <code>no</code> and only if they are on. In addition to options changed from the default state by the user, any options activated automatically by the shell (for example, <code>SHIN_STDIN</code> or <code>INTERACTIVE</code>) will be shown in the list. The format is further modified by the option <code>KSH_OPTION_PRINT</code>, however the rationale for choosing options with or without the <code>no</code> prefix remains the same in this case.</p>
<p>If the <code>-m</code> flag is given the arguments are taken as patterns (which should be quoted to protect them from filename expansion), and all options with names matching these patterns are set.</p>
<p>Note that a bad option name does not cause execution of subsequent shell code to be aborted; this is behaviour is different from that of <code></code>set -o<code>'. This is because </code>set<code> is regarded as a special builtin by the POSIX standard, but </code>setopt<code> is not.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-compat-shift">
<h3><code>shift</code> <a class="doc-anchor" href="#doc-lsp-compat-shift">¶</a></h3>
<p>The positional parameters <code>${</code><em>n</em>+1tt(}) ... are renamed to <code>$1</code> ..., where <em>n</em> is an arithmetic expression that defaults to 1. If any _name_s are given then the arrays with these names are shifted instead of the positional parameters.</p>
<p>If the option <code>-p</code> is given arguments are instead removed (popped) from the end rather than the start of the array.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-source">
<h3><code>source</code> <a class="doc-anchor" href="#doc-lsp-compat-source">¶</a></h3>
<p>Same as ".", except that the current directory is always searched and is always searched first, before directories in <code>$path</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-stat">
<h3><code>stat</code> <a class="doc-anchor" href="#doc-lsp-compat-stat">¶</a></h3>
<p>The command acts as a front end to the <code>stat</code> system call (see manref(stat)(2)). The same command is provided with two names; as the name <code>stat</code> is often used by an external command it is recommended that only the <code>zstat</code> form of the command is used. This can be arranged by loading the module with the command <code></code>zmodload -F zsh/stat b:zstat<code>'.</code></p>
<p>If the <code>stat</code> call fails, the appropriate system error message printed and status 1 is returned. The fields of <code>struct stat</code> give information about the files provided as arguments to the command. In addition to those available from the <code>stat</code> call, an extra element "link" is provided. These elements are:</p>
<p>- <strong><code>device</code></strong> — The number of the device on which the file resides.</p>
<p>- <strong><code>inode</code></strong> — The unique number of the file on this device ("<em>inode</em>" number).</p>
<p>- <strong><code>mode</code></strong> — The mode of the file; that is, the file's type and access permissions. With the <code>-s</code> option, this will be returned as a string corresponding to the first column in the display of the <code>ls -l</code> command.</p>
<p>- <strong><code>nlink</code></strong> — The number of hard links to the file.</p>
<p>- <strong><code>uid</code></strong> — The user ID of the owner of the file. With the <code>-s</code> option, this is displayed as a user name.</p>
<p>- <strong><code>gid</code></strong> — The group ID of the file. With the <code>-s</code> option, this is displayed as a group name.</p>
<p>- <strong><code>rdev</code></strong> — The raw device number. This is only useful for special devices.</p>
<p>- <strong><code>size</code></strong> — The size of the file in bytes.</p>
<p>- <strong><code>atime</code></strong></p>
<p>- <strong><code>mtime</code></strong></p>
<p>- <strong><code>ctime</code></strong> — The last access, modification and inode change times of the file, respectively, as the number of seconds since midnight GMT on 1st January, 1970. With the <code>-s</code> option, these are printed as strings for the local time zone; the format can be altered with the <code>-F</code> option, and with the <code>-g</code> option the times are in GMT.</p>
<p>- <strong><code>blksize</code></strong> — The number of bytes in one allocation block on the device on which the file resides.</p>
<p>- <strong><code>block</code></strong> — The number of disk blocks used by the file.</p>
<p>- <strong><code>link</code></strong> — If the file is a link and the <code>-L</code> option is in effect, this contains the name of the file linked to, otherwise it is empty. Note that if this element is selected (""zstat +link"") then the <code>-L</code> option is automatically used.</p>
<p>A particular element may be selected by including its name preceded by a "+" 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.</p>
<p>Options:</p>
<p>- <strong><code>-A</code> <em>array</em></strong> — Instead of displaying the results on standard output, assign them to an <em>array</em>, one <code>struct stat</code> element per array element for each file in order. In this case neither the name of the element nor the name of the files appears in <em>array</em> unless the <code>-t</code> or <code>-n</code> options were given, respectively. If <code>-t</code> is given, the element name appears as a prefix to the appropriate array element; if <code>-n</code> is given, the file name appears as a separate array element preceding all the others. Other formatting options are respected.</p>
<p>- <strong><code>-H</code> <em>hash</em></strong> — Similar to <code>-A</code>, but instead assign the values to <em>hash</em>. The keys are the elements listed above. If the <code>-n</code> option is provided then the name of the file is included in the hash with key <code>name</code>.</p>
<p>- <strong><code>-f</code> <em>fd</em></strong> — Use the file on file descriptor <em>fd</em> instead of named files; no list of file names is allowed in this case.</p>
<p>- <strong><code>-F</code> <em>fmt</em></strong> — Supplies a <code>strftime</code> (see manref(strftime)(3)) string for the formatting of the time elements. The format string supports all of the zsh extensions (see the description of <code>%D{</code><em>string</em><code>}</code> prompt escape in <em>Simple Prompt Escapes</em> (zshmisc)). In particular, <code>-F %s.%N</code> can be used to show timestamps with nanosecond precision if supported by the system. The <code>-s</code> option is implied.</p>
<p>- <strong><code>-g</code></strong> — Show the time elements in the GMT time zone. The <code>-s</code> option is implied.</p>
<p>- <strong><code>-l</code></strong> — List the names of the type elements (to standard output or an array as appropriate) and return immediately; arguments, and options other than <code>-A</code>, are ignored.</p>
<p>- <strong><code>-L</code></strong> — Perform an <code>lstat</code> (see manref(lstat)(2)) rather than a <code>stat</code> 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 <code>link</code> element useful. It's important to note that this is the exact opposite from manref(ls)(1), etc.</p>
<p>- <strong><code>-n</code></strong> — Always show the names of files. Usually these are only shown when output is to standard output and there is more than one file in the list.</p>
<p>- <strong><code>-N</code></strong> — Never show the names of files.</p>
<p>- <strong><code>-o</code></strong> — If a raw file mode is printed, show it in octal, which is more useful for human consumption than the default of decimal. A leading zero will be printed in this case. Note that this does not affect whether a raw or formatted file mode is shown, which is controlled by the <code>-r</code> and <code>-s</code> options, nor whether a mode is shown at all.</p>
<p>- <strong><code>-r</code></strong> — Print raw data (the default format) alongside string data (the <code>-s</code> format); the string data appears in parentheses after the raw data.</p>
<p>- <strong><code>-s</code></strong> — Print <code>mode</code>, <code>uid</code>, <code>gid</code> and the three time elements as strings instead of numbers. In each case the format is like that of <code>ls -l</code>.</p>
<p>- <strong><code>-t</code></strong> — Always show the type names for the elements of <code>struct stat</code>. Usually these are only shown when output is to standard output and no individual element has been selected.</p>
<p>- <strong><code>-T</code></strong> — Never show the type names of the <code>struct stat</code> elements.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-strftime">
<h3><code>strftime</code> <a class="doc-anchor" href="#doc-lsp-compat-strftime">¶</a></h3>
<p>Output the date in the <em>format</em> specified. With no <em>epochtime</em>, the current system date/time is used; optionally, <em>epochtime</em> may be used to specify the number of seconds since the epoch, and <em>nanoseconds</em> may additionally be used to specify the number of nanoseconds past the second (otherwise that number is assumed to be 0). See manref(strftime)(3) for details. The zsh extensions described under <code>%D{</code><em>string</em><code>}</code> prompt eqcape in <em>Simple Prompt Escapes</em> (zshmisc) are also available.</p>
<p>- <strong><code>-n</code></strong> — Suppress printing a newline after the formatted string.</p>
<p>- <strong><code>-q</code></strong> — Run quietly; suppress printing of all error messages described below. Errors for invalid <em>epochtime</em> values are always printed.</p>
<p>- <strong><code>-r</code></strong> — With the option <code>-r</code> (reverse), use <em>format</em> to parse the input string <em>timestring</em> and output the number of seconds since the epoch at which the time occurred. The parsing is implemented by the system function <code>strptime</code>; see manref(strptime)(3). This means that zsh format extensions are not available, but for reverse lookup they are not required.</p>
<p>In most implementations of <code>strptime</code> any timezone in the <em>timestring</em> is ignored and the local timezone declared by the <code>TZ</code> environment variable is used; other parameters are set to zero if not present.</p>
<p>If <em>timestring</em> does not match <em>format</em> the command returns status 1 and prints an error message. If <em>timestring</em> matches <em>format</em> but not all characters in <em>timestring</em> were used, the conversion succeeds but also prints an error message.</p>
<p>If either of the system functions <code>strptime</code> or <code>mktime</code> is not available, status 2 is returned and an error message is printed.</p>
<p>- <strong><code>-s</code> <em>scalar</em></strong> — Assign the date string (or epoch time in seconds if <code>-r</code> is given) to <em>scalar</em> instead of printing it.</p>
<p>Note that depending on the system's declared integral time type, <code>strftime</code> may produce incorrect results for epoch times greater than 2147483647 which corresponds to 2038-01-19 03:14:07 +0000.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-suspend">
<h3><code>suspend</code> <a class="doc-anchor" href="#doc-lsp-compat-suspend">¶</a></h3>
<p>Suspend the execution of the shell (send it a <code>SIGTSTP</code>) until it receives a <code>SIGCONT</code>. Unless the <code>-f</code> option is given, this will refuse to suspend a login shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-sync">
<h3><code>sync</code> <a class="doc-anchor" href="#doc-lsp-compat-sync">¶</a></h3>
<p>Calls the system call of the same name (see manref(sync)(2)), which flushes dirty buffers to disk. It might return before the I/O has actually been completed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-syserror">
<h3><code>syserror</code> <a class="doc-anchor" href="#doc-lsp-compat-syserror">¶</a></h3>
<p>This command prints out the error message associated with <em>errno</em>, a system error number, followed by a newline to standard error.</p>
<p>Instead of the error number, a name <em>errname</em>, for example <code>ENOENT</code>, may be used. The set of names is the same as the contents of the array <code>errnos</code>, see below.</p>
<p>If the string <em>prefix</em> is given, it is printed in front of the error message, with no intervening space.</p>
<p>If <em>errvar</em> is supplied, the entire message, without a newline, is assigned to the parameter names <em>errvar</em> and nothing is output.</p>
<p>A return status of 0 indicates the message was successfully printed (although it may not be useful if the error number was out of the system's range), a return status of 1 indicates an error in the parameters, and a return status of 2 indicates the error name was not recognised (no message is printed for this).</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-sysopen">
<h3><code>sysopen</code> <a class="doc-anchor" href="#doc-lsp-compat-sysopen">¶</a></h3>
<p>This command opens a file. The <code>-r</code>, <code>-w</code> and <code>-a</code> flags indicate whether the file should be opened for reading, writing and appending, respectively. The <code>-m</code> option allows the initial permissions to use when creating a file to be specified in octal form. The file descriptor is specified with <code>-u</code>. Either an explicit file descriptor in the range 0 to 9 can be specified or a variable name can be given to which the file descriptor number will be assigned.</p>
<p>The <code>-o</code> option allows various system specific options to be specified as a comma-separated list. The following is a list of possible options. Note that, depending on the system, some may not be available.</p>
<p>- <strong><code>cloexec</code></strong> — mark file to be closed when other programs are executed (else the file descriptor remains open in subshells and forked external executables)</p>
<p>- <strong><code>create</code></strong></p>
<p>- <strong><code>creat</code></strong> — create file if it does not exist</p>
<p>- <strong><code>excl</code></strong> — create file, error if it already exists</p>
<p>- <strong><code>noatime</code></strong> — suppress updating of the file atime</p>
<p>- <strong><code>nofollow</code></strong> — fail if <em>file</em> is a symbolic link</p>
<p>- <strong><code>nonblock</code></strong> — the file is opened in nonblocking mode</p>
<p>- <strong><code>sync</code></strong> — request that writes wait until data has been physically written</p>
<p>- <strong><code>truncate</code></strong></p>
<p>- <strong><code>trunc</code></strong> — truncate file to size 0</p>
<p>A return status of 0 indicates the descriptor was successfully opened, otherwise an error message is printed, and 1 is returned for an error in the parameters to the command, or 2 is returned for a system error. The parameter <code>ERRNO</code> is nonzero for system errors.</p>
<p>To close the file, use one of the following:</p>
<p> <code>exec {</code><em>fd</em><code>}<&-</code> <code>exec {</code><em>fd</em><code>}>&-</code></p>
</article>
<article class="doc-entry" id="doc-lsp-compat-sysread">
<h3><code>sysread</code> <a class="doc-anchor" href="#doc-lsp-compat-sysread">¶</a></h3>
<p>Perform a single system read from file descriptor <em>infd</em>, or zero if that is not given. The result of the read is stored in <em>param</em> or <code>REPLY</code> if that is not given. If <em>countvar</em> is given, the number of bytes read is assigned to the parameter named by <em>countvar</em>.</p>
<p>The maximum number of bytes read is <em>bufsize</em> or 8192 if that is not given, however the command returns as soon as any number of bytes was successfully read.</p>
<p>If <em>timeout</em> is given, it specifies a timeout in seconds, which may be zero to poll the file descriptor. This is handled by the <code>poll</code> system call if available, otherwise the <code>select</code> system call if available.</p>
<p>If <em>outfd</em> is given, an attempt is made to write all the bytes just read to the file descriptor <em>outfd</em>. If this fails, because of a system error other than <code>EINTR</code> or because of an internal zsh error during an interrupt, the bytes read but not written are stored in the parameter named by <em>param</em> if supplied (no default is used in this case), and the number of bytes read but not written is stored in the parameter named by <em>countvar</em> if that is supplied. If it was successful, <em>countvar</em> contains the full number of bytes transferred, as usual, and <em>param</em> is not set.</p>
<p>The error <code>EINTR</code> (interrupted system call) is handled internally so that shell interrupts are transparent to the caller. Any other error causes a return.</p>
<p>The possible return statuses are</p>
<p>- <strong>0</strong> — At least one byte of data was successfully read and, if appropriate, written.</p>
<p>- <strong>1</strong> — There was an error in the parameters to the command. This is the only error for which a message is printed to standard error.</p>
<p>- <strong>2</strong> — There was an error on the read, or on polling the input file descriptor for a timeout. The parameter <code>ERRNO</code> identifies the error.</p>
<p>- <strong>3</strong> — Data were successfully read, but there was an error writing them to <em>outfd</em>. The parameter <code>ERRNO</code> identifies the error.</p>
<p>- <strong>4</strong> — The attempt to read timed out. Note this does not set <code>ERRNO</code> as this is not a system error.</p>
<p>- <strong>5</strong> — No system error occurred, but zero bytes were read. This usually indicates end of file. The parameters are set according to the usual rules; no write to <em>outfd</em> is attempted.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-sysseek">
<h3><code>sysseek</code> <a class="doc-anchor" href="#doc-lsp-compat-sysseek">¶</a></h3>
<p>The current file position at which future reads and writes will take place is adjusted to the specified byte offset. The <em>offset</em> is evaluated as a math expression. The <code>-u</code> option allows the file descriptor to be specified. By default the offset is specified relative to the start or the file but, with the <code>-w</code> option, it is possible to specify that the offset should be relative to the current position or the end of the file.</p>
<p>The return status may be 0 for success, 1 for an error in the parameters to the command, or 2 for an error on the seek; no error message is printed in the last case, but the parameter <code>ERRNO</code> reflects the error that occurred.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-syswrite">
<h3><code>syswrite</code> <a class="doc-anchor" href="#doc-lsp-compat-syswrite">¶</a></h3>
<p>The data (a single string of bytes) are written to the file descriptor <em>outfd</em>, or 1 if that is not given, using the <code>write</code> system call. Multiple write operations may be used if the first does not write all the data.</p>
<p>If <em>countvar</em> is given, the number of byte written is stored in the parameter named by <em>countvar</em>; this may not be the full length of <em>data</em> if an error occurred.</p>
<p>The error <code>EINTR</code> (interrupted system call) is handled internally by retrying; otherwise an error causes the command to return. For example, if the file descriptor is set to non-blocking output, an error <code>EAGAIN</code> (on some systems, <code>EWOULDBLOCK</code>) may result in the command returning early.</p>
<p>The return status may be 0 for success, 1 for an error in the parameters to the command, or 2 for an error on the write; no error message is printed in the last case, but the parameter <code>ERRNO</code> reflects the error that occurred.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-test">
<h3><code>test</code> <a class="doc-anchor" href="#doc-lsp-compat-test">¶</a></h3>
<p>Like the system version of <code>test</code>. Added for compatibility; use conditional expressions instead (see <em>Conditional Expressions</em> (zshmisc)). The main differences between the conditional expression syntax and the <code>test</code> and <code>[</code> builtins are: these commands are not handled syntactically, so for example an empty variable expansion may cause an argument to be omitted; syntax errors cause status 2 to be returned instead of a shell error; and arithmetic operators expect integer arguments rather than arithmetic expressions.</p>
<p>The command attempts to implement POSIX and its extensions where these are specified. Unfortunately there are intrinsic ambiguities in the syntax; in particular there is no distinction between test operators and strings that resemble them. The standard attempts to resolve these for small numbers of arguments (up to four); for five or more arguments compatibility cannot be relied on. Users are urged wherever possible to use the "[[" test syntax which does not have these ambiguities.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-times">
<h3><code>times</code> <a class="doc-anchor" href="#doc-lsp-compat-times">¶</a></h3>
<p>Print the accumulated user and system times for the shell and for processes run from the shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-trap">
<h3><code>trap</code> <a class="doc-anchor" href="#doc-lsp-compat-trap">¶</a></h3>
<p><em>arg</em> is a series of commands (usually quoted to protect it from immediate evaluation by the shell) to be read and executed when the shell receives any of the signals specified by one or more <em>sig</em> args. Each <em>sig</em> can be given as a number, or as the name of a signal either with or without the string <code>SIG</code> in front (e.g. 1, HUP, and SIGHUP are all the same signal).</p>
<p>If <em>arg</em> is "-", then the specified signals are reset to their defaults, or, if no <em>sig</em> args are present, all traps are reset.</p>
<p>If <em>arg</em> is an empty string, then the specified signals are ignored by the shell (and by the commands it invokes).</p>
<p>If <em>arg</em> is omitted but one or more <em>sig</em> args are provided (i.e. the first argument is a valid signal number or name), the effect is the same as if <em>arg</em> had been specified as "-".</p>
<p>The <code>trap</code> command with no arguments prints a list of commands associated with each signal.</p>
<p>If <em>sig</em> is <code>ZERR</code> then <em>arg</em> will be executed after each command with a nonzero exit status. <code>ERR</code> is an alias for <code>ZERR</code> on systems that have no <code>SIGERR</code> signal (this is the usual case).</p>
<p>If <em>sig</em> is <code>DEBUG</code> then <em>arg</em> will be executed before each command if the option <code>DEBUG_BEFORE_CMD</code> is set (as it is by default), else after each command. Here, a "command" is what is described as a "sublist" in the shell grammar, see <em>Simple Commands & Pipelines</em> (zshmisc). If <code>DEBUG_BEFORE_CMD</code> is set various additional features are available. First, it is possible to skip the next command by setting the option <code>ERR_EXIT</code>; see the description of the <code>ERR_EXIT</code> option in nmref(Description of Options)(zshoptions). Also, the shell parameter <code>ZSH_DEBUG_CMD</code> is set to the string corresponding to the command to be executed following the trap. Note that this string is reconstructed from the internal format and may not be formatted the same way as the original text. The parameter is unset after the trap is executed.</p>
<p>If <em>sig</em> is <code>0</code> or <code>EXIT</code> and the <code>trap</code> statement is executed inside the body of a function, then the command <em>arg</em> is executed after the function completes. The value of <code>$?</code> at the start of execution is the exit status of the shell or the return status of the function exiting. If <em>sig</em> is <code>0</code> or <code>EXIT</code> and the <code>trap</code> statement is not executed inside the body of a function, then the command <em>arg</em> is executed when the shell terminates; the trap runs before any <code>zshexit</code> hook functions.</p>
<p><code>ZERR</code>, <code>DEBUG</code>, and <code>EXIT</code> traps are not executed inside other traps. <code>ZERR</code> and <code>DEBUG</code> traps are kept within subshells, while other traps are reset.</p>
<p>Note that traps defined with the <code>trap</code> builtin are slightly different from those defined as <code></code>TRAP"<em>NAL</em> () { ... }", as the latter have their own function environment (line numbers, local variables, etc.) while the former use the environment of the command in which they were called. For example,</p>
<p> trap 'print $LINENO' DEBUG</p>
<p>will print the line number of a command executed after it has run, while</p>
<p>example(TRAPDEBUG+() { print $LINENO; })</p>
<p>will always print the number zero.</p>
<p>Alternative signal names are allowed as described under <code>kill</code> above. Defining a trap under either name causes any trap under an alternative name to be removed. However, it is recommended that for consistency users stick exclusively to one name or another.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-true">
<h3><code>true</code> <a class="doc-anchor" href="#doc-lsp-compat-true">¶</a></h3>
<p>Do nothing and return an exit status of 0.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-ttyctl">
<h3><code>ttyctl</code> <a class="doc-anchor" href="#doc-lsp-compat-ttyctl">¶</a></h3>
<p>The <code>-f</code> option freezes the tty (i.e. terminal or terminal emulator), and <code>-u</code> unfreezes it. When the tty is frozen, no changes made to the tty settings by external programs will be honored by the shell, except for changes in the size of the screen; the shell will simply reset the settings to their previous values as soon as each command exits or is suspended. Thus, <code>stty</code> and similar programs have no effect when the tty is frozen. Freezing the tty does not cause the current state to be remembered: instead, it causes future changes to the state to be blocked.</p>
<p>Without options it reports whether the terminal is frozen or not.</p>
<p>Note that, regardless of whether the tty is frozen or not, the shell needs to change the settings when the line editor starts, so unfreezing the tty does not guarantee settings made on the command line are preserved. Strings of commands run between editing the command line will see a consistent tty state. See also the shell variable <code>STTY</code> for a means of initialising the tty before running external commands and/or freezing the tty around a single command.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-type">
<h3><code>type</code> <a class="doc-anchor" href="#doc-lsp-compat-type">¶</a></h3>
<p>Equivalent to <code>whence -v</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-typeset">
<h3><code>typeset</code> <a class="doc-anchor" href="#doc-lsp-compat-typeset">¶</a></h3>
<p>Set or display attributes and values for shell parameters.</p>
<p>Except as noted below for control flags that change the behavior, a parameter is created for each <em>name</em> that does not already refer to one. When inside a function, a new parameter is created for every <em>name</em> (even those that already exist), and is unset again when the function completes. See <em>Local Parameters</em> (zshparam). The same rules apply to special shell parameters, which retain their special attributes when made local.</p>
<p>For each <em>name</em><code>=</code><em>value</em> assignment, the parameter <em>name</em> is set to <em>value</em>. If the assignment is omitted and <em>name</em> does <em>not</em> refer to an existing parameter, a new parameter is initialized to empty string, zero, or empty array (as appropriate), <em>unless</em> the shell option <code>TYPESET_TO_UNSET</code> is set. When that option is set, the parameter attributes are recorded but the parameter remains unset.</p>
<p>If the shell option <code>TYPESET_SILENT</code> is not set, for each remaining <em>name</em> that refers to a parameter that is already set, the name and value of the parameter are printed in the form of an assignment. Nothing is printed for newly-created parameters, or when any attribute flags listed below are given along with the <em>name</em>. Using "+" instead of minus to introduce an attribute turns it off.</p>
<p>If no <em>name</em> is present, the names and values of all parameters are printed. In this case the attribute flags restrict the display to only those parameters that have the specified attributes, and using "+" rather than "-" to introduce the flag suppresses printing of the values of parameters when there is no parameter name.</p>
<p>All forms of the command handle scalar assignment. Array assignment is possible if any of the reserved words <code>declare</code>, <code>export</code>, <code>float</code>, <code>integer</code>, <code>local</code>, <code>readonly</code> or <code>typeset</code> is matched when the line is parsed (N.B. not when it is executed). In this case the arguments are parsed as assignments, except that the "+=" syntax and the <code>GLOB_ASSIGN</code> option are not supported, and scalar values after <code>=</code> are <em>not</em> split further into words, even if expanded (regardless of the setting of the <code>KSH_TYPESET</code> option; this option is obsolete).</p>
<p>Examples of the differences between command and reserved word parsing:</p>
<p>example(# Reserved word parsing typeset svar=$(echo one word) avar=(several words))</p>
<p>The above creates a scalar parameter <code>svar</code> and an array parameter <code>avar</code> as if the assignments had been</p>
<p>example(svar="one word" avar=(several words))</p>
<p>On the other hand:</p>
<p>example(# Normal builtin interface builtin typeset svar=$(echo two words))</p>
<p>The <code>builtin</code> keyword causes the above to use the standard builtin interface to <code>typeset</code> in which argument parsing is performed in the same way as for other commands. This example creates a scalar <code>svar</code> containing the value <code>two</code> and another scalar parameter <code>words</code> with no value. An array value in this case would either cause an error or be treated as an obscure set of glob qualifiers.</p>
<p>Arbitrary arguments are allowed if they take the form of assignments after command line expansion; however, these only perform scalar assignment:</p>
<p> var='svar=val' typeset $var</p>
<p>The above sets the scalar parameter <code>svar</code> to the value <code>val</code>. Parentheses around the value within <code>var</code> would not cause array assignment as they will be treated as ordinary characters when <code>$var</code> is substituted. Any non-trivial expansion in the name part of the assignment causes the argument to be treated in this fashion:</p>
<p> typeset {var1,var2,var3}=name</p>
<p>The above syntax is valid, and has the expected effect of setting the three parameters to the same value, but the command line is parsed as a set of three normal command line arguments to <code>typeset</code> after expansion. Hence it is not possible to assign to multiple arrays by this means.</p>
<p>Note that each interface to any of the commands may be disabled separately. For example, "disable -r typeset" disables the reserved word interface to <code>typeset</code>, exposing the builtin interface, while "disable typeset" disables the builtin. Note that disabling the reserved word interface for <code>typeset</code> may cause problems with the output of "typeset -p", which assumes the reserved word interface is available in order to restore array and associative array values.</p>
<p>Unlike parameter assignment statements, <code>typeset</code>'s exit status on an assignment that involves a command substitution does not reflect the exit status of the command substitution. Therefore, to test for an error in a command substitution, separate the declaration of the parameter from its initialization:</p>
<p>example(# WRONG typeset var1=$(exit 1) || echo "Trouble with var1"</p>
<p># RIGHT typeset var1 && var1=$(exit 1) || echo "Trouble with var1" )</p>
<p>To initialize a parameter <em>param</em> to a command output and mark it readonly, use <code>typeset -r </code><em>param</em> or <code>readonly </code><em>param</em> after the parameter assignment statement.</p>
<p>cindex(named reference) cindex(reference, named) The flag <code>-n</code> creates a <em>named reference</em> to another parameter. The second parameter need not exist at the time the reference is created. Only the <code>-H</code>, <code>-g</code>, and <code>-r</code> flags may be used in conjunction with <code>-n</code>, having their usual meanings. The <code>-u</code> flag is special and may be applied to alter the scope of the reference. The <em>name</em> so created may not be an array element nor use a subscript, but the <em>value</em> assigned may be any valid parameter name syntax, even a subscripted array element (including an associative array element) or an array slice, which is evaluated when the named reference is expanded. It is an error for a named reference to refer to itself, even indirectly through a chain of references. When <code>-u</code> is applied to a named reference, the parameter identified by <em>value</em> is always found in the calling function scope rather than the current local scope. In this case, if there is no such parameter in the calling scope, assignments to the named reference may fail, setting <code>$?</code> to 1. See <em>Parameter Expansion</em> (zshexpn) and <em>Named References</em> (zshparam) for details of the behavior of named references.</p>
<p>Local function scoping rules for "typeset" do apply with "-n", so a declaration within a function persists only until the end of the function unless "-g -n" is specified, and any local parameter (of any type) with the same <em>name</em> supplants a named reference from a surrounding scope.</p>
<p>A scalar parameter, including an existing named reference, may be converted to a new named reference by <code></code>typeset -n "<em>name</em>", so the "-p" option must be included to display the value of a specific named reference <em>name</em>.</p>
<p>If no attribute flags are given, and either no <em>name</em> arguments are present or the flag <code>+m</code> is used, then each parameter name printed is preceded by a list of the attributes of that parameter (<code>array</code>, <code>association</code>, <code>exported</code>, <code>float</code>, <code>integer</code>, <code>readonly</code>, or <code>undefined</code> for autoloaded parameters not yet loaded). If <code>+m</code> is used with attribute flags, and all those flags are introduced with <code>+</code>, the matching parameter names are printed but their values are not.</p>
<p>The following control flags change the behavior of <code>typeset</code>:</p>
<p>- <strong><code>+</code></strong> — If "+" appears by itself in a separate word as the last option, then the names of all parameters (functions with <code>-f</code>) are printed, but the values (function bodies) are not. If <em>name</em> arguments appear, both those names and their values are printed in the form of assignments. It is an error for any other options to follow "+", but the effect of "+" is as if all attribute flags which precede it were given with a "+" prefix. For example, "typeset -U +" is equivalent to "typeset +U" and displays the names of all arrays having the uniqueness attribute, whereas "typeset -f -U +" displays the names of all autoloadable functions. If <code>+</code> is the only option, then type information (array, readonly, etc.) is also printed for each parameter, in the same manner as "typeset +m "*"".</p>
<p>- <strong><code>-g</code></strong> — The <code>-g</code> (global) means that any resulting parameter will not be restricted to local scope. Note that this does not necessarily mean that the parameter will be global, as the flag will apply to any existing parameter (even if unset) from an enclosing function. This flag does not affect the parameter after creation, hence it has no effect when listing existing parameters, nor does the flag <code>+g</code> have any effect except in combination with <code>-m</code> (see below).</p>
<p>- <strong><code>-m</code></strong> — If the <code>-m</code> flag is given the <em>name</em> arguments are taken as patterns (use quoting to prevent these from being interpreted as file patterns). With no attribute flags, all parameters (or functions with the <code>-f</code> flag) with matching names are printed (the shell option <code>TYPESET_SILENT</code> is not used in this case).</p>
<p>If the <code>+g</code> flag is combined with <code>-m</code>, a new local parameter is created for every matching parameter that is not already local. Otherwise <code>-m</code> applies all other flags or assignments to the existing parameters, except that the <code>-n</code> option cannot create named references in this way.</p>
<p>Except when assignments are made with <em>name</em><code>=</code><em>value</em>, using <code>+m</code> forces the matching parameters and their attributes to be printed, even inside a function. Note that <code>-m</code> is ignored if no patterns are given, so "typeset -m" displays attributes but "typeset -a +m" does not. Ordinary scalar string parameters have no attributes, so for those <code>+m</code> prints only the names.</p>
<p>- <strong><code>-p</code> [ <em>n</em> ]</strong> — If the <code>-p</code> option is given, parameters and values are printed in the form of a typeset command with an assignment, regardless of other flags and options. Note that the <code>-H</code> flag on parameters is respected; no value will be shown for these parameters.</p>
<p><code>-p</code> may be followed by an optional integer argument. Currently only the value <code>1</code> is supported. In this case arrays and associative arrays are printed with newlines between indented elements for readability.</p>
<p>The names and values of readonly special parameters (most of the parameters marked "<S>" in <em>Parameters Set by the Shell</em> (zshparam), except those documented as settable) are not printed with <code></code>-"p" because to execute those typeset commands would cause errors. However, these parameters are printed when they have been made local to the scope where "typeset -p" is run.</p>
<p>- <strong><code>-T</code> [ <em>scalar</em>[<code>=</code><em>value</em>] <em>array</em>[<code>=()_value_ ...</code><code></code>] [ <em>sep</em> ] ]</strong> — This flag has a different meaning when used with <code>-f</code>; see below. Otherwise the <code>-T</code> option requires zero, two, or three arguments to be present. With no arguments, the list of parameters created in this fashion is shown. With two or three arguments, the first two are the name of a scalar and of an array parameter (in that order) that will be tied together in the manner of <code>$PATH</code> and <code>$path</code>. The optional third argument is a single-character separator which will be used to join the elements of the array to form the scalar; if absent, a colon is used, as with <code>$PATH</code>. Only the first character of the separator is significant; any remaining characters are ignored. Multibyte characters are not yet supported.</p>
<p>Only one of the scalar and array parameters may be assigned an initial value (the restrictions on assignment forms described above also apply).</p>
<p>Both the scalar and the array may be manipulated as normal. If one is unset, the other will automatically be unset too. There is no way of untying the variables without unsetting them, nor of converting the type of one of them with another <code>typeset</code> command; <code>+T</code> does not work, assigning an array to <em>scalar</em> is an error, and assigning a scalar to <em>array</em> sets it to be a single-element array.</p>
<p>Note that both "typeset -xT ..." and "export -T ..." work, but only the scalar will be marked for export. Setting the value using the scalar version causes a split on all separators (which cannot be quoted). It is possible to apply <code>-T</code> to two previously tied variables but with a different separator character, in which case the variables remain joined as before but the separator is changed.</p>
<p>When an existing scalar is tied to a new array, the value of the scalar is preserved but no attribute other than export will be preserved.</p>
<p>Attribute flags that transform the final value (<code>-L</code>, <code>-R</code>, <code>-Z</code>, <code>-l</code>, <code>-u</code>) are only applied to the expanded value at the point of a parameter expansion expression using "$". They are not applied when a parameter is retrieved internally by the shell for any purpose.</p>
<p>The following attribute flags may be specified:</p>
<p>- <strong><code>-A</code></strong> — The names refer to associative array parameters; see <em>Array Parameters</em> (zshparam).</p>
<p>- <strong><code>-L</code> [ <em>n</em> ]</strong> — Left justify and remove leading blanks from the value when the parameter is expanded. If <em>n</em> is nonzero, it defines the width of the field. If <em>n</em> is zero, the width is determined by the width of the value of the first assignment. In the case of numeric parameters, the length of the complete value assigned to the parameter is used to determine the width, not the value that would be output.</p>
<p>The width is the count of characters, which may be multibyte characters if the <code>MULTIBYTE</code> option is in effect. Note that the screen width of the character is not taken into account; if this is required, use padding with parameter expansion flags tt(${+(ml)<em>...</em><code></code>)<em>...</em><code>}</code> as described in subref(Parameter Expansion Flags)(zshexpn).</p>
<p>When the parameter is expanded, it is filled on the right with blanks or truncated if necessary to fit the field. Note truncation can lead to unexpected results with numeric parameters. Leading zeros are removed if the <code>-Z</code> flag is also set.</p>
<p>- <strong><code>-R</code> [ <em>n</em> ]</strong> — Similar to <code>-L</code>, except that right justification is used; when the parameter is expanded, the field is left filled with blanks or truncated from the end. May not be combined with the <code>-Z</code> flag.</p>
<p>- <strong><code>-U</code></strong> — For arrays (but not for associative arrays), keep only the first occurrence of each duplicated value. This may also be set for tied parameters (see <code>-T</code>) or colon-separated special parameters like <code>PATH</code> or <code>FIGNORE</code>, etc. Note the flag takes effect on assignment, and the type of the variable being assigned to is determinative; for variables with shared values it is therefore recommended to set the flag for all interfaces, e.g. "typeset -U PATH path".</p>
<p>This flag has a different meaning when used with <code>-f</code>; see below.</p>
<p>- <strong><code>-Z</code> [ <em>n</em> ]</strong> — Specially handled if set along with the <code>-L</code> flag. Otherwise, similar to <code>-R</code>, except that leading zeros are used for padding instead of blanks if the first non-blank character is a digit. Numeric parameters are specially handled: they are always eligible for padding with zeroes, and the zeroes are inserted at an appropriate place in the output.</p>
<p>- <strong><code>-a</code></strong> — The names refer to array parameters. An array parameter may be created this way, but it may be assigned to in the <code>typeset</code> statement only if the reserved word form of <code>typeset</code> is enabled (as it is by default). When displaying, both normal and associative arrays are shown.</p>
<p>- <strong><code>-f</code></strong> — The names refer to functions rather than parameters. No assignments can be made, and the only other valid flags are <code>-t</code>, <code>-T</code>, <code>-k</code>, <code>-u</code>, <code>-U</code> and <code>-z</code>. The flag <code>-t</code> turns on execution tracing for this function; the flag <code>-T</code> does the same, but turns off tracing for any named (not anonymous) function called from the present one, unless that function also has the <code>-t</code> or <code>-T</code> flag. The <code>-u</code> and <code>-U</code> flags cause the function to be marked for autoloading; <code>-U</code> also causes alias expansion to be suppressed when the function is loaded. See the description of the "autoload" builtin for details.</p>
<p>Note that the builtin <code>functions</code> provides the same basic capabilities as <code>typeset -f</code> but gives access to a few extra options; <code>autoload</code> gives further additional options for the case <code>typeset -fu</code> and <code>typeset -fU</code>.</p>
<p>- <strong><code>-h</code></strong> — Hide: only useful for special parameters (those marked "<S>" in the table in <em>Parameters Set by the Shell</em> (zshparam)), and for local parameters with the same name as a special parameter, though harmless for others. A special parameter with this attribute will not retain its special effect when made local. Thus after <code></code>typeset -h PATH<code>', a function containing "typeset PATH" will create an ordinary local parameter without the usual behaviour of </code>PATH<code>. Alternatively, the local parameter may itself be given this attribute; hence inside a function "typeset -h PATH" creates an ordinary local parameter and the special </code>PATH<code> parameter is not altered in any way. It is also possible to create a local parameter using </code><code>typeset +h "_special_", where the local copy of _special_ will retain its special properties regardless of having the </code>-h<code> attribute. Global special parameters loaded from shell modules (for example, those in </code>zsh/mapfile<code> and </code>zsh/parameter<code>) are automatically given the </code>-h<code> attribute to avoid name clashes.</code></p>
<p>- <strong><code>-H</code></strong> — Hide value: specifies that <code>typeset</code> will not display the value of the parameter when listing parameters; the display for such parameters is always as if the "+" flag were given, but use of the parameter is in other respects normal. This effect does not apply when the parameter is specified by name or by pattern with the <code>-m</code> option. This is on by default for the parameters in the <code>zsh/parameter</code> and <code>zsh/mapfile</code> modules. Note, however, that unlike the <code>-h</code> flag this is also useful for non-special parameters.</p>
<p>- <strong><code>-i</code> [ <em>n</em> ]</strong> — Use an internal integer representation. If <em>n</em> is nonzero it defines the output arithmetic base, otherwise it is determined by the first assignment. Bases from 2 to 36 inclusive are allowed.</p>
<p>- <strong><code>-E</code> [ <em>n</em> ]</strong> — Use an internal double-precision floating point representation. On output the variable will be converted to scientific notation. If <em>n</em> is nonzero it defines the number of significant figures to display; the default is ten.</p>
<p>- <strong><code>-F</code> [ <em>n</em> ]</strong> — Use an internal double-precision floating point representation. On output the variable will be converted to fixed-point decimal notation. If <em>n</em> is nonzero it defines the number of digits to display after the decimal point; the default is ten.</p>
<p>- <strong><code>-l</code></strong> — Convert the result to lower case whenever the parameter is expanded. The value is <em>not</em> converted when assigned.</p>
<p>- <strong><code>-r</code></strong> — The given _name_s are marked readonly. Note that if <em>name</em> is a special parameter, the readonly attribute can be turned on, but cannot then be turned off.</p>
<p>If the <code>POSIX_BUILTINS</code> option is set, the readonly attribute is more restrictive: unset variables can be marked readonly and cannot then be set; furthermore, the readonly attribute cannot be removed from any variable.</p>
<p>It is still possible to change other attributes of the variable though, some of which like <code>-U</code> or <code>-Z</code> would affect the value. More generally, the readonly attribute should not be relied on as a security mechanism.</p>
<p>Note that in zsh (like in pdksh but unlike most other shells) it is still possible to create a local variable of the same name as this is considered a different variable (though this variable, too, can be marked readonly). Special variables that have been made readonly retain their value and readonly attribute when made local.</p>
<p>- <strong><code>-t</code></strong> — Tags the named parameters. Tags only exist to flag the parameter for the user's own purposes --- the list of tagged parameters can be queried using "typeset -t". Tags have no other use. Note that the <code>-t</code> flag has a different meaning when used with <code>-f</code>; see above.</p>
<p>- <strong><code>-u</code></strong> — Convert the result to upper case whenever the parameter is expanded. The value is <em>not</em> converted when assigned. This flag has different meanings when used with <code>-f</code> or <code>-n</code>; see above.</p>
<p>- <strong><code>-x</code></strong> — Mark for automatic export to the environment of subsequently executed commands. If the option <code>GLOBAL_EXPORT</code> is set, this implies the option <code>-g</code>, unless <code>+g</code> is also explicitly given; in other words the parameter is not made local to the enclosing function. This is for compatibility with previous versions of zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-ulimit">
<h3><code>ulimit</code> <a class="doc-anchor" href="#doc-lsp-compat-ulimit">¶</a></h3>
<p>Set or display resource limits of the shell and the processes started by the shell. The value of <em>limit</em> can be a number in the unit specified below or one of the values "unlimited", which removes the limit on the resource, or "hard", which uses the current value of the hard limit on the resource.</p>
<p>By default, only soft limits are manipulated. If the <code>-H</code> flag is given use hard limits instead of soft limits. If the <code>-S</code> flag is given together with the <code>-H</code> flag set both hard and soft limits.</p>
<p>If no options are used, the file size limit (<code>-f</code>) is assumed.</p>
<p>If <em>limit</em> is omitted the current value of the specified resources are printed. When more than one resource value is printed, the limit name and unit is printed before each value.</p>
<p>When looping over multiple resources, the shell will abort immediately if it detects a badly formed argument. However, if it fails to set a limit for some other reason it will continue trying to set the remaining limits.</p>
<p>Not all the following resources are supported on all systems. Running <code>ulimit -a</code> will show which are supported.</p>
<p>- <code>-a</code> — List all of the current resource limits.</p>
<p>- <strong><code>-b</code></strong> — Socket buffer size in bytes (N.B. not kilobytes+)</p>
<p>- <code>-c</code> — 512-byte blocks on the size of core dumps. - <code>-d</code> — Kilobytes on the size of the data segment. - <code>-e</code> — Maximum nice value. - <code>-f</code> — 512-byte blocks on the size of files written. - <code>-i</code> — The number of pending signals. - <code>-k</code> — The number of kqueues allocated. - <code>-l</code> — Kilobytes on the size of locked-in memory. - <code>-m</code> — Kilobytes on the size of physical memory. - <code>-n</code> — Open file descriptors. - <code>-o</code> — Maximum number of POSIX thread library objects. - <code>-p</code> — The number of pseudo-terminals. - <code>-q</code> — Bytes in POSIX message queues. - <code>-r</code> — Maximum real time priority. On some systems where this is not available, such as NetBSD, this has the same effect as <code>-T</code> for compatibility with <code>sh</code>. - <code>-s</code> — Kilobytes on the size of the stack. - <code>-T</code> — The number of simultaneous threads available to the user. - <code>-t</code> — CPU seconds to be used. - <code>-u</code> — The number of processes available to the user. - <code>-v</code> — Kilobytes on the size of virtual memory. On some systems this refers to the limit called "address space". - <code>-w</code> — Kilobytes on the size of swapped out memory. - <code>-x</code> — The number of locks on files. - <code>-y</code> — Maximum size of buffers for pipes/fifos.</p>
<p>A resource may also be specified by integer in the form <code></code>-N<code> _resource_', where _resource_ corresponds to the integer defined for the resource by the operating system. This may be used to set the limits for resources known to the shell which do not correspond to option letters. Such limits will be shown by number in the output of "ulimit -a".</code></p>
<p>The number may alternatively be out of the range of limits compiled into the shell. The shell will try to read or write the limit anyway, and will report an error if this fails.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-umask">
<h3><code>umask</code> <a class="doc-anchor" href="#doc-lsp-compat-umask">¶</a></h3>
<p>The umask is set to <em>mask</em>. <em>mask</em> can be either an octal number or a symbolic value as described in the manref(chmod)(1) man page. If <em>mask</em> is omitted, the current value is printed. The <code>-S</code> option causes the mask to be printed as a symbolic value. Otherwise, the mask is printed as an octal number. Note that in the symbolic form the permissions you specify are those which are to be allowed (not denied) to the users specified.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unalias">
<h3><code>unalias</code> <a class="doc-anchor" href="#doc-lsp-compat-unalias">¶</a></h3>
<p>Removes aliases. This command works the same as <code>unhash -a</code>, except that the <code>-a</code> option removes all regular or global aliases, or with <code>-s</code> all suffix aliases: in this case no <em>name</em> arguments may appear. The options <code>-m</code> (remove by pattern) and <code>-s</code> without <code>-a</code> (remove listed suffix aliases) behave as for <code>unhash -a</code>. Note that the meaning of <code>-a</code> is different between <code>unalias</code> and <code>unhash</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unfunction">
<h3><code>unfunction</code> <a class="doc-anchor" href="#doc-lsp-compat-unfunction">¶</a></h3>
<p>Remove a function definition. Equivalent to <code>unhash -f</code> / <code>unset -f name</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unhash">
<h3><code>unhash</code> <a class="doc-anchor" href="#doc-lsp-compat-unhash">¶</a></h3>
<p>Remove the element named <em>name</em> from an internal hash table. The default is remove elements from the command hash table. The <code>-a</code> option causes <code>unhash</code> to remove regular or global aliases; note when removing a global aliases that the argument must be quoted to prevent it from being expanded before being passed to the command. The <code>-s</code> option causes <code>unhash</code> to remove suffix aliases. The <code>-f</code> option causes <code>unhash</code> to remove shell functions. The <code>-d</code> options causes <code>unhash</code> to remove named directories. If the <code>-m</code> flag is given the arguments are taken as patterns (should be quoted) and all elements of the corresponding hash table with matching names will be removed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unlimit">
<h3><code>unlimit</code> <a class="doc-anchor" href="#doc-lsp-compat-unlimit">¶</a></h3>
<p>The resource limit for each <em>resource</em> is set to the hard limit. If the <code>-h</code> flag is given and the shell has appropriate privileges, the hard resource limit for each <em>resource</em> is removed. The resources of the shell process are only changed if the <code>-s</code> flag is given.</p>
<p>The <code>unlimit</code> command is not made available by default when the shell starts in a mode emulating another shell. It can be made available with the command "zmodload -F zsh/rlimits b:unlimit".</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unset">
<h3><code>unset</code> <a class="doc-anchor" href="#doc-lsp-compat-unset">¶</a></h3>
<p>Each named parameter is unset. Local parameters remain local even if unset; they appear unset within scope, but the previous value will still reappear when the scope ends.</p>
<p>Individual elements of associative array parameters may be unset by using subscript syntax on <em>name</em>, which should be quoted (or the entire command prefixed with <code>noglob</code>) to protect the subscript from filename generation.</p>
<p>If the <code>-m</code> flag is specified the arguments are taken as patterns (should be quoted) and all parameters with matching names are unset. Note that this cannot be used when unsetting associative array elements, as the subscript will be treated as part of the pattern.</p>
<p>The <code>-v</code> flag specifies that <em>name</em> refers to parameters. This is the default behaviour. If the <code>-n</code> option is supplied, and <em>name</em> is a a named reference, <em>name</em> will be unset rather than the variable it references.</p>
<p><code>unset -f</code> is equivalent to <code>unfunction</code>. The <code>-n</code> option has no effect with <code>-f</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-unsetopt">
<h3><code>unsetopt</code> <a class="doc-anchor" href="#doc-lsp-compat-unsetopt">¶</a></h3>
<p>Unset the options for the shell. All options specified either with flags or by name are unset. If no arguments are supplied, the names of all options currently unset are printed. If the <code>-m</code> flag is given the arguments are taken as patterns (which should be quoted to preserve them from being interpreted as glob patterns), and all options with names matching these patterns are unset.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-vared">
<h3><code>vared</code> <a class="doc-anchor" href="#doc-lsp-compat-vared">¶</a></h3>
<p>The value of the parameter <em>name</em> is loaded into the edit buffer, and the line editor is invoked. When the editor exits, <em>name</em> is set to the string value returned by the editor. When the <code>-c" flag is given, the parameter is created if it doesn"t already exist. The </code>-a<code> flag may be given with </code>-c<code> to create an array parameter, or the </code>-A<code> flag to create an associative array. If the type of an existing parameter does not match the type to be created, the parameter is unset and recreated. The </code>-g<code> flag may be given to suppress warnings from the </code>WARN_CREATE_GLOBAL<code> and </code>WARN_NESTED_VAR<code> options.</code></p>
<p>If an array or array slice is being edited, separator characters as defined in <code>$IFS</code> will be shown quoted with a backslash, as will backslashes themselves. Conversely, when the edited text is split into an array, a backslash quotes an immediately following separator character or backslash; no other special handling of backslashes, or any handling of quotes, is performed.</p>
<p>Individual elements of existing array or associative array parameters may be edited by using subscript syntax on <em>name</em>. New elements are created automatically, even without <code>-c</code>.</p>
<p>If the <code>-p</code> flag is given, the following string will be taken as the prompt to display at the left. If the <code>-r</code> flag is given, the following string gives the prompt to display at the right. If the <code>-h</code> flag is specified, the history can be accessed from ZLE. If the <code>-e</code> flag is given, typing <code>^D</code> (Control-D) in an empty buffer causes <code>vared</code> to exit immediately with a non-zero return value.</p>
<p>The <code>-M</code> option gives a keymap to link to the <code>main</code> keymap during editing, and the <code>-m</code> option gives a keymap to link to the <code>vicmd</code> keymap during editing. For vi-style editing, this allows a pair of keymaps to override <code>viins</code> and <code>vicmd</code>. For emacs-style editing, only <code>-M</code> is normally needed but the <code>-m</code> option may still be used. On exit, the previous keymaps will be restored.</p>
<p><code>Vared</code> calls the usual "zle-line-init" and "zle-line-finish" hooks before and after it takes control. Using the <code>-i</code> and <code>-f</code> options, it is possible to replace these with other custom widgets.</p>
<p>If <code></code>-t" <em>tty</em>" is given, <em>tty</em> is the name of a terminal device to be used instead of the default <code>/dev/tty</code>. If <em>tty</em> does not refer to a terminal an error is reported.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-wait">
<h3><code>wait</code> <a class="doc-anchor" href="#doc-lsp-compat-wait">¶</a></h3>
<p>Wait for the specified jobs or processes. If <em>job</em> is not given then all currently active child processes are waited for. Each <em>job</em> can be either a job specification or the process ID of a job in the job table. The exit status from this command is that of the job waited for. If <em>job</em> represents an unknown job or process ID, a warning is printed (unless the <code>POSIX_BUILTINS</code> option is set) and the exit status is 127.</p>
<p>It is possible to wait for recent processes (specified by process ID, not by job) that were running in the background even if the process has exited. Typically the process ID will be recorded by capturing the value of the variable <code>$!</code> immediately after the process has been started. There is a limit on the number of process IDs remembered by the shell; this is given by the value of the system configuration parameter <code>CHILD_MAX</code>. When this limit is reached, older process IDs are discarded, least recently started processes first.</p>
<p>Note there is no protection against the process ID wrapping, i.e. if the wait is not executed soon enough there is a chance the process waited for is the wrong one. A conflict implies both process IDs have been generated by the shell, as other processes are not recorded, and that the user is potentially interested in both, so this problem is intrinsic to process IDs.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-whence">
<h3><code>whence</code> <a class="doc-anchor" href="#doc-lsp-compat-whence">¶</a></h3>
<p>For each <em>name</em>, indicate how it would be interpreted if used as a command name.</p>
<p>If <em>name</em> is not an alias, built-in command, external command, shell function, hashed command, or a reserved word, the exit status shall be non-zero, and DASH()- if <code>-v</code>, <code>-c</code>, or <code>-w</code> was passed DASH()- a message will be written to standard output. (This is different from other shells that write that message to standard error.)</p>
<p><code>whence</code> is most useful when <em>name</em> is only the last path component of a command, i.e. does not include a "/"; in particular, pattern matching only succeeds if just the non-directory component of the command is passed.</p>
<p>- <strong><code>-v</code></strong> — Produce a more verbose report.</p>
<p>- <strong><code>-c</code></strong> — Print the results in a <strong>csh</strong>-like format. This takes precedence over <code>-v</code>.</p>
<p>- <strong><code>-w</code></strong> — For each <em>name</em>, print <code>_name_</code>:" <em>word</em>" where <em>word</em> is one of <code>alias</code>, <code>builtin</code>, <code>command</code>, <code>function</code>, <code>hashed</code>, <code>reserved</code> or <code>none</code>, according as <em>name</em> corresponds to an alias, a built-in command, an external command, a shell function, a command defined with the <code>hash</code> builtin, a reserved word, or is not recognised. This takes precedence over <code>-v</code> and <code>-c</code>.</p>
<p>- <strong><code>-f</code></strong> — Causes the contents of a shell function to be displayed, which would otherwise not happen unless the <code>-c</code> flag were used.</p>
<p>- <strong><code>-p</code></strong> — Do a path search for <em>name</em> even if it is an alias, reserved word, shell function or builtin.</p>
<p>- <strong><code>-a</code></strong> — Do a search for all occurrences of <em>name</em> throughout the command path. Normally only the first occurrence is printed. When combined with <code>-m</code>, only names appearing in the command hash table are searched, but all occurrences of those names are printed.</p>
<p>- <strong><code>-m</code></strong> — The arguments are taken as patterns (pattern characters should be quoted), and the information is displayed for each entry in the command hash table matching one of these patterns. The hash table is first refilled, in case of changes to <code>PATH</code>.</p>
<p>- <strong><code>-s</code></strong> — If a pathname contains symlinks, print the symlink-free pathname as well.</p>
<p>- <strong><code>-S</code></strong> — As <code>-s</code>, but if the pathname had to be resolved by following multiple symlinks, the intermediate steps are printed, too. The symlink resolved at each step might be anywhere in the path.</p>
<p>- <strong><code>-x</code> <em>num</em></strong> — Expand tabs when outputting shell functions using the <code>-c</code> option. This has the same effect as the <code>-x</code> option to the <code>functions</code> builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-where">
<h3><code>where</code> <a class="doc-anchor" href="#doc-lsp-compat-where">¶</a></h3>
<p>Equivalent to <code>whence -ca</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-which">
<h3><code>which</code> <a class="doc-anchor" href="#doc-lsp-compat-which">¶</a></h3>
<p>Equivalent to <code>whence -c</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zcompile">
<h3><code>zcompile</code> <a class="doc-anchor" href="#doc-lsp-compat-zcompile">¶</a></h3>
<p>This builtin command can be used to compile functions or scripts, storing the compiled form in a file, and to examine files containing the compiled form. This allows faster autoloading of functions and sourcing of scripts by avoiding parsing of the text when the files are read.</p>
<p>The first form (without the <code>-c</code>, <code>-a</code> or <code>-t</code> options) creates a compiled file. If only the <em>file</em> argument is given, the output file has the name <code>_file_</code>.zwc<code>' and will be placed in the same directory as the _file_. The shell will load the compiled file instead of the normal function file when the function is autoloaded; see _Autoloading Functions_ (zshmisc) for a description of how autoloaded functions are searched. The extension </code>.zwc<code> stands for "zsh word code".</code></p>
<p>vindex(fpath, with zcompile) If there is at least one <em>name</em> argument, all the named files are compiled into the output <em>file</em> given as the first argument. If <em>file</em> does not end in <code>.zwc</code>, this extension is automatically appended. Files containing multiple compiled functions are called "digest" files, and are intended to be used as elements of the <code>FPATH</code>/<code>fpath</code> special array.</p>
<p>The second form, with the <code>-c</code> or <code>-a</code> options, writes the compiled definitions for all the named functions into <em>file</em>. For <code>-c</code>, the names must be functions currently defined in the shell, not those marked for autoloading. Undefined functions that are marked for autoloading may be written by using the <code>-a</code> option, in which case the <code>fpath</code> is searched and the contents of the definition files for those functions, if found, are compiled into <em>file</em>. If both <code>-c</code> and <code>-a</code> are given, names of both defined functions and functions marked for autoloading may be given. In either case, the functions in files written with the <code>-c</code> or <code>-a</code> option will be autoloaded as if the <code>KSH_AUTOLOAD</code> option were unset.</p>
<p>The reason for handling loaded and not-yet-loaded functions with different options is that some definition files for autoloading define multiple functions, including the function with the same name as the file, and, at the end, call that function. In such cases the output of "zcompile -c" does not include the additional functions defined in the file, and any other initialization code in the file is lost. Using "zcompile -a" captures all this extra information.</p>
<p>If the <code>-m</code> option is combined with <code>-c</code> or <code>-a</code>, the _name_s are used as patterns and all functions whose names match one of these patterns will be written. If no <em>name</em> is given, the definitions of all functions currently defined or marked as autoloaded will be written.</p>
<p>Note the second form cannot be used for compiling functions that include redirections as part of the definition rather than within the body of the function; for example</p>
<p>example(fn1() { { ... } >~/logfile })</p>
<p>can be compiled but</p>
<p>example(fn1() { ... } >~/logfile)</p>
<p>cannot. It is possible to use the first form of <code>zcompile</code> to compile autoloadable functions that include the full function definition instead of just the body of the function.</p>
<p>The third form, with the <code>-t</code> option, examines an existing compiled file. Without further arguments, the names of the original files compiled into it are listed. The first line of output shows the version of the shell which compiled the file and how the file will be used (i.e. by reading it directly or by mapping it into memory). With arguments, nothing is output and the return status is set to zero if definitions for <em>all</em> _name_s were found in the compiled file, and non-zero if the definition for at least one <em>name</em> was not found.</p>
<p>Other options:</p>
<p>- <strong><code>-U</code></strong> — Aliases are not expanded when compiling the _name_d files.</p>
<p>- <strong><code>-R</code></strong> — When the compiled file is read, its contents are copied into the shell's memory, rather than memory-mapped (see <code>-M</code>). This happens automatically on systems that do not support memory mapping.</p>
<p>When compiling scripts instead of autoloadable functions, it is often desirable to use this option; otherwise the whole file, including the code to define functions which have already been defined, will remain mapped, consequently wasting memory.</p>
<p>- <strong><code>-M</code></strong> — The compiled file is mapped into the shell's memory when read. This is done in such a way that multiple instances of the shell running on the same host will share this mapped file. If neither <code>-R</code> nor <code>-M</code> is given, the <code>zcompile</code> builtin decides what to do based on the size of the compiled file.</p>
<p>- <strong><code>-k</code></strong></p>
<p>- <strong><code>-z</code></strong> — These options are used when the compiled file contains functions which are to be autoloaded. If <code>-z</code> is given, the function will be autoloaded as if the <code>KSH_AUTOLOAD</code> option is <em>not</em> set, even if it is set at the time the compiled file is read, while if the <code>-k</code> is given, the function will be loaded as if <code>KSH_AUTOLOAD</code> <em>is</em> set. These options also take precedence over any <code>-k</code> or <code>-z</code> options specified to the <code>autoload</code> builtin. If neither of these options is given, the function will be loaded as determined by the setting of the <code>KSH_AUTOLOAD</code> option at the time the compiled file is read. ifzman( ) These options may also appear as many times as necessary between the listed _name_s to specify the loading style of all following functions, up to the next <code>-k</code> or <code>-z</code>.</p>
<p>ifnzman( ) The created file always contains two versions of the compiled format, one for big-endian machines and one for small-endian machines. The upshot of this is that the compiled file is machine independent and if it is read or mapped, only one half of the file is actually used (and mapped). ifzman()</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zcurses">
<h3><code>zcurses</code> <a class="doc-anchor" href="#doc-lsp-compat-zcurses">¶</a></h3>
<p>Manipulate curses windows. All uses of this command should be bracketed by "zcurses init" to initialise use of curses, and "zcurses end" to end it; omitting "zcurses end" can cause the terminal to be in an unwanted state.</p>
<p>The subcommand <code>addwin</code> creates a window with <em>nlines</em> lines and <em>ncols</em> columns. Its upper left corner will be placed at row _begin_y_ and column _begin_x_ of the screen. <em>targetwin</em> is a string and refers to the name of a window that is not currently assigned. Note in particular the curses convention that vertical values appear before horizontal values.</p>
<p>If <code>addwin</code> is given an existing window as the final argument, the new window is created as a subwindow of <em>parentwin</em>. This differs from an ordinary new window in that the memory of the window contents is shared with the parent's memory. Subwindows must be deleted before their parent. Note that the coordinates of subwindows are relative to the screen, not the parent, as with other windows.</p>
<p>Use the subcommand <code>delwin</code> to delete a window created with <code>addwin</code>. Note that <code>end</code> does <em>not</em> implicitly delete windows, and that <code>delwin</code> does not erase the screen image of the window.</p>
<p>The window corresponding to the full visible screen is called <code>stdscr</code>; it always exists after "zcurses init" and cannot be delete with <code>delwin</code>.</p>
<p>The subcommand <code>refresh</code> will refresh window <em>targetwin</em>; this is necessary to make any pending changes (such as characters you have prepared for output with <code>char</code>) visible on the screen. <code>refresh</code> without an argument causes the screen to be cleared and redrawn. If multiple windows are given, the screen is updated once at the end.</p>
<p>The subcommand <code>touch</code> marks the _targetwin_s listed as changed. This is necessary before <code>refresh</code>ing windows if a window that was in front of another window (which may be <code>stdscr</code>) is deleted.</p>
<p>The subcommand <code>move</code> moves the cursor position in <em>targetwin</em> to new coordinates _new_y_ and _new_x_. Note that the subcommand <code>string</code> (but not the subcommand <code>char</code>) advances the cursor position over the characters added.</p>
<p>The subcommand <code>clear</code> erases the contents of <em>targetwin</em>. One (and no more than one) of three options may be specified. With the option <code>redraw</code>, in addition the next <code>refresh</code> of <em>targetwin</em> will cause the screen to be cleared and repainted. With the option <code>eol</code>, <em>targetwin</em> is only cleared to the end of the current cursor line. With the option <code>bot</code>, <em>targetwin</em> is cleared to the end of the window, i.e everything to the right and below the cursor is cleared.</p>
<p>The subcommand <code>position</code> writes various positions associated with <em>targetwin</em> into the array named <em>array</em>. These are, in order:</p>
<p>- - — The y and x coordinates of the cursor relative to the top left of <em>targetwin</em> - - — The y and x coordinates of the top left of <em>targetwin</em> on the screen - - — The size of <em>targetwin</em> in y and x dimensions.</p>
<p>Outputting characters and strings are achieved by <code>char</code> and <code>string</code> respectively.</p>
<p>To draw a border around window <em>targetwin</em>, use <code>border</code>. Note that the border is not subsequently handled specially: in other words, the border is simply a set of characters output at the edge of the window. Hence it can be overwritten, can scroll off the window, etc.</p>
<p>The subcommand <code>attr" will set _targetwin_"s attributes or foreground/background color pair for any successive character output. Each _attribute_ given on the line may be prepended by a </code>+<code> to set or a </code>-<code> to unset that attribute; </code>+<code> is assumed if absent. The attributes supported are </code>blink<code>, </code>bold<code>, </code>dim<code>, </code>reverse<code>, </code>standout<code>, and </code>underline<code>.</code></p>
<p>Each _fg_col_<code>/</code>_bg_col_ attribute (to be read as "_fg_col_ on _bg_col_") sets the foreground and background color for character output. The color <code>default</code> is sometimes available (in particular if the library is ncurses), specifying the foreground or background color with which the terminal started. The color pair <code>default/default</code> is always available. To use more than the 8 named colors (red, green, etc.) construct the _fg_col_<code>/</code>_bg_col_ pairs where _fg_col_ and _bg_col_ are decimal integers, e.g <code>128/200</code>. The maximum color value is 254 if the terminal supports 256 colors.</p>
<p><code>bg</code> overrides the color and other attributes of all characters in the window. Its usual use is to set the background initially, but it will overwrite the attributes of any characters at the time when it is called. In addition to the arguments allowed with <code>attr</code>, an argument <code>@</code><em>char</em> specifies a character to be shown in otherwise blank areas of the window. Owing to limitations of curses this cannot be a multibyte character (use of ASCII characters only is recommended). As the specified set of attributes override the existing background, turning attributes off in the arguments is not useful, though this does not cause an error.</p>
<p>The subcommand <code>scroll</code> can be used with <code>on</code> or <code>off</code> to enabled or disable scrolling of a window when the cursor would otherwise move below the window due to typing or output. It can also be used with a positive or negative integer to scroll the window up or down the given number of lines without changing the current cursor position (which therefore appears to move in the opposite direction relative to the window). In the second case, if scrolling is <code>off</code> it is temporarily turned <code>on</code> to allow the window to be scrolled.</p>
<p>The subcommand <code>input</code> reads a single character from the window without echoing it back. If <em>param</em> is supplied the character is assigned to the parameter <em>param</em>, else it is assigned to the parameter <code>REPLY</code>.</p>
<p>If both <em>param</em> and <em>kparam</em> are supplied, the key is read in "keypad" mode. In this mode special keys such as function keys and arrow keys return the name of the key in the parameter <em>kparam</em>. The key names are the macros defined in the <code>curses.h</code> or <code>ncurses.h</code> with the prefix "KEY_" removed; see also the description of the parameter <code>zcurses_keycodes</code> below. Other keys cause a value to be set in <em>param</em> as before. On a successful return only one of <em>param</em> or <em>kparam</em> contains a non-empty string; the other is set to an empty string.</p>
<p>If <em>mparam</em> is also supplied, <code>input</code> attempts to handle mouse input. This is only available with the ncurses library; mouse handling can be detected by checking for the exit status of "zcurses mouse" with no arguments. If a mouse button is clicked (or double- or triple-clicked, or pressed or released with a configurable delay from being clicked) then <em>kparam</em> is set to the string <code>MOUSE</code>, and <em>mparam</em> is set to an array consisting of the following elements:</p>
<p>- - — An identifier to discriminate different input devices; this is only rarely useful.</p>
<p>- <strong>-</strong> — The x, y and z coordinates of the mouse click relative to the full screen, as three elements in that order (i.e. the y coordinate is, unusually, after the x coordinate). The z coordinate is only available for a few unusual input devices and is otherwise set to zero.</p>
<p>- <strong>-</strong> — Any events that occurred as separate items; usually there will be just one. An event consists of <code>PRESSED</code>, <code>RELEASED</code>, <code>CLICKED</code>, <code>DOUBLE_CLICKED</code> or <code>TRIPLE_CLICKED</code> followed immediately (in the same element) by the number of the button.</p>
<p>- - — If the shift key was pressed, the string <code>SHIFT</code>. - - — If the control key was pressed, the string <code>CTRL</code>. - - — If the alt key was pressed, the string <code>ALT</code>.</p>
<p>Not all mouse events may be passed through to the terminal window; most terminal emulators handle some mouse events themselves. Note that the ncurses manual implies that using input both with and without mouse handling may cause the mouse cursor to appear and disappear.</p>
<p>The subcommand <code>mouse</code> can be used to configure the use of the mouse. There is no window argument; mouse options are global. "zcurses mouse" with no arguments returns status 0 if mouse handling is possible, else status 1. Otherwise, the possible arguments (which may be combined on the same command line) are as follows. <code>delay</code> <em>num</em> sets the maximum delay in milliseconds between press and release events to be considered as a click; the value 0 disables click resolution, and the default is one sixth of a second. <code>motion</code> proceeded by an optional "+" (the default) or <code>-</code> turns on or off reporting of mouse motion in addition to clicks, presses and releases, which are always reported. However, it appears reports for mouse motion are not currently implemented.</p>
<p>The subcommand <code>timeout</code> specifies a timeout value for input from <em>targetwin</em>. If <em>intval</em> is negative, "zcurses input" waits indefinitely for a character to be typed; this is the default. If <em>intval</em> is zero, "zcurses input" returns immediately; if there is typeahead it is returned, else no input is done and status 1 is returned. If <em>intval</em> is positive, "zcurses input" waits <em>intval</em> milliseconds for input and if there is none at the end of that period returns status 1.</p>
<p>The subcommand <code>querychar</code> queries the character at the current cursor position. The return values are stored in the array named <em>param</em> if supplied, else in the array <code>reply</code>. The first value is the character (which may be a multibyte character if the system supports them); the second is the color pair in the usual _fg_col_<code>/</code>_bg_col_ notation, or <code>0</code> if color is not supported. Any attributes other than color that apply to the character, as set with the subcommand <code>attr</code>, appear as additional elements.</p>
<p>The subcommand <code>resize</code> resizes <code>stdscr</code> and all windows to given dimensions (windows that stick out from the new dimensions are resized down). The underlying curses extension (<code>resize_term call</code>) can be unavailable. To verify, zeroes can be used for <em>height</em> and <em>width</em>. If the result of the subcommand is <code>0</code>, resize_term is available (<code>2</code> otherwise). Tests show that resizing can be normally accomplished by calling <code>zcurses end</code> and <code>zcurses refresh</code>. The <code>resize</code> subcommand is provided for versatility. Multiple system configurations have been checked and <code>zcurses end</code> and <code>zcurses refresh</code> are still needed for correct terminal state after resize. To invoke them with <code>resize</code>, use <em>endwin</em> argument. Using <em>nosave</em> argument will cause new terminal state to not be saved internally by <code>zcurses</code>. This is also provided for versatility and should normally be not needed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zdelattr">
<h3><code>zdelattr</code> <a class="doc-anchor" href="#doc-lsp-compat-zdelattr">¶</a></h3>
<p>Remove the extended attribute <em>attribute</em> from the specified <em>filename</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_chgrp">
<h3><code>zf_chgrp</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_chgrp">¶</a></h3>
<p>zftp: change group of remote files. Mirrors <code>chgrp(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_chmod">
<h3><code>zf_chmod</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_chmod">¶</a></h3>
<p>zftp: change mode of remote files. Mirrors <code>chmod(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_chown">
<h3><code>zf_chown</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_chown">¶</a></h3>
<p>zftp: change owner of remote files. Mirrors <code>chown(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_ln">
<h3><code>zf_ln</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_ln">¶</a></h3>
<p>zftp: link / rename remote files. Mirrors <code>ln(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_mkdir">
<h3><code>zf_mkdir</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_mkdir">¶</a></h3>
<p>zftp: create remote directories. Mirrors <code>mkdir(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_mv">
<h3><code>zf_mv</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_mv">¶</a></h3>
<p>zftp: move / rename remote files. Mirrors <code>mv(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_rm">
<h3><code>zf_rm</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_rm">¶</a></h3>
<p>zftp: remove remote files. Mirrors <code>rm(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_rmdir">
<h3><code>zf_rmdir</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_rmdir">¶</a></h3>
<p>zftp: remove remote directories. Mirrors <code>rmdir(1)</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zf_sync">
<h3><code>zf_sync</code> <a class="doc-anchor" href="#doc-lsp-compat-zf_sync">¶</a></h3>
<p>zftp: flush pending writes on the FTP control channel.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zformat">
<h3><code>zformat</code> <a class="doc-anchor" href="#doc-lsp-compat-zformat">¶</a></h3>
<p>This builtin provides different forms of formatting. The first form is selected with the <code>-f</code> option. In this case the <em>format</em> string will be modified by replacing sequences starting with a percent sign in it with strings from the _spec_s. Each <em>spec</em> should be of the form <code>_char_</code>:"<em>string</em>" which will cause every appearance of the sequence <code></code>%"<em>char</em>" in <em>format</em> to be replaced by the <em>string</em>. The "%" sequence may also contain optional minimum and maximum field width specifications between the "%" and the "<em>char</em>" in the form <code></code>%<code>_min_</code>.<code>_max_</code>c<code>', i.e. the minimum field width is given first and if the maximum field width is used, it has to be preceded by a dot. Specifying a minimum field width makes the result be padded with spaces to the right if the _string_ is shorter than the requested width. Padding to the left can be achieved by giving a negative minimum field width. If a maximum field width is specified, the _string_ will be truncated after that many characters. After all "%" sequences for the given _spec_s have been processed, the resulting string is stored in the parameter _param_.</code></p>
<p>The <code>%</code>-escapes also understand ternary expressions in the form used by prompts. The <code>%</code> is followed by a "tt(()" and then an ordinary format specifier character as described above. There may be a set of digits either before or after the "tt(()"; these specify a test number, which defaults to zero. Negative numbers are also allowed. An arbitrary delimiter character follows the format specifier, which is followed by a piece of "true" text, the delimiter character again, a piece of "false" text, and a closing parenthesis. The complete expression (without the digits) thus looks like <code>tt(%()_X_</code>.<code>_text1_</code>.<code>_text2_</code>")", except that the "." character is arbitrary. The value given for the format specifier in the <em>char</em><code>:</code><em>string</em> expressions is evaluated as a mathematical expression, and compared with the test number. If they are the same, <em>text1</em> is output, else <em>text2</em> is output. A parenthesis may be escaped in <em>text2</em> as <code>%</code>). Either of <em>text1</em> or <em>text2</em> may contain nested <code>%</code>-escapes.</p>
<p>For example:</p>
<p>example(zformat -f REPLY "The answer is '%3(c.yes.no)'." c:3)</p>
<p>outputs "The answer is 'yes'." to <code>REPLY</code> since the value for the format specifier <code>c</code> is 3, agreeing with the digit argument to the ternary expression.</p>
<p>With <code>-F</code> instead of <code>-f</code>, ternary expressions choose between the "true" or "false" text on the basis of whether the format specifier is present and non-empty. A test number indicates a minimum width for the value given in the format specifier. Negative numbers reverse this, so the test is for whether the value exceeds a maximum width.</p>
<p>The form, using the <code>-a</code> option, can be used for aligning strings. Here, the _spec_s are of the form <code>_left_</code>:"<em>right</em>" where "<em>left</em>" and "<em>right</em>" are arbitrary strings. These strings are modified by replacing the colons by the <em>sep</em> string and padding the <em>left</em> strings with spaces to the right so that the <em>sep</em> strings in the result (and hence the <em>right</em> strings after them) are all aligned if the strings are printed below each other. All strings without a colon are left unchanged and all strings with an empty <em>right</em> string have the trailing colon removed. In both cases the lengths of the strings are not used to determine how the other strings are to be aligned. A colon in the <em>left</em> string can be escaped with a backslash. The resulting strings are stored in the <em>array</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zftp">
<h3><code>zftp</code> <a class="doc-anchor" href="#doc-lsp-compat-zftp">¶</a></h3>
<p>The <code>zsh/zftp</code> module is a client for FTP (file transfer protocol). It is implemented as a builtin to allow full use of shell command line editing, file I/O, and job control mechanisms. Often, users will access it via shell functions providing a more powerful interface; a set is provided with the <code>zsh</code> distribution and is described in nmref(Zftp Function System)(zshzftpsys). However, the <code>zftp</code> command is entirely usable in its own right.</p>
<p>All commands consist of the command name <code>zftp</code> followed by the name of a subcommand. These are listed below. The return status of each subcommand is supposed to reflect the success or failure of the remote operation. See a description of the variable <code>ZFTP_VERBOSE</code> for more information on how responses from the server may be printed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zgdbmpath">
<h3><code>zgdbmpath</code> <a class="doc-anchor" href="#doc-lsp-compat-zgdbmpath">¶</a></h3>
<p>Put path to database file assigned to <em>parametername</em> into <code>REPLY</code> scalar.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zgetattr">
<h3><code>zgetattr</code> <a class="doc-anchor" href="#doc-lsp-compat-zgetattr">¶</a></h3>
<p>Get the extended attribute <em>attribute</em> from the specified <em>filename</em>. If the optional argument <em>parameter</em> is given, the attribute is set on that parameter instead of being printed to stdout.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zle">
<h3><code>zle</code> <a class="doc-anchor" href="#doc-lsp-compat-zle">¶</a></h3>
<p>The <code>zle</code> builtin performs a number of different actions concerning ZLE.</p>
<p>With no options and no arguments, only the return status will be set. It is zero if ZLE is currently active and widgets could be invoked using this builtin command and non-zero otherwise. Note that even if non-zero status is returned, zle may still be active as part of the completion system; this does not allow direct calls to ZLE widgets.</p>
<p>Otherwise, which operation it performs depends on its options:</p>
<p>- <strong><code>-l</code> [ <code>-L</code> | <code>-a</code> ] [ <em>string</em> ]</strong> — List all existing user-defined widgets. If the <code>-L</code> option is used, list in the form of <code>zle</code> commands to create the widgets.</p>
<p>When combined with the <code>-a</code> option, all widget names are listed, including the builtin ones. In this case the <code>-L</code> option is ignored.</p>
<p>If at least one <em>string</em> is given, and <code>-a</code> is present or <code>-L</code> is not used, nothing will be printed. The return status will be zero if all _string_s are names of existing widgets and non-zero if at least one <em>string</em> is not a name of a defined widget. If <code>-a</code> is also present, all widget names are used for the comparison including builtin widgets, else only user-defined widgets are used.</p>
<p>If at least one <em>string</em> is present and the <code>-L</code> option is used, user-defined widgets matching any <em>string</em> are listed in the form of <code>zle</code> commands to create the widgets.</p>
<p>- <strong><code>-D</code> <em>widget</em> ...</strong> — Delete the named _widget_s.</p>
<p>- <strong><code>-A</code> <em>old-widget</em> <em>new-widget</em></strong> — Make the <em>new-widget</em> name an alias for <em>old-widget</em>, so that both names refer to the same widget. The names have equal standing; if either is deleted, the other remains. If there is already a widget with the <em>new-widget</em> name, it is deleted.</p>
<p>- <strong><code>-N</code> <em>widget</em> [ <em>function</em> ]</strong> — Create a user-defined widget. If there is already a widget with the specified name, it is overwritten. When the new widget is invoked from within the editor, the specified shell <em>function</em> is called. If no function name is specified, it defaults to the same name as the widget. For further information, see <em>Zle Widgets</em> (below).</p>
<p>- <strong><code>-f</code> <em>flag</em> [ <em>flag</em>... ]</strong> — Set various flags on the running widget. Possible values for <em>flag</em> are:</p>
<p><code>yank</code> for indicating that the widget has yanked text into the buffer. If the widget is wrapping an existing internal widget, no further action is necessary, but if it has inserted the text manually, then it should also take care to set <code>YANK_START</code> and <code>YANK_END</code> correctly. <code>yankbefore</code> does the same but is used when the yanked text appears after the cursor.</p>
<p><code>kill</code> for indicating that text has been killed into the cutbuffer. When repeatedly invoking a kill widget, text is appended to the cutbuffer instead of replacing it, but when wrapping such widgets, it is necessary to call "zle -f kill" to retain this effect.</p>
<p><code>vichange</code> for indicating that the widget represents a vi change that can be repeated as a whole with "vi-repeat-change". The flag should be set early in the function before inspecting the value of <code>NUMERIC</code> or invoking other widgets. This has no effect for a widget invoked from insert mode. If insert mode is active when the widget finishes, the change extends until next returning to command mode.</p>
<p>cindex(completion widgets, creating)</p>
<p>- <strong><code>-C</code> <em>widget</em> <em>completion-widget</em> <em>function</em></strong> — Create a user-defined completion widget named <em>widget</em>. The completion widget will behave like the built-in completion-widget whose name is given as <em>completion-widget</em>. To generate the completions, the shell function <em>function</em> will be called. For further information, see nmref(Completion Widgets)(zshcompwid).</p>
<p>- <strong><code>-R</code> [ <code>-c</code> ] [ <em>display-string</em> ] [ <em>string</em> ... ]</strong> — Redisplay the command line. If a <em>display-string</em> is given and not empty, this is shown in the status line (immediately below the line being edited).</p>
<p>If the optional _string_s are given they are listed below the prompt in the same way as completion lists are printed. If no _string_s are given but the <code>-c</code> option is used such a list is cleared.</p>
<p>Note that immediately after returning from running widgets, the command line will be redisplayed and the strings displayed will be erased. Therefore, this option is only useful for widgets that do not exit immediately after using it.</p>
<p>This command can safely be called outside user defined widgets; if zle is active, the display will be refreshed, while if zle is not active, the command has no effect. In this case there will usually be no other arguments.</p>
<p>The status is zero if zle was active, else one.</p>
<p>- <strong><code>-M</code> <em>string</em></strong> — As with the <code>-R</code> option, the <em>string</em> will be displayed below the command line; unlike the <code>-R</code> option, the string will not be put into the status line but will instead be printed normally below the prompt. This means that the <em>string</em> will still be displayed after the widget returns (until it is overwritten by subsequent commands).</p>
<p>- <strong><code>-U</code> <em>string</em></strong> — This pushes the characters in the <em>string</em> onto the input stack of ZLE. After the widget currently executed finishes ZLE will behave as if the characters in the <em>string</em> were typed by the user.</p>
<p>As ZLE uses a stack, if this option is used repeatedly the last string pushed onto the stack will be processed first. However, the characters in each <em>string</em> will be processed in the order in which they appear in the string.</p>
<p>- <strong><code>-K</code> <em>keymap</em></strong> — Selects the keymap named <em>keymap</em>. An error message will be displayed if there is no such keymap.</p>
<p>This keymap selection affects the interpretation of following keystrokes within this invocation of ZLE. Any following invocation (e.g., the next command line) will start as usual with the "main" keymap selected.</p>
<p>- <strong><code>-F</code> [ <code>-L</code> | <code>-w</code> ] [ <em>fd</em> [ <em>handler</em> ] ]</strong> — Only available if your system supports one of the "poll" or "select" system calls; most modern systems do.</p>
<p>Installs <em>handler</em> (the name of a shell function) to handle input from file descriptor <em>fd</em>. Installing a handler for an <em>fd</em> which is already handled causes the existing handler to be replaced. Any number of handlers for any number of readable file descriptors may be installed. Note that zle makes no attempt to check whether this <em>fd</em> is actually readable when installing the handler. The user must make their own arrangements for handling the file descriptor when zle is not active.</p>
<p>When zle is attempting to read data, it will examine both the terminal and the list of handled <em>fd</em>'s. If data becomes available on a handled <em>fd</em>, zle calls <em>handler</em> with the fd which is ready for reading as the first argument. Under normal circumstances this is the only argument, but if an error was detected, a second argument provides details: "hup" for a disconnect, "nval" for a closed or otherwise invalid descriptor, or "err" for any other condition. Systems that support only the "select" system call always use "err".</p>
<p>If the option <code>-w</code> is also given, the <em>handler</em> is instead a line editor widget, typically a shell function made into a widget using "zle -N". In that case <em>handler</em> can use all the facilities of zle to update the current editing line. Note, however, that as handling <em>fd</em> takes place at a low level changes to the display will not automatically appear; the widget should call "zle -R" to force redisplay. As of this writing, widget handlers only support a single argument and thus are never passed a string for error state, so widgets must be prepared to test the descriptor themselves.</p>
<p>If either type of handler produces output to the terminal, it should call "zle -I" before doing so (see below). Handlers should not attempt to read from the terminal.</p>
<p>If no <em>handler</em> is given, but an <em>fd</em> is present, any handler for that <em>fd</em> is removed. If there is none, an error message is printed and status 1 is returned.</p>
<p>If no arguments are given, or the <code>-L</code> option is supplied, a list of handlers is printed in a form which can be stored for later execution.</p>
<p>An <em>fd</em> (but not a <em>handler</em>) may optionally be given with the <code>-L</code> option; in this case, the function will list the handler if any, else silently return status 1.</p>
<p>Note that this feature should be used with care. Activity on one of the <em>fd</em>'s which is not properly handled can cause the terminal to become unusable. Removing an <em>fd</em> handler from within a signal trap may cause unpredictable behavior.</p>
<p>Here is a simple example of using this feature. A connection to a remote TCP port is created using the ztcp command; see <em>The zsh/net/tcp Module</em> (zshmodules). Then a handler is installed which simply prints out any data which arrives on this connection. Note that "select" will indicate that the file descriptor needs handling if the remote side has closed the connection; we handle that by testing for a failed read.</p>
<p>example(if ztcp pwspc 2811; then tcpfd=$REPLY handler+() { zle -I local line if ! read -r line <&$1; then # select marks this fd if we reach EOF, # so handle this specially. print "[Read on fd $1 failed, removing.]" >&2 zle -F $1 return 1 fi print -r - $line } zle -F $tcpfd handler fi)</p>
<p>- <strong><code>-I</code></strong> — Unusually, this option is most useful outside ordinary widget functions, though it may be used within if normal output to the terminal is required. It invalidates the current zle display in preparation for output; typically this will be from a trap function. It has no effect if zle is not active. When a trap exits, the shell checks to see if the display needs restoring, hence the following will print output in such a way as not to disturb the line being edited:</p>
<p>example(TRAPUSR1() { # Invalidate zle display [[ -o zle ]] && zle -I # Show output print Hello })</p>
<p>In general, the trap function may need to test whether zle is active before using this method (as shown in the example), since the <code>zsh/zle</code> module may not even be loaded; if it is not, the command can be skipped.</p>
<p>It is possible to call "zle -I" several times before control is returned to the editor; the display will only be invalidated the first time to minimise disruption.</p>
<p>Note that there are normally better ways of manipulating the display from within zle widgets; see, for example, "zle -R" above.</p>
<p>The returned status is zero if zle was invalidated, even though this may have been by a previous call to "zle -I" or by a system notification. To test if a zle widget may be called at this point, execute <code>zle</code> with no arguments and examine the return status.</p>
<p>- <strong><code>-T</code></strong> — This is used to add, list or remove internal transformations on the processing performed by the line editor. It is typically used only for debugging or testing and is therefore of little interest to the general user.</p>
<p><code></code>zle -T" <em>transformation</em> <em>func</em>" specifies that the given <em>transformation</em> (see below) is effected by shell function <em>func</em>.</p>
<p><code></code>zle -Tr" <em>transformation</em>" removes the given <em>transformation</em> if it was present (it is not an error if none was).</p>
<p>"zle -TL" can be used to list all transformations currently in operation.</p>
<p>Currently the only transformation is <code>tc</code>. This is used instead of outputting termcap codes to the terminal. When the transformation is in operation the shell function is passed the termcap code that would be output as its first argument; if the operation required a numeric argument, that is passed as a second argument. The function should set the shell variable <code>REPLY</code> to the transformed termcap code. Typically this is used to produce some simply formatted version of the code and optional argument for debugging or testing. Note that this transformation is not applied to other non-printing characters such as carriage returns and newlines.</p>
<p>- <strong><em>widget</em> [ <code>-n</code> <em>num</em> ] [ <code>-f</code> <em>flag</em> ] [ <code>-Nw</code> ] [ <code>-K</code> <em>keymap</em> ] <em>args</em> ...</strong> — Invoke the specified <em>widget</em>. This can only be done when ZLE is active; normally this will be within a user-defined widget.</p>
<p>With the options <code>-n</code> and <code>-N</code>, the current numeric argument will be saved and then restored after the call to <em>widget</em>; <code></code>-n" <em>num</em>" sets the numeric argument temporarily to <em>num</em>, while "-N" sets it to the default, i.e. as if there were none.</p>
<p>With the option <code>-K</code>, <em>keymap</em> will be used as the current keymap during the execution of the widget. The previous keymap will be restored when the widget exits.</p>
<p>Normally, calling a widget in this way does not set the special parameter <code>WIDGET</code> and related parameters, so that the environment appears as if the top-level widget called by the user were still active. With the option <code>-w</code>, <code>WIDGET</code> and related parameters are set to reflect the widget being executed by the <code>zle</code> call.</p>
<p>Normally, when <em>widget</em> returns the special parameter <code>LASTWIDGET</code> will point to it. This can be inhibited by passing the option <code>-f nolast</code>.</p>
<p>Any further arguments will be passed to the widget; note that as standard argument handling is performed, any general argument list should be preceded by <code>-</code><code>-</code>. If it is a shell function, these are passed down as positional parameters; for builtin widgets it is up to the widget in question what it does with them. Currently arguments are only handled by the incremental-search commands, the <code>history-search-forward</code> and <code>-backward</code> and the corresponding functions prefixed by <code>vi-</code>, and by <code>universal-argument</code>. No error is flagged if the command does not use the arguments, or only uses some of them.</p>
<p>The return status reflects the success or failure of the operation carried out by the widget, or if it is a user-defined widget the return status of the shell function.</p>
<p>A non-zero return status causes the shell to beep when the widget exits, unless the <code>BEEP</code> options was unset or the widget was called via the <code>zle</code> command. Thus if a user defined widget requires an immediate beep, it should call the <code>beep</code> widget directly.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zlistattr">
<h3><code>zlistattr</code> <a class="doc-anchor" href="#doc-lsp-compat-zlistattr">¶</a></h3>
<p>List the extended attributes currently set on the specified <em>filename</em>. If the optional argument <em>parameter</em> is given, the list of attributes is set on that parameter instead of being printed to stdout.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zmodload">
<h3><code>zmodload</code> <a class="doc-anchor" href="#doc-lsp-compat-zmodload">¶</a></h3>
<p>Performs operations relating to zsh's loadable modules. Loading of modules while the shell is running ("dynamical loading") is not available on all operating systems, or on all installations on a particular operating system, although the <code>zmodload</code> command itself is always available and can be used to manipulate modules built into versions of the shell executable without dynamical loading.</p>
<p>Without arguments the names of all currently loaded binary modules are printed. The <code>-L</code> option causes this list to be in the form of a series of <code>zmodload</code> commands. Forms with arguments are:</p>
<p>- <strong><code>zmodload</code> [ <code>-is</code> ] <em>name</em> ... </strong></p>
<p>- <strong><code>zmodload</code> <code>-u</code> [ <code>-i</code> ] <em>name</em> ...</strong> — In the simplest case, <code>zmodload</code> loads a binary module. The module must be in a file with a name consisting of the specified <em>name</em> followed by a standard suffix, usually ".so" (".sl" on HPUX). If the module to be loaded is already loaded the duplicate module is ignored. If <code>zmodload</code> detects an inconsistency, such as an invalid module name or circular dependency list, the current code block is aborted. If it is available, the module is loaded if necessary, while if it is not available, non-zero status is silently returned. The option <code>-i</code> is accepted for compatibility but has no effect.</p>
<p>The _name_d module is searched for in the same way a command is, using <code>$module_path</code> instead of <code>$path</code>. However, the path search is performed even when the module name contains a "/", which it usually does. There is no way to prevent the path search.</p>
<p>If the module supports features (see below), <code>zmodload</code> tries to enable all features when loading a module. If the module was successfully loaded but not all features could be enabled, <code>zmodload</code> returns status 2.</p>
<p>If the option <code>-s</code> is given, no error is printed if the module was not available (though other errors indicating a problem with the module are printed). The return status indicates if the module was loaded. This is appropriate if the caller considers the module optional.</p>
<p>With <code>-u</code>, <code>zmodload</code> unloads modules. The same <em>name</em> must be given that was given when the module was loaded, but it is not necessary for the module to exist in the file system. The <code>-i</code> option suppresses the error if the module is already unloaded (or was never loaded).</p>
<p>Each module has a boot and a cleanup function. The module will not be loaded if its boot function fails. Similarly a module can only be unloaded if its cleanup function runs successfully.</p>
<p>- <strong><code>zmodload -F</code> [ <code>-almLe</code> <code>-P</code> <em>param</em> ] <em>module</em> [ [<code>+-</code>]<em>feature</em> ... ]</strong> — <code>zmodload -F</code> allows more selective control over the features provided by modules. With no options apart from <code>-F</code>, the module named <em>module</em> is loaded, if it was not already loaded, and the list of _feature_s is set to the required state. If no _feature_s are specified, the module is loaded, if it was not already loaded, but the state of features is unchanged. Each feature may be preceded by a <code>+</code> to turn the feature on, or <code>-</code> to turn it off; the <code>+</code> is assumed if neither character is present. Any feature not explicitly mentioned is left in its current state; if the module was not previously loaded this means any such features will remain disabled. The return status is zero if all features were set, 1 if the module failed to load, and 2 if some features could not be set (for example, a parameter couldn't be added because there was a different parameter of the same name) but the module was loaded.</p>
<p>The standard features are builtins, conditions, parameters and math functions; these are indicated by the prefix "b:", "c:" ("C:" for an infix condition), "p:" and "f:", respectively, followed by the name that the corresponding feature would have in the shell. For example, "b:strftime" indicates a builtin named <code>strftime</code> and <code>p:EPOCHSECONDS</code> indicates a parameter named <code>EPOCHSECONDS</code>. The module may provide other ("abstract") features of its own as indicated by its documentation; these have no prefix.</p>
<p>With <code>-l</code> or <code>-L</code>, features provided by the module are listed. With <code>-l</code> alone, a list of features together with their states is shown, one feature per line. With <code>-L</code> alone, a <code>zmodload -F</code> command that would cause enabled features of the module to be turned on is shown. With <code>-lL</code>, a <code>zmodload -F</code> command that would cause all the features to be set to their current state is shown. If one of these combinations is given with the option <code>-P</code> <em>param</em> then the parameter <em>param</em> is set to an array of features, either features together with their state or (if <code>-L</code> alone is given) enabled features.</p>
<p>With the option <code>-L</code> the module name may be omitted; then a list of all enabled features for all modules providing features is printed in the form of <code>zmodload -F</code> commands. If <code>-l</code> is also given, the state of both enabled and disabled features is output in that form.</p>
<p>A set of features may be provided together with <code>-l</code> or <code>-L</code> and a module name; in that case only the state of those features is considered. Each feature may be preceded by <code>+</code> or <code>-</code> but the character has no effect. If no set of features is provided, all features are considered.</p>
<p>With <code>-e</code>, the command first tests that the module is loaded; if it is not, status 1 is returned. If the module is loaded, the list of features given as an argument is examined. Any feature given with no prefix is simply tested to see if the module provides it; any feature given with a prefix <code>+</code> or <code>-</code> is tested to see if is provided and in the given state. If the tests on all features in the list succeed, status 0 is returned, else status 1.</p>
<p>With <code>-m</code>, each entry in the given list of features is taken as a pattern to be matched against the list of features provided by the module. An initial <code>+</code> or <code>-</code> must be given explicitly. This may not be combined with the <code>-a</code> option as autoloads must be specified explicitly.</p>
<p>With <code>-a</code>, the given list of features is marked for autoload from the specified module, which may not yet be loaded. An optional <code>+</code> may appear before the feature name. If the feature is prefixed with <code>-</code>, any existing autoload is removed. The options <code>-l</code> and <code>-L</code> may be used to list autoloads. Autoloading is specific to individual features; when the module is loaded only the requested feature is enabled. Autoload requests are preserved if the module is subsequently unloaded until an explicit <code></code>zmodload -Fa<code> _module_ </code>-"<em>feature</em>" is issued. It is not an error to request an autoload for a feature of a module that is already loaded.</p>
<p>When the module is loaded each autoload is checked against the features actually provided by the module; if the feature is not provided the autoload request is deleted. A warning message is output; if the module is being loaded to provide a different feature, and that autoload is successful, there is no effect on the status of the current command. If the module is already loaded at the time when <code>zmodload -Fa</code> is run, an error message is printed and status 1 returned.</p>
<p><code>zmodload -Fa</code> can be used with the <code>-l</code>, <code>-L</code>, <code>-e</code> and <code>-P</code> options for listing and testing the existence of autoloadable features. In this case <code>-l</code> is ignored if <code>-L</code> is specified. <code>zmodload -FaL</code> with no module name lists autoloads for all modules.</p>
<p>Note that only standard features as described above can be autoloaded; other features require the module to be loaded before enabling.</p>
<p>- <strong><code>zmodload</code> <code>-d</code> [ <code>-L</code> ] [ <em>name</em> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-d</code> <em>name</em> <em>dep</em> ...</strong></p>
<p>- <strong><code>zmodload</code> <code>-ud</code> <em>name</em> [ <em>dep</em> ... ]</strong> — The <code>-d</code> option can be used to specify module dependencies. The modules named in the second and subsequent arguments will be loaded before the module named in the first argument.</p>
<p>With <code>-d</code> and one argument, all dependencies for that module are listed. With <code>-d</code> and no arguments, all module dependencies are listed. This listing is by default in a Makefile-like format. The <code>-L</code> option changes this format to a list of <code>zmodload -d</code> commands.</p>
<p>If <code>-d</code> and <code>-u</code> are both used, dependencies are removed. If only one argument is given, all dependencies for that module are removed.</p>
<p>- <strong><code>zmodload</code> <code>-ab</code> [ <code>-L</code> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-ab</code> [ <code>-i</code> ] <em>name</em> [ <em>builtin</em> ... ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-ub</code> [ <code>-i</code> ] <em>builtin</em> ...</strong> — The <code>-ab</code> option defines autoloaded builtins. It defines the specified _builtin_s. When any of those builtins is called, the module specified in the first argument is loaded and all its features are enabled (for selective control of features use "zmodload -F -a" as described above). If only the <em>name</em> is given, one builtin is defined, with the same name as the module. <code>-i</code> suppresses the error if the builtin is already defined or autoloaded, but not if another builtin of the same name is already defined.</p>
<p>With <code>-ab</code> and no arguments, all autoloaded builtins are listed, with the module name (if different) shown in parentheses after the builtin name. The <code>-L</code> option changes this format to a list of <code>zmodload -a</code> commands.</p>
<p>If <code>-b</code> is used together with the <code>-u</code> option, it removes builtins previously defined with <code>-ab</code>. This is only possible if the builtin is not yet loaded. <code>-i</code> suppresses the error if the builtin is already removed (or never existed).</p>
<p>Autoload requests are retained if the module is subsequently unloaded until an explicit <code></code>zmodload -ub" <em>builtin</em>" is issued.</p>
<p>- <strong><code>zmodload</code> <code>-ac</code> [ <code>-IL</code> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-ac</code> [ <code>-iI</code> ] <em>name</em> [ <em>cond</em> ... ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-uc</code> [ <code>-iI</code> ] <em>cond</em> ...</strong> — The <code>-ac</code> option is used to define autoloaded condition codes. The <em>cond</em> strings give the names of the conditions defined by the module. The optional <code>-I</code> option is used to define infix condition names. Without this option prefix condition names are defined.</p>
<p>If given no condition names, all defined names are listed (as a series of <code>zmodload</code> commands if the <code>-L</code> option is given).</p>
<p>The <code>-uc</code> option removes definitions for autoloaded conditions.</p>
<p>- <strong><code>zmodload</code> <code>-ap</code> [ <code>-L</code> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-ap</code> [ <code>-i</code> ] <em>name</em> [ <em>parameter</em> ... ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-up</code> [ <code>-i</code> ] <em>parameter</em> ...</strong> — The <code>-p</code> option is like the <code>-b</code> and <code>-c</code> options, but makes <code>zmodload</code> work on autoloaded parameters instead.</p>
<p>- <strong><code>zmodload</code> <code>-af</code> [ <code>-L</code> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-af</code> [ <code>-i</code> ] <em>name</em> [ <em>function</em> ... ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-uf</code> [ <code>-i</code> ] <em>function</em> ...</strong> — The <code>-f</code> option is like the <code>-b</code>, <code>-p</code>, and <code>-c</code> options, but makes <code>zmodload</code> work on autoloaded math functions instead.</p>
<p>- <strong><code>zmodload</code> <code>-a</code> [ <code>-L</code> ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-a</code> [ <code>-i</code> ] <em>name</em> [ <em>builtin</em> ... ]</strong></p>
<p>- <strong><code>zmodload</code> <code>-ua</code> [ <code>-i</code> ] <em>builtin</em> ...</strong> — Equivalent to <code>-ab</code> and <code>-ub</code>.</p>
<p>- <strong><code>zmodload -e</code> [ <code>-A</code> ] [ <em>string</em> ... ]</strong> — The <code>-e</code> option without arguments lists all loaded modules; if the <code>-A</code> option is also given, module aliases corresponding to loaded modules are also shown. If arguments are provided, nothing is printed; the return status is set to zero if all _string_s given as arguments are names of loaded modules and to one if at least on <em>string</em> is not the name of a loaded module. This can be used to test for the availability of things implemented by modules. In this case, any aliases are automatically resolved and the <code>-A</code> flag is not used.</p>
<p>- <strong><code>zmodload</code> <code>-A</code> [ <code>-L</code> ] [ <em>modalias</em>[<code>=</code><em>module</em>] ... ]</strong> — For each argument, if both <em>modalias</em> and <em>module</em> are given, define <em>modalias</em> to be an alias for the module <em>module</em>. If the module <em>modalias</em> is ever subsequently requested, either via a call to <code>zmodload</code> or implicitly, the shell will attempt to load <em>module</em> instead. If <em>module</em> is not given, show the definition of <em>modalias</em>. If no arguments are given, list all defined module aliases. When listing, if the <code>-L</code> flag was also given, list the definition as a <code>zmodload</code> command to recreate the alias.</p>
<p>The existence of aliases for modules is completely independent of whether the name resolved is actually loaded as a module: while the alias exists, loading and unloading the module under any alias has exactly the same effect as using the resolved name, and does not affect the connection between the alias and the resolved name which can be removed either by <code>zmodload -R</code> or by redefining the alias. Chains of aliases (i.e. where the first resolved name is itself an alias) are valid so long as these are not circular. As the aliases take the same format as module names, they may include path separators: in this case, there is no requirement for any part of the path named to exist as the alias will be resolved first. For example, "any/old/alias" is always a valid alias.</p>
<p>Dependencies added to aliased modules are actually added to the resolved module; these remain if the alias is removed. It is valid to create an alias whose name is one of the standard shell modules and which resolves to a different module. However, if a module has dependencies, it will not be possible to use the module name as an alias as the module will already be marked as a loadable module in its own right.</p>
<p>Apart from the above, aliases can be used in the <code>zmodload</code> command anywhere module names are required. However, aliases will not be shown in lists of loaded modules with a bare "zmodload".</p>
<p>- <strong><code>zmodload</code> <code>-R</code> <em>modalias</em> ... </strong> — For each <em>modalias</em> argument that was previously defined as a module alias via <code>zmodload -A</code>, delete the alias. If any was not defined, an error is caused and the remainder of the line is ignored.</p>
<p>Note that <code>zsh</code> makes no distinction between modules that were linked into the shell and modules that are loaded dynamically. In both cases this builtin command has to be used to make available the builtins and other things defined by modules (unless the module is autoloaded on these definitions). This is true even for systems that don't support dynamic loading of modules.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zparseopts">
<h3><code>zparseopts</code> <a class="doc-anchor" href="#doc-lsp-compat-zparseopts">¶</a></h3>
<p>This builtin simplifies the parsing of options in positional parameters, i.e. the set of arguments given by <code>$*</code>. Each <em>spec</em> describes one option and must be of the form <code>_opt_[</code>="<em>array</em>]". If an option described by <em>opt</em> is found in the positional parameters it is copied into the <em>array</em> specified with the <code>-a</code> option; if the optional <code></code>="<em>array</em>" is given, it is instead copied into that array, which should be declared as a normal array and never as an associative array.</p>
<p>Note that it is an error to give any <em>spec</em> without an <code></code>="<em>array</em>" unless one of the <code>-a</code> or <code>-A</code> options is used.</p>
<p>Unless the <code>-E</code> option is given, parsing stops at the first string that isn't described by one of the _spec_s. Even with <code>-E</code>, parsing always stops at a positional parameter equal to <code></code>-"-" or (without <code>-G</code>) "-". See also <code>-F</code>.</p>
<p>The <em>opt</em> description must be one of the following. Any of the special characters can appear in the option name provided it is preceded by a backslash.</p>
<p>- <strong><em>name</em></strong></p>
<p>- <strong><em>name</em><code>+</code></strong> — The <em>name</em> is the name of the option without the leading "-". To specify a GNU-style long option, one of the usual two leading "-" must be included in <em>name</em>; for example, a <code></code>-"-file" option is represented by a <em>name</em> of "-file".</p>
<p>If a "+" appears after <em>name</em>, the option is appended to <em>array</em> each time it is found in the positional parameters; without the "+" only the <em>last</em> occurrence of the option is preserved.</p>
<p>If one of these forms is used, the option takes no argument, so parsing stops if the next positional parameter does not also begin with "-" (unless the <code>-E</code> option is used).</p>
<p>- <strong><em>name</em><code>:</code></strong></p>
<p>- <strong><em>name</em><code>:-</code></strong></p>
<p>- <strong><em>name</em><code>::</code></strong> — If one or two colons are given, the option takes an argument; with one colon, the argument is mandatory and with two colons it is optional. The argument is appended to the <em>array</em> after the option itself.</p>
<p>An optional argument is put into the same array element as the option name (note that this makes empty strings as arguments indistinguishable). A mandatory argument is added as a separate element unless the ":-" form is used, in which case the argument is put into the same element.</p>
<p>A "+" as described above may appear between the <em>name</em> and the first colon.</p>
<p>By default, option-arguments may appear either immediately following the option in the same positional parameter or in the next one. Even an optional argument may appear in the next parameter, unless it begins with a "-". Additionally, there is no special consideration given to an "=" between an option and its argument. To make parsing use the more common GNU-style conventions, use the <code>-G</code> option.</p>
<p>When the names of two options that take no arguments overlap, the longest one wins, so that parsing for the _spec_s "-foo -foobar" (for example) is unambiguous. However, due to the aforementioned handling of option-arguments, ambiguities may arise when at least one overlapping <em>spec</em> takes an argument, as in "-foo: -foobar". In that case, the last matching <em>spec</em> wins. (This is not an issue with GNU-style parsing.)</p>
<p>The options of <code>zparseopts</code> itself cannot be stacked because, for example, the stack "-DEK" is indistinguishable from a <em>spec</em> for the GNU-style long option <code></code>-"-DEK". The options of <code>zparseopts</code> itself are:</p>
<p>- <strong><code>-a</code> <em>array</em></strong> — As described above, this names the default array in which to store the recognised options.</p>
<p>- <strong><code>-A</code> <em>assoc</em></strong> — If this is given, the options and their values are also put into an associative array with the option names as keys and the arguments (if any) as the values.</p>
<p>- <strong><code>-D</code></strong> — If this option is given, all options found are removed from the positional parameters of the calling shell or shell function, up to but not including any not described by the _spec_s. If the first such parameter is <code></code>-"-" or (without <code>-G</code>) "-", it is removed as well. This is similar to using the <code>shift</code> builtin.</p>
<p>- <strong><code>-E</code></strong> — This changes the parsing rules to <em>not</em> stop at the first string that isn't described by one of the _spec_s. It can be used to test for or (if used together with <code>-D</code>) extract options and their arguments, ignoring all other options and arguments that may be in the positional parameters. As indicated above, parsing still stops at the first "-" or <code></code>-"-" not described by a <em>spec</em>, but it is not removed when used with <code>-D</code>. )</p>
<p>- <strong><code>-F</code></strong> — If this option is given, <code>zparseopts</code> immediately stops at the first option-like parameter not described by one of the _spec_s, prints an error message, and returns status 1. Removal (<code>-D</code>) and extraction (<code>-E</code>) are not performed, and option arrays are not updated. This provides basic validation for the given options.</p>
<p>Note that the appearance in the positional parameters of an option without its required argument always aborts parsing and returns an error as described above regardless of whether this option is used.</p>
<p>- <strong><code>-G</code></strong> — This option specifies that options are parsed in the GNU style, similar to tt(getopt_long+(3+)). In particular:</p>
<p>Given the <em>spec</em> "-foo:", the positional parameter <code></code>-"-foo=bar" is interpreted as option <code></code>-"-foo" with argument "bar", rather than argument "=bar" as is the default, whilst the positional parameter <code></code>-"-foobar" is considered an unknown option (unless another <em>spec</em> describes it). This applies to both singly and doubly hyphenated long options.</p>
<p>An empty option-argument can be given to its long option in the same parameter using a trailing "=".</p>
<p>An optional argument to a long option must be given with the equals syntax, and an optional argument to a short option must follow it immediately in the same parameter; in both cases the following parameter is considered unrelated.</p>
<p>Whenever a long option and its argument are stored in the same array element, an "=" is used to separate them.</p>
<p>A mandatory option-argument given in a separate parameter from its option (as in <code></code>-<code></code>-foo<code> </code>bar<code>' , or any option-argument given to a short option in the same parameter, is always treated the same regardless of whether this option is in effect.</code></p>
<p>Lastly, when this option is active, only <code></code>-"-" is treated as an explicit option-parsing terminator in the parsed arguments; a single "-" is considered a normal operand.</p>
<p>Note: Unlike most tt(getopt_long+(3+)) implementations, <code>zparseopts</code> does not support abbreviating long options. )</p>
<p>- <strong><code>-K</code></strong> — With this option, the arrays specified with the <code>-a</code> option and with the <code></code>="<em>array</em>" forms are kept unchanged when none of the _spec_s for them is used. Otherwise the entire array is replaced when any of the _spec_s is used. Individual elements of associative arrays specified with the <code>-A</code> option are preserved by <code>-K</code>. This allows assignment of default values to arrays before calling <code>zparseopts</code>.</p>
<p>- <strong><code>-M</code></strong> — This changes the assignment rules to implement a map among equivalent option names. If any <em>spec</em> uses the <code></code>="<em>array</em>" form, the string <em>array</em> is interpreted as the name of another <em>spec</em>, which is used to choose where to store the values. If no other <em>spec</em> is found, the values are stored as usual. This changes only the way the values are stored, not the way <code>$*</code> is parsed, so results may be unpredictable if the <code>_name_</code>+<code>' specifier is used inconsistently.</code></p>
<p>- <strong><code>-v</code> <em>argv</em></strong> — With this option, the elements of the named array <em>argv</em> are used as the positional parameters to parse, rather than those given by <code>$*</code>. The array may be modified according to the <code>-D</code> option.</p>
<p>For example,</p>
<p> set -- -a -bx -c y -cz baz -cend zparseopts a=foo b:=bar c+:=bar</p>
<p>will have the effect of</p>
<p>example(foo=(-a) bar=(-b x -c y -c z))</p>
<p>The arguments from "baz" on will not be used.</p>
<p>As an example for the <code>-E</code> option, consider:</p>
<p> set -- -a x -b y -c z arg1 arg2 zparseopts -E -D b:=bar</p>
<p>will have the effect of</p>
<p>example(bar=(-b y) set -- -a x -c z arg1 arg2)</p>
<p>I.e., the option <code>-b</code> and its arguments are taken from the positional parameters and put into the array <code>bar</code>.</p>
<p>The <code>-M</code> option can be used like this:</p>
<p> set -- -a -bx -c y -cz baz -cend zparseopts -A bar -M a=foo b+: c:=b</p>
<p>to have the effect of</p>
<p>example(foo=(-a) bar=(-a '' -b xyz))</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zprof">
<h3><code>zprof</code> <a class="doc-anchor" href="#doc-lsp-compat-zprof">¶</a></h3>
<p>Without the <code>-c</code> option, <code>zprof</code> lists profiling results to standard output. The format is comparable to that of commands like <code>gprof</code>.</p>
<p>At the top there is a summary listing all functions that were called at least once. This summary is sorted in decreasing order of the amount of time spent in each. The lines contain the number of the function in order, which is used in other parts of the list in suffixes of the form <code></code>[<code>_num_</code>]<code>', then the number of calls made to the function. The next three columns list the time in milliseconds spent in the function and its descendants, the average time in milliseconds spent in the function and its descendants per call and the percentage of time spent in all shell functions used in this function and its descendants. The following three columns give the same information, but counting only the time spent in the function itself. The final column shows the name of the function.</code></p>
<p>After the summary, detailed information about every function that was invoked is listed, sorted in decreasing order of the amount of time spent in each function and its descendants. Each of these entries consists of descriptions for the functions that called the function described, the function itself, and the functions that were called from it. The description for the function itself has the same format as in the summary (and shows the same information). The other lines don't show the number of the function at the beginning and have their function named indented to make it easier to distinguish the line showing the function described in the section from the surrounding lines.</p>
<p>The information shown in this case is almost the same as in the summary, but only refers to the call hierarchy being displayed. For example, for a calling function the column showing the total running time lists the time spent in the described function and its descendants only for the times when it was called from that particular calling function. Likewise, for a called function, this columns lists the total time spent in the called function and its descendants only for the times when it was called from the function described.</p>
<p>Also in this case, the column showing the number of calls to a function also shows a slash and then the total number of invocations made to the called function.</p>
<p>As long as the <code>zsh/zprof</code> module is loaded, profiling will be done and multiple invocations of the <code>zprof</code> builtin command will show the times and numbers of calls since the module was loaded. With the <code>-c</code> option, the <code>zprof</code> builtin command will reset its internal counters and will not show the listing.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zpty">
<h3><code>zpty</code> <a class="doc-anchor" href="#doc-lsp-compat-zpty">¶</a></h3>
<p>The arguments following <em>name</em> are concatenated with spaces between, then executed as a command, as if passed to the <code>eval</code> builtin. The command runs under a newly assigned pseudo-terminal; this is useful for running commands non-interactively which expect an interactive environment. The <em>name</em> is not part of the command, but is used to refer to this command in later calls to <code>zpty</code>.</p>
<p>With the <code>-e</code> option, the pseudo-terminal is set up so that input characters are echoed.</p>
<p>With the <code>-b</code> option, input to and output from the pseudo-terminal are made non-blocking.</p>
<p>The shell parameter <code>REPLY</code> is set to the file descriptor assigned to the master side of the pseudo-terminal. This allows the terminal to be monitored with ZLE descriptor handlers (see the description of option <code>-F</code> for <code>zle</code> builtin in <em>Zle Builtins</em> (zshzle)) or manipulated with <code>sysread</code> and <code>syswrite</code> builtins (see <em>The zsh/system Module</em> (zshmodules)). <em>Warning</em>: Use of <code>sysread</code> and <code>syswrite</code> is <em>not</em> recommended; use <code>zpty -r</code> and <code>zpty -w</code> unless you know exactly what you are doing.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zregexparse">
<h3><code>zregexparse</code> <a class="doc-anchor" href="#doc-lsp-compat-zregexparse">¶</a></h3>
<p>This implements some internals of the <code>_regex_arguments</code> function.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zselect">
<h3><code>zselect</code> <a class="doc-anchor" href="#doc-lsp-compat-zselect">¶</a></h3>
<p>The <code>zselect</code> builtin is a front-end to the "select" system call, which blocks until a file descriptor is ready for reading or writing, or has an error condition, with an optional timeout. If this is not available on your system, the command prints an error message and returns status 2 (normal errors return status 1). For more information, see your system's documentation for manref(select)(2). Note there is no connection with the shell builtin of the same name.</p>
<p>Arguments and options may be intermingled in any order. Non-option arguments are file descriptors, which must be decimal integers. By default, file descriptors are to be tested for reading, i.e. <code>zselect</code> will return when data is available to be read from the file descriptor, or more precisely, when a read operation from the file descriptor will not block. After a <code>-r</code>, <code>-w</code> and <code>-e</code>, the given file descriptors are to be tested for reading, writing, or error conditions. These options and an arbitrary list of file descriptors may be given in any order.</p>
<p>(The presence of an "error condition" is not well defined in the documentation for many implementations of the select system call. According to recent versions of the POSIX specification, it is really an <em>exception</em> condition, of which the only standard example is out-of-band data received on a socket. So zsh users are unlikely to find the <code>-e</code> option useful.)</p>
<p>The option <code></code>-t" <em>timeout</em>" specifies a timeout in hundredths of a second. This may be zero, in which case the file descriptors will simply be polled and <code>zselect</code> will return immediately. It is possible to call zselect with no file descriptors and a non-zero timeout for use as a finer-grained replacement for "sleep"; note, however, the return status is always 1 for a timeout.</p>
<p>The option <code></code>-a" <em>array</em>" indicates that <em>array</em> should be set to indicate the file descriptor+(s+) which are ready. If the option is not given, the array <code>reply</code> will be used for this purpose. The array will contain a string similar to the arguments for <code>zselect</code>. For example,</p>
<p> zselect -t 0 -r 0 -w 1</p>
<p>might return immediately with status 0 and <code>$reply</code> containing <code></code>-r 0 -w 1<code>' to show that both file descriptors are ready for the requested operations.</code></p>
<p>The option <code></code>-A" <em>assoc</em>" indicates that the associative array <em>assoc</em> should be set to indicate the file descriptor+(s+) which are ready. This option overrides the option <code>-a</code>, nor will <code>reply</code> be modified. The keys of <code>assoc</code> are the file descriptors, and the corresponding values are any of the characters "rwe" to indicate the condition.</p>
<p>The command returns status 0 if some file descriptors are ready for reading. If the operation timed out, or a timeout of 0 was given and no file descriptors were ready, or there was an error, it returns status 1 and the array will not be set (nor modified in any way). If there was an error in the select operation the appropriate error message is printed.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zsetattr">
<h3><code>zsetattr</code> <a class="doc-anchor" href="#doc-lsp-compat-zsetattr">¶</a></h3>
<p>Set the extended attribute <em>attribute</em> on the specified <em>filename</em> to <em>value</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zsocket">
<h3><code>zsocket</code> <a class="doc-anchor" href="#doc-lsp-compat-zsocket">¶</a></h3>
<p><code>zsocket</code> is implemented as a builtin to allow full use of shell command line editing, file I/O, and job control mechanisms.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zstat">
<h3><code>zstat</code> <a class="doc-anchor" href="#doc-lsp-compat-zstat">¶</a></h3>
<p>The command acts as a front end to the <code>stat</code> system call (see manref(stat)(2)). The same command is provided with two names; as the name <code>stat</code> is often used by an external command it is recommended that only the <code>zstat</code> form of the command is used. This can be arranged by loading the module with the command <code></code>zmodload -F zsh/stat b:zstat<code>'.</code></p>
<p>If the <code>stat</code> call fails, the appropriate system error message printed and status 1 is returned. The fields of <code>struct stat</code> give information about the files provided as arguments to the command. In addition to those available from the <code>stat</code> call, an extra element "link" is provided. These elements are:</p>
<p>- <strong><code>device</code></strong> — The number of the device on which the file resides.</p>
<p>- <strong><code>inode</code></strong> — The unique number of the file on this device ("<em>inode</em>" number).</p>
<p>- <strong><code>mode</code></strong> — The mode of the file; that is, the file's type and access permissions. With the <code>-s</code> option, this will be returned as a string corresponding to the first column in the display of the <code>ls -l</code> command.</p>
<p>- <strong><code>nlink</code></strong> — The number of hard links to the file.</p>
<p>- <strong><code>uid</code></strong> — The user ID of the owner of the file. With the <code>-s</code> option, this is displayed as a user name.</p>
<p>- <strong><code>gid</code></strong> — The group ID of the file. With the <code>-s</code> option, this is displayed as a group name.</p>
<p>- <strong><code>rdev</code></strong> — The raw device number. This is only useful for special devices.</p>
<p>- <strong><code>size</code></strong> — The size of the file in bytes.</p>
<p>- <strong><code>atime</code></strong></p>
<p>- <strong><code>mtime</code></strong></p>
<p>- <strong><code>ctime</code></strong> — The last access, modification and inode change times of the file, respectively, as the number of seconds since midnight GMT on 1st January, 1970. With the <code>-s</code> option, these are printed as strings for the local time zone; the format can be altered with the <code>-F</code> option, and with the <code>-g</code> option the times are in GMT.</p>
<p>- <strong><code>blksize</code></strong> — The number of bytes in one allocation block on the device on which the file resides.</p>
<p>- <strong><code>block</code></strong> — The number of disk blocks used by the file.</p>
<p>- <strong><code>link</code></strong> — If the file is a link and the <code>-L</code> option is in effect, this contains the name of the file linked to, otherwise it is empty. Note that if this element is selected (""zstat +link"") then the <code>-L</code> option is automatically used.</p>
<p>A particular element may be selected by including its name preceded by a "+" 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.</p>
<p>Options:</p>
<p>- <strong><code>-A</code> <em>array</em></strong> — Instead of displaying the results on standard output, assign them to an <em>array</em>, one <code>struct stat</code> element per array element for each file in order. In this case neither the name of the element nor the name of the files appears in <em>array</em> unless the <code>-t</code> or <code>-n</code> options were given, respectively. If <code>-t</code> is given, the element name appears as a prefix to the appropriate array element; if <code>-n</code> is given, the file name appears as a separate array element preceding all the others. Other formatting options are respected.</p>
<p>- <strong><code>-H</code> <em>hash</em></strong> — Similar to <code>-A</code>, but instead assign the values to <em>hash</em>. The keys are the elements listed above. If the <code>-n</code> option is provided then the name of the file is included in the hash with key <code>name</code>.</p>
<p>- <strong><code>-f</code> <em>fd</em></strong> — Use the file on file descriptor <em>fd</em> instead of named files; no list of file names is allowed in this case.</p>
<p>- <strong><code>-F</code> <em>fmt</em></strong> — Supplies a <code>strftime</code> (see manref(strftime)(3)) string for the formatting of the time elements. The format string supports all of the zsh extensions (see the description of <code>%D{</code><em>string</em><code>}</code> prompt escape in <em>Simple Prompt Escapes</em> (zshmisc)). In particular, <code>-F %s.%N</code> can be used to show timestamps with nanosecond precision if supported by the system. The <code>-s</code> option is implied.</p>
<p>- <strong><code>-g</code></strong> — Show the time elements in the GMT time zone. The <code>-s</code> option is implied.</p>
<p>- <strong><code>-l</code></strong> — List the names of the type elements (to standard output or an array as appropriate) and return immediately; arguments, and options other than <code>-A</code>, are ignored.</p>
<p>- <strong><code>-L</code></strong> — Perform an <code>lstat</code> (see manref(lstat)(2)) rather than a <code>stat</code> 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 <code>link</code> element useful. It's important to note that this is the exact opposite from manref(ls)(1), etc.</p>
<p>- <strong><code>-n</code></strong> — Always show the names of files. Usually these are only shown when output is to standard output and there is more than one file in the list.</p>
<p>- <strong><code>-N</code></strong> — Never show the names of files.</p>
<p>- <strong><code>-o</code></strong> — If a raw file mode is printed, show it in octal, which is more useful for human consumption than the default of decimal. A leading zero will be printed in this case. Note that this does not affect whether a raw or formatted file mode is shown, which is controlled by the <code>-r</code> and <code>-s</code> options, nor whether a mode is shown at all.</p>
<p>- <strong><code>-r</code></strong> — Print raw data (the default format) alongside string data (the <code>-s</code> format); the string data appears in parentheses after the raw data.</p>
<p>- <strong><code>-s</code></strong> — Print <code>mode</code>, <code>uid</code>, <code>gid</code> and the three time elements as strings instead of numbers. In each case the format is like that of <code>ls -l</code>.</p>
<p>- <strong><code>-t</code></strong> — Always show the type names for the elements of <code>struct stat</code>. Usually these are only shown when output is to standard output and no individual element has been selected.</p>
<p>- <strong><code>-T</code></strong> — Never show the type names of the <code>struct stat</code> elements.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zstyle">
<h3><code>zstyle</code> <a class="doc-anchor" href="#doc-lsp-compat-zstyle">¶</a></h3>
<p>This makes defining styles a bit simpler by using a single "+" as a special token that allows you to append a context name to the previously used context name. Like this:</p>
<p> zstyle+ ':foo:bar' <em>style1</em> <em>value1</em> \ + ':baz' <em>style2</em> <em>value2</em> \ + ':frob' <em>style3</em> <em>value3</em></p>
<p>This defines <em>style1</em> with <em>value1</em> for the context <code>:foo:bar</code> as usual, but it also defines <em>style2</em> with <em>value2</em> for the context <code>:foo:bar:baz</code> and <em>style3</em> with <em>value3</em> for <code>:foo:bar:frob</code>. Any <em>subcontext</em> may be the empty string to re-use the first context unchanged.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zsystem">
<h3><code>zsystem</code> <a class="doc-anchor" href="#doc-lsp-compat-zsystem">¶</a></h3>
<p>The builtin <code>zsystem</code>'s subcommand <code>flock</code> performs advisory file locking (via the manref(fcntl)(2) system call) over the entire contents of the given file. This form of locking requires the processes accessing the file to cooperate; its most obvious use is between two instances of the shell itself.</p>
<p>In the first form the named <em>file</em>, which must already exist, is locked by opening a file descriptor to the file and applying a lock to the file descriptor. The lock terminates when the shell process that created the lock exits; it is therefore often convenient to create file locks within subshells, since the lock is automatically released when the subshell exits. Note that use of the <code>print</code> builtin with the <code>-u</code> option will, as a side effect, release the lock, as will redirection to the file in the shell holding the lock. To work around this use a subshell, e.g. "tt((print message) >> )<em>file</em>". Status 0 is returned if the lock succeeds, else status 1.</p>
<p>In the second form the file descriptor given by the arithmetic expression _fd_expr_ is closed, releasing a lock. The file descriptor can be queried by using the <code></code>-f" <em>var</em>" form during the lock; on a successful lock, the shell variable <em>var</em> is set to the file descriptor used for locking. The lock will be released if the file descriptor is closed by any other means, for example using <code></code>exec {<code>_var_</code>}>&-<code>'; however, the form described here performs a safety check that the file descriptor is in use for file locking.</code></p>
<p>By default the shell waits indefinitely for the lock to succeed. The option <code>-t</code> <em>timeout</em> specifies a timeout for the lock in seconds; fractional seconds are allowed. During this period, the shell will attempt to lock the file every <em>interval</em> seconds if the <code>-i</code> <em>interval</em> option is given, otherwise once a second. (This <em>interval</em> is shortened before the last attempt if needed, so that the shell waits only until the <em>timeout</em> and not longer.) If the attempt times out, status 2 is returned.</p>
<p>(Note: <em>timeout</em> is limited to 2^30-1 seconds (about 34 years), and <em>interval</em> to 0.999 * LONG_MAX microseconds (only about 35 minutes on 32-bit systems).)</p>
<p>If the option <code>-e</code> is given, the file descriptor for the lock is preserved when the shell uses <code>exec</code> to start a new process; otherwise it is closed at that point and the lock released.</p>
<p>If the option <code>-r</code> is given, the lock is only for reading, otherwise it is for reading and writing. The file descriptor is opened accordingly.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-ztcp">
<h3><code>ztcp</code> <a class="doc-anchor" href="#doc-lsp-compat-ztcp">¶</a></h3>
<p><code>ztcp</code> is implemented as a builtin to allow full use of shell command line editing, file I/O, and job control mechanisms.</p>
<p>If <code>ztcp</code> is run with no options, it will output the contents of its session table.</p>
<p>If it is run with only the option <code>-L</code>, it will output the contents of the session table in a format suitable for automatic parsing. The option is ignored if given with a command to open or close a session. The output consists of a set of lines, one per session, each containing the following elements separated by spaces:</p>
<p>- <strong>File descriptor</strong> — The file descriptor in use for the connection. For normal inbound (<code>I</code>) and outbound (<code>O</code>) connections this may be read and written by the usual shell mechanisms. However, it should only be close with "ztcp -c".</p>
<p>- <strong>Connection type</strong> — A letter indicating how the session was created:</p>
<p>- <strong><code>Z</code></strong> — A session created with the <code>zftp</code> command.</p>
<p>- <strong><code>L</code></strong> — A connection opened for listening with "ztcp -l".</p>
<p>- <strong><code>I</code></strong> — An inbound connection accepted with "ztcp -a".</p>
<p>- <strong><code>O</code></strong> — An outbound connection created with <code></code>ztcp" <em>host</em> <em>...</em>".</p>
<p>- <strong>The local host</strong> — This is usually set to an all-zero IP address as the address of the localhost is irrelevant.</p>
<p>- <strong>The local port</strong> — This is likely to be zero unless the connection is for listening.</p>
<p>- <strong>The remote host</strong> — This is the fully qualified domain name of the peer, if available, else an IP address. It is an all-zero IP address for a session opened for listening.</p>
<p>- <strong>The remote port</strong> — This is zero for a connection opened for listening.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-ztie">
<h3><code>ztie</code> <a class="doc-anchor" href="#doc-lsp-compat-ztie">¶</a></h3>
<p>Open the GDBM database identified by <em>filename</em> and, if successful, create the associative array <em>arrayname</em> linked to the file. To create a local tied array, the parameter must first be declared, so commands similar to the following would be executed inside a function scope:</p>
<p> local -A sampledb ztie -d db/gdbm -f sample.gdbm sampledb</p>
<p>The <code>-r</code> option opens the database file for reading only, creating a parameter with the readonly attribute. Without this option, using "ztie" on a file for which the user does not have write permission is an error. If writable, the database is opened synchronously so fields changed in <em>arrayname</em> are immediately written to <em>filename</em>.</p>
<p>Changes to the file modes <em>filename</em> after it has been opened do not alter the state of <em>arrayname</em>, but <code></code>typeset -r" <em>arrayname</em>" works as expected.</p>
</article>
<article class="doc-entry" id="doc-lsp-compat-zuntie">
<h3><code>zuntie</code> <a class="doc-anchor" href="#doc-lsp-compat-zuntie">¶</a></h3>
<p>Close the GDBM database associated with each <em>arrayname</em> and then unset the parameter. The <code>-u</code> option forces an unset of parameters made readonly with "ztie -r".</p>
<p>This happens automatically if the parameter is explicitly unset or its local scope (function) ends. Note that a readonly parameter may not be explicitly unset, so the only way to unset a global parameter created with "ztie -r" is to use "zuntie -u".</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-keywords">
<h2>Keyword Index</h2>
<p class="chapter-meta">31 entries</p>
<article class="doc-entry" id="doc-lsp-keyword-bang">
<h3><code>!</code> <a class="doc-anchor" href="#doc-lsp-keyword-bang">¶</a></h3>
<p>Pipeline negation (also a reserved word). <code>! cmd</code> inverts <code>cmd</code>'s exit status — zero becomes 1, non-zero becomes 0. Distinct from <code>!</code> history expansion (lexer-stage).</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-lbracketlbracket">
<h3><code>[[</code> <a class="doc-anchor" href="#doc-lsp-keyword-lbracketlbracket">¶</a></h3>
<p>Open zsh conditional expression. <code>[[ EXPR ]]</code> evaluates a boolean. No word splitting / glob inside; supports <code>&&</code>, <code>||</code>, <code>!</code>, <code>==</code>, <code>!=</code>, <code>=~</code>, <code>-e</code>, <code>-f</code>, <code>-d</code>, <code>-z</code>, <code>-n</code>, etc. Prefer this over <code>[ ]</code> in zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-lbrace">
<h3><code>{</code> <a class="doc-anchor" href="#doc-lsp-keyword-lbrace">¶</a></h3>
<p>Command-group open brace. <code>{ cmd1; cmd2; }</code> runs the commands in the current shell (no subshell), grouping them as one syntactic unit. Reserved word — must be followed by whitespace or a newline.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-rbrace">
<h3><code>}</code> <a class="doc-anchor" href="#doc-lsp-keyword-rbrace">¶</a></h3>
<p>Command-group close brace. Pairs with <code>{ … }</code>. Reserved word — preceded by <code>;</code> or newline.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-case">
<h3><code>case</code> <a class="doc-anchor" href="#doc-lsp-keyword-case">¶</a></h3>
<p>Execute the <em>list</em> associated with the first <em>pattern</em> that matches <em>word</em>, if any. The form of the patterns is the same as that used for filename generation. See <em>Filename Generation</em> (zshexpn).</p>
<p>Note further that, unless the <code>SH_GLOB</code> option is set, the whole pattern with alternatives is treated by the shell as equivalent to a group of patterns within parentheses, although white space may appear about the parentheses and the vertical bar and will be stripped from the pattern at those points. White space may appear elsewhere in the pattern; this is not stripped. If the <code>SH_GLOB</code> option is set, so that an opening parenthesis can be unambiguously treated as part of the case syntax, the expression is parsed into separate words and these are treated as strict alternatives (as in other shells).</p>
<p>If the <em>list</em> that is executed is terminated with <code>;&</code> rather than <code>;;</code>, the following list is also executed. The rule for the terminator of the following list <code>;;</code>, <code>;&</code> or <code>;|</code> is applied unless the <code>esac</code> is reached.</p>
<p>If the <em>list</em> that is executed is terminated with <code>;|</code> the shell continues to scan the _pattern_s looking for the next match, executing the corresponding <em>list</em>, and applying the rule for the corresponding terminator <code>;;</code>, <code>;&</code> or <code>;|</code>. Note that <em>word</em> is not re-expanded; all applicable _pattern_s are tested with the same <em>word</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-coproc">
<h3><code>coproc</code> <a class="doc-anchor" href="#doc-lsp-keyword-coproc">¶</a></h3>
<p>Run a command as a coprocess (background, attached I/O).</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-declare">
<h3><code>declare</code> <a class="doc-anchor" href="#doc-lsp-keyword-declare">¶</a></h3>
<p>Alias for <code>typeset</code>. Set variable attributes. <code>-a</code> array, <code>-A</code> assoc, <code>-i</code> integer, <code>-r</code> readonly.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-do">
<h3><code>do</code> <a class="doc-anchor" href="#doc-lsp-keyword-do">¶</a></h3>
<p>Body-introducer for <code>for</code>/<code>while</code>/<code>until</code>/<code>select</code>/<code>repeat</code>. <code>for v in …; do body; done</code></p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-done">
<h3><code>done</code> <a class="doc-anchor" href="#doc-lsp-keyword-done">¶</a></h3>
<p>Closes a <code>for</code> / <code>foreach</code> / <code>while</code> / <code>until</code> / <code>select</code> / <code>repeat</code> loop body. <code>for v in a b c; do echo $v; done</code>. Required terminator.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-elif">
<h3><code>elif</code> <a class="doc-anchor" href="#doc-lsp-keyword-elif">¶</a></h3>
<p>Alternative test in an <code>if</code> chain. <code>if a; then …; elif b; then …; fi</code></p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-else">
<h3><code>else</code> <a class="doc-anchor" href="#doc-lsp-keyword-else">¶</a></h3>
<p>Alternative branch for <code>if</code>. <code>if cmd; then a; else b; fi</code></p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-end">
<h3><code>end</code> <a class="doc-anchor" href="#doc-lsp-keyword-end">¶</a></h3>
<p>Closes the alternate-form compound statement (<code>foreach NAME (WORDS) … end</code>, <code>if COND … end</code>, <code>while COND … end</code>). Csh-style syntactic mirror of <code>fi</code> / <code>done</code> / <code>esac</code> for users coming from csh / tcsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-esac">
<h3><code>esac</code> <a class="doc-anchor" href="#doc-lsp-keyword-esac">¶</a></h3>
<p>Closes a <code>case</code> statement. <code>case word in pat) …;; esac</code></p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-export">
<h3><code>export</code> <a class="doc-anchor" href="#doc-lsp-keyword-export">¶</a></h3>
<p>The specified _name_s are marked for automatic export to the environment of subsequently executed commands. Equivalent to <code>typeset -gx</code>. If a parameter specified does not already exist, it is created in the global scope.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-fi">
<h3><code>fi</code> <a class="doc-anchor" href="#doc-lsp-keyword-fi">¶</a></h3>
<p>Closes an <code>if</code> block. <code>if cmd; then body; fi</code>. Required terminator — without it the parser keeps reading until EOF.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-float">
<h3><code>float</code> <a class="doc-anchor" href="#doc-lsp-keyword-float">¶</a></h3>
<p>Equivalent to <code>typeset -E</code>, except that options irrelevant to floating point numbers are not permitted.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-for">
<h3><code>for</code> <a class="doc-anchor" href="#doc-lsp-keyword-for">¶</a></h3>
<p>Expand the list of _word_s, and set the parameter <em>name</em> to each of them in turn, executing <em>list</em> each time. If the <code></code>in" <em>word</em>" is omitted, use the positional parameters instead of the _word_s. If any <em>name</em> has been declared as a named reference, the corresponding <em>word</em> is treated as the name of a parameter and <em>name</em> is made a reference to that. Note that for the positional parameters, this treats the value of each positional as parameter name rather than creating a reference to the position.</p>
<p>The <em>term</em> consists of one or more newline or <code>;</code> which terminate the _word_s, and are optional when the <code></code>in" <em>word</em>" is omitted.</p>
<p>More than one parameter <em>name</em> can appear before the list of _word_s. If <em>N</em> _name_s are given, then on each execution of the loop the next <em>N</em> _word_s are assigned to the corresponding parameters. If there are more _name_s than remaining _word_s, the remaining parameters are each set to the empty string. Execution of the loop ends when there is no remaining <em>word</em> to assign to the first <em>name</em>. It is only possible for <code>in</code> to appear as the first <em>name</em> in the list, else it will be treated as marking the end of the list.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-foreach">
<h3><code>foreach</code> <a class="doc-anchor" href="#doc-lsp-keyword-foreach">¶</a></h3>
<p>Another form of <code>for</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-function">
<h3><code>function</code> <a class="doc-anchor" href="#doc-lsp-keyword-function">¶</a></h3>
<p>where <em>term</em> is one or more newline or <code>;</code>. Define a function which is referenced by any one of <em>word</em>. Normally, only one <em>word</em> is provided; multiple _word_s are usually only useful for setting traps. The body of the function is the <em>list</em> between the <code>{</code> and <code>}</code>. See <em>Functions</em> (blow).</p>
<p>The options of <code>function</code> have the following meanings:</p>
<p>- <strong>-T</strong> — Enable tracing for this function, as though with <code>functions -T</code>. See the documentation of the <code>-f</code> option to the <code>typeset</code> builtin, in <em>Shell Builtin Commands</em> (zshbuiltins).</p>
<p>If the option <code>SH_GLOB</code> is set for compatibility with other shells, then whitespace may appear between the left and right parentheses when there is a single <em>word</em>; otherwise, the parentheses will be treated as forming a globbing pattern in that case.</p>
<p>In any of the forms above, a redirection may appear outside the function body, for example</p>
<p>example(func+() { ... } 2>&1)</p>
<p>The redirection is stored with the function and applied whenever the function is executed. Any variables in the redirection are expanded at the point the function is executed, but outside the function scope.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-if">
<h3><code>if</code> <a class="doc-anchor" href="#doc-lsp-keyword-if">¶</a></h3>
<p>The <code>if</code> <em>list</em> is executed, and if it returns a zero exit status, the <code>then</code> <em>list</em> is executed. Otherwise, the <code>elif</code> <em>list</em> is executed and if its status is zero, the <code>then</code> <em>list</em> is executed. If each <code>elif</code> <em>list</em> returns nonzero status, the <code>else</code> <em>list</em> is executed.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-integer">
<h3><code>integer</code> <a class="doc-anchor" href="#doc-lsp-keyword-integer">¶</a></h3>
<p>Equivalent to <code>typeset -i</code>, except that options irrelevant to integers are not permitted.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-local">
<h3><code>local</code> <a class="doc-anchor" href="#doc-lsp-keyword-local">¶</a></h3>
<p>Same as <code>typeset</code>, except that the options <code>-g</code>, and <code>-f</code> are not permitted. In this case the <code>-x</code> option does not force the use of <code>-g</code>, i.e. exported variables will be local to functions.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-nocorrect">
<h3><code>nocorrect</code> <a class="doc-anchor" href="#doc-lsp-keyword-nocorrect">¶</a></h3>
<p>Spelling correction is not done on any of the words. This must appear before any other precommand modifier, as it is interpreted immediately, before any parsing is done. It has no effect in non-interactive shells.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-readonly">
<h3><code>readonly</code> <a class="doc-anchor" href="#doc-lsp-keyword-readonly">¶</a></h3>
<p>Same as <code>typeset -r</code>. With the <code>POSIX_BUILTINS</code> option set, same as <code>typeset -gr</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-repeat">
<h3><code>repeat</code> <a class="doc-anchor" href="#doc-lsp-keyword-repeat">¶</a></h3>
<p><em>word</em> is expanded and treated as an arithmetic expression, which must evaluate to a number <em>n</em>. <em>list</em> is then executed <em>n</em> times.</p>
<p>The <code>repeat</code> syntax is disabled by default when the shell starts in a mode emulating another shell. It can be enabled with the command "enable -r repeat"</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-select">
<h3><code>select</code> <a class="doc-anchor" href="#doc-lsp-keyword-select">¶</a></h3>
<p>where <em>term</em> is one or more newline or <code>;</code> to terminate the _word_s. vindex(REPLY, use of) Print the set of _word_s, each preceded by a number. If the <code>in</code> <em>word</em> is omitted, use the positional parameters. The <code>PROMPT3</code> prompt is printed and a line is read from the line editor if the shell is interactive and that is active, or else standard input. If this line consists of the number of one of the listed _word_s, then the parameter <em>name</em> is set to the <em>word</em> corresponding to this number. If this line is empty, the selection list is printed again. Otherwise, the value of the parameter <em>name</em> is set to null. The contents of the line read from standard input is saved in the parameter <code>REPLY</code>. <em>list</em> is executed for each selection until a break or end-of-file is encountered.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-then">
<h3><code>then</code> <a class="doc-anchor" href="#doc-lsp-keyword-then">¶</a></h3>
<p>Body separator for <code>if</code>/<code>elif</code>. <code>if cmd; then body; fi</code></p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-time">
<h3><code>time</code> <a class="doc-anchor" href="#doc-lsp-keyword-time">¶</a></h3>
<p>The <em>pipeline</em> is executed, and timing statistics are reported on the standard error in the form specified by the <code>TIMEFMT</code> parameter. If <em>pipeline</em> is omitted, print statistics about the shell process and its children.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-typeset">
<h3><code>typeset</code> <a class="doc-anchor" href="#doc-lsp-keyword-typeset">¶</a></h3>
<p>Set or display attributes and values for shell parameters.</p>
<p>Except as noted below for control flags that change the behavior, a parameter is created for each <em>name</em> that does not already refer to one. When inside a function, a new parameter is created for every <em>name</em> (even those that already exist), and is unset again when the function completes. See <em>Local Parameters</em> (zshparam). The same rules apply to special shell parameters, which retain their special attributes when made local.</p>
<p>For each <em>name</em><code>=</code><em>value</em> assignment, the parameter <em>name</em> is set to <em>value</em>. If the assignment is omitted and <em>name</em> does <em>not</em> refer to an existing parameter, a new parameter is initialized to empty string, zero, or empty array (as appropriate), <em>unless</em> the shell option <code>TYPESET_TO_UNSET</code> is set. When that option is set, the parameter attributes are recorded but the parameter remains unset.</p>
<p>If the shell option <code>TYPESET_SILENT</code> is not set, for each remaining <em>name</em> that refers to a parameter that is already set, the name and value of the parameter are printed in the form of an assignment. Nothing is printed for newly-created parameters, or when any attribute flags listed below are given along with the <em>name</em>. Using "+" instead of minus to introduce an attribute turns it off.</p>
<p>If no <em>name</em> is present, the names and values of all parameters are printed. In this case the attribute flags restrict the display to only those parameters that have the specified attributes, and using "+" rather than "-" to introduce the flag suppresses printing of the values of parameters when there is no parameter name.</p>
<p>All forms of the command handle scalar assignment. Array assignment is possible if any of the reserved words <code>declare</code>, <code>export</code>, <code>float</code>, <code>integer</code>, <code>local</code>, <code>readonly</code> or <code>typeset</code> is matched when the line is parsed (N.B. not when it is executed). In this case the arguments are parsed as assignments, except that the "+=" syntax and the <code>GLOB_ASSIGN</code> option are not supported, and scalar values after <code>=</code> are <em>not</em> split further into words, even if expanded (regardless of the setting of the <code>KSH_TYPESET</code> option; this option is obsolete).</p>
<p>Examples of the differences between command and reserved word parsing:</p>
<p>example(# Reserved word parsing typeset svar=$(echo one word) avar=(several words))</p>
<p>The above creates a scalar parameter <code>svar</code> and an array parameter <code>avar</code> as if the assignments had been</p>
<p>example(svar="one word" avar=(several words))</p>
<p>On the other hand:</p>
<p>example(# Normal builtin interface builtin typeset svar=$(echo two words))</p>
<p>The <code>builtin</code> keyword causes the above to use the standard builtin interface to <code>typeset</code> in which argument parsing is performed in the same way as for other commands. This example creates a scalar <code>svar</code> containing the value <code>two</code> and another scalar parameter <code>words</code> with no value. An array value in this case would either cause an error or be treated as an obscure set of glob qualifiers.</p>
<p>Arbitrary arguments are allowed if they take the form of assignments after command line expansion; however, these only perform scalar assignment:</p>
<p> var='svar=val' typeset $var</p>
<p>The above sets the scalar parameter <code>svar</code> to the value <code>val</code>. Parentheses around the value within <code>var</code> would not cause array assignment as they will be treated as ordinary characters when <code>$var</code> is substituted. Any non-trivial expansion in the name part of the assignment causes the argument to be treated in this fashion:</p>
<p> typeset {var1,var2,var3}=name</p>
<p>The above syntax is valid, and has the expected effect of setting the three parameters to the same value, but the command line is parsed as a set of three normal command line arguments to <code>typeset</code> after expansion. Hence it is not possible to assign to multiple arrays by this means.</p>
<p>Note that each interface to any of the commands may be disabled separately. For example, "disable -r typeset" disables the reserved word interface to <code>typeset</code>, exposing the builtin interface, while "disable typeset" disables the builtin. Note that disabling the reserved word interface for <code>typeset</code> may cause problems with the output of "typeset -p", which assumes the reserved word interface is available in order to restore array and associative array values.</p>
<p>Unlike parameter assignment statements, <code>typeset</code>'s exit status on an assignment that involves a command substitution does not reflect the exit status of the command substitution. Therefore, to test for an error in a command substitution, separate the declaration of the parameter from its initialization:</p>
<p>example(# WRONG typeset var1=$(exit 1) || echo "Trouble with var1"</p>
<p># RIGHT typeset var1 && var1=$(exit 1) || echo "Trouble with var1" )</p>
<p>To initialize a parameter <em>param</em> to a command output and mark it readonly, use <code>typeset -r </code><em>param</em> or <code>readonly </code><em>param</em> after the parameter assignment statement.</p>
<p>cindex(named reference) cindex(reference, named) The flag <code>-n</code> creates a <em>named reference</em> to another parameter. The second parameter need not exist at the time the reference is created. Only the <code>-H</code>, <code>-g</code>, and <code>-r</code> flags may be used in conjunction with <code>-n</code>, having their usual meanings. The <code>-u</code> flag is special and may be applied to alter the scope of the reference. The <em>name</em> so created may not be an array element nor use a subscript, but the <em>value</em> assigned may be any valid parameter name syntax, even a subscripted array element (including an associative array element) or an array slice, which is evaluated when the named reference is expanded. It is an error for a named reference to refer to itself, even indirectly through a chain of references. When <code>-u</code> is applied to a named reference, the parameter identified by <em>value</em> is always found in the calling function scope rather than the current local scope. In this case, if there is no such parameter in the calling scope, assignments to the named reference may fail, setting <code>$?</code> to 1. See <em>Parameter Expansion</em> (zshexpn) and <em>Named References</em> (zshparam) for details of the behavior of named references.</p>
<p>Local function scoping rules for "typeset" do apply with "-n", so a declaration within a function persists only until the end of the function unless "-g -n" is specified, and any local parameter (of any type) with the same <em>name</em> supplants a named reference from a surrounding scope.</p>
<p>A scalar parameter, including an existing named reference, may be converted to a new named reference by <code></code>typeset -n "<em>name</em>", so the "-p" option must be included to display the value of a specific named reference <em>name</em>.</p>
<p>If no attribute flags are given, and either no <em>name</em> arguments are present or the flag <code>+m</code> is used, then each parameter name printed is preceded by a list of the attributes of that parameter (<code>array</code>, <code>association</code>, <code>exported</code>, <code>float</code>, <code>integer</code>, <code>readonly</code>, or <code>undefined</code> for autoloaded parameters not yet loaded). If <code>+m</code> is used with attribute flags, and all those flags are introduced with <code>+</code>, the matching parameter names are printed but their values are not.</p>
<p>The following control flags change the behavior of <code>typeset</code>:</p>
<p>- <strong><code>+</code></strong> — If "+" appears by itself in a separate word as the last option, then the names of all parameters (functions with <code>-f</code>) are printed, but the values (function bodies) are not. If <em>name</em> arguments appear, both those names and their values are printed in the form of assignments. It is an error for any other options to follow "+", but the effect of "+" is as if all attribute flags which precede it were given with a "+" prefix. For example, "typeset -U +" is equivalent to "typeset +U" and displays the names of all arrays having the uniqueness attribute, whereas "typeset -f -U +" displays the names of all autoloadable functions. If <code>+</code> is the only option, then type information (array, readonly, etc.) is also printed for each parameter, in the same manner as "typeset +m "*"".</p>
<p>- <strong><code>-g</code></strong> — The <code>-g</code> (global) means that any resulting parameter will not be restricted to local scope. Note that this does not necessarily mean that the parameter will be global, as the flag will apply to any existing parameter (even if unset) from an enclosing function. This flag does not affect the parameter after creation, hence it has no effect when listing existing parameters, nor does the flag <code>+g</code> have any effect except in combination with <code>-m</code> (see below).</p>
<p>- <strong><code>-m</code></strong> — If the <code>-m</code> flag is given the <em>name</em> arguments are taken as patterns (use quoting to prevent these from being interpreted as file patterns). With no attribute flags, all parameters (or functions with the <code>-f</code> flag) with matching names are printed (the shell option <code>TYPESET_SILENT</code> is not used in this case).</p>
<p>If the <code>+g</code> flag is combined with <code>-m</code>, a new local parameter is created for every matching parameter that is not already local. Otherwise <code>-m</code> applies all other flags or assignments to the existing parameters, except that the <code>-n</code> option cannot create named references in this way.</p>
<p>Except when assignments are made with <em>name</em><code>=</code><em>value</em>, using <code>+m</code> forces the matching parameters and their attributes to be printed, even inside a function. Note that <code>-m</code> is ignored if no patterns are given, so "typeset -m" displays attributes but "typeset -a +m" does not. Ordinary scalar string parameters have no attributes, so for those <code>+m</code> prints only the names.</p>
<p>- <strong><code>-p</code> [ <em>n</em> ]</strong> — If the <code>-p</code> option is given, parameters and values are printed in the form of a typeset command with an assignment, regardless of other flags and options. Note that the <code>-H</code> flag on parameters is respected; no value will be shown for these parameters.</p>
<p><code>-p</code> may be followed by an optional integer argument. Currently only the value <code>1</code> is supported. In this case arrays and associative arrays are printed with newlines between indented elements for readability.</p>
<p>The names and values of readonly special parameters (most of the parameters marked "<S>" in <em>Parameters Set by the Shell</em> (zshparam), except those documented as settable) are not printed with <code></code>-"p" because to execute those typeset commands would cause errors. However, these parameters are printed when they have been made local to the scope where "typeset -p" is run.</p>
<p>- <strong><code>-T</code> [ <em>scalar</em>[<code>=</code><em>value</em>] <em>array</em>[<code>=()_value_ ...</code><code></code>] [ <em>sep</em> ] ]</strong> — This flag has a different meaning when used with <code>-f</code>; see below. Otherwise the <code>-T</code> option requires zero, two, or three arguments to be present. With no arguments, the list of parameters created in this fashion is shown. With two or three arguments, the first two are the name of a scalar and of an array parameter (in that order) that will be tied together in the manner of <code>$PATH</code> and <code>$path</code>. The optional third argument is a single-character separator which will be used to join the elements of the array to form the scalar; if absent, a colon is used, as with <code>$PATH</code>. Only the first character of the separator is significant; any remaining characters are ignored. Multibyte characters are not yet supported.</p>
<p>Only one of the scalar and array parameters may be assigned an initial value (the restrictions on assignment forms described above also apply).</p>
<p>Both the scalar and the array may be manipulated as normal. If one is unset, the other will automatically be unset too. There is no way of untying the variables without unsetting them, nor of converting the type of one of them with another <code>typeset</code> command; <code>+T</code> does not work, assigning an array to <em>scalar</em> is an error, and assigning a scalar to <em>array</em> sets it to be a single-element array.</p>
<p>Note that both "typeset -xT ..." and "export -T ..." work, but only the scalar will be marked for export. Setting the value using the scalar version causes a split on all separators (which cannot be quoted). It is possible to apply <code>-T</code> to two previously tied variables but with a different separator character, in which case the variables remain joined as before but the separator is changed.</p>
<p>When an existing scalar is tied to a new array, the value of the scalar is preserved but no attribute other than export will be preserved.</p>
<p>Attribute flags that transform the final value (<code>-L</code>, <code>-R</code>, <code>-Z</code>, <code>-l</code>, <code>-u</code>) are only applied to the expanded value at the point of a parameter expansion expression using "$". They are not applied when a parameter is retrieved internally by the shell for any purpose.</p>
<p>The following attribute flags may be specified:</p>
<p>- <strong><code>-A</code></strong> — The names refer to associative array parameters; see <em>Array Parameters</em> (zshparam).</p>
<p>- <strong><code>-L</code> [ <em>n</em> ]</strong> — Left justify and remove leading blanks from the value when the parameter is expanded. If <em>n</em> is nonzero, it defines the width of the field. If <em>n</em> is zero, the width is determined by the width of the value of the first assignment. In the case of numeric parameters, the length of the complete value assigned to the parameter is used to determine the width, not the value that would be output.</p>
<p>The width is the count of characters, which may be multibyte characters if the <code>MULTIBYTE</code> option is in effect. Note that the screen width of the character is not taken into account; if this is required, use padding with parameter expansion flags tt(${+(ml)<em>...</em><code></code>)<em>...</em><code>}</code> as described in subref(Parameter Expansion Flags)(zshexpn).</p>
<p>When the parameter is expanded, it is filled on the right with blanks or truncated if necessary to fit the field. Note truncation can lead to unexpected results with numeric parameters. Leading zeros are removed if the <code>-Z</code> flag is also set.</p>
<p>- <strong><code>-R</code> [ <em>n</em> ]</strong> — Similar to <code>-L</code>, except that right justification is used; when the parameter is expanded, the field is left filled with blanks or truncated from the end. May not be combined with the <code>-Z</code> flag.</p>
<p>- <strong><code>-U</code></strong> — For arrays (but not for associative arrays), keep only the first occurrence of each duplicated value. This may also be set for tied parameters (see <code>-T</code>) or colon-separated special parameters like <code>PATH</code> or <code>FIGNORE</code>, etc. Note the flag takes effect on assignment, and the type of the variable being assigned to is determinative; for variables with shared values it is therefore recommended to set the flag for all interfaces, e.g. "typeset -U PATH path".</p>
<p>This flag has a different meaning when used with <code>-f</code>; see below.</p>
<p>- <strong><code>-Z</code> [ <em>n</em> ]</strong> — Specially handled if set along with the <code>-L</code> flag. Otherwise, similar to <code>-R</code>, except that leading zeros are used for padding instead of blanks if the first non-blank character is a digit. Numeric parameters are specially handled: they are always eligible for padding with zeroes, and the zeroes are inserted at an appropriate place in the output.</p>
<p>- <strong><code>-a</code></strong> — The names refer to array parameters. An array parameter may be created this way, but it may be assigned to in the <code>typeset</code> statement only if the reserved word form of <code>typeset</code> is enabled (as it is by default). When displaying, both normal and associative arrays are shown.</p>
<p>- <strong><code>-f</code></strong> — The names refer to functions rather than parameters. No assignments can be made, and the only other valid flags are <code>-t</code>, <code>-T</code>, <code>-k</code>, <code>-u</code>, <code>-U</code> and <code>-z</code>. The flag <code>-t</code> turns on execution tracing for this function; the flag <code>-T</code> does the same, but turns off tracing for any named (not anonymous) function called from the present one, unless that function also has the <code>-t</code> or <code>-T</code> flag. The <code>-u</code> and <code>-U</code> flags cause the function to be marked for autoloading; <code>-U</code> also causes alias expansion to be suppressed when the function is loaded. See the description of the "autoload" builtin for details.</p>
<p>Note that the builtin <code>functions</code> provides the same basic capabilities as <code>typeset -f</code> but gives access to a few extra options; <code>autoload</code> gives further additional options for the case <code>typeset -fu</code> and <code>typeset -fU</code>.</p>
<p>- <strong><code>-h</code></strong> — Hide: only useful for special parameters (those marked "<S>" in the table in <em>Parameters Set by the Shell</em> (zshparam)), and for local parameters with the same name as a special parameter, though harmless for others. A special parameter with this attribute will not retain its special effect when made local. Thus after <code></code>typeset -h PATH<code>', a function containing "typeset PATH" will create an ordinary local parameter without the usual behaviour of </code>PATH<code>. Alternatively, the local parameter may itself be given this attribute; hence inside a function "typeset -h PATH" creates an ordinary local parameter and the special </code>PATH<code> parameter is not altered in any way. It is also possible to create a local parameter using </code><code>typeset +h "_special_", where the local copy of _special_ will retain its special properties regardless of having the </code>-h<code> attribute. Global special parameters loaded from shell modules (for example, those in </code>zsh/mapfile<code> and </code>zsh/parameter<code>) are automatically given the </code>-h<code> attribute to avoid name clashes.</code></p>
<p>- <strong><code>-H</code></strong> — Hide value: specifies that <code>typeset</code> will not display the value of the parameter when listing parameters; the display for such parameters is always as if the "+" flag were given, but use of the parameter is in other respects normal. This effect does not apply when the parameter is specified by name or by pattern with the <code>-m</code> option. This is on by default for the parameters in the <code>zsh/parameter</code> and <code>zsh/mapfile</code> modules. Note, however, that unlike the <code>-h</code> flag this is also useful for non-special parameters.</p>
<p>- <strong><code>-i</code> [ <em>n</em> ]</strong> — Use an internal integer representation. If <em>n</em> is nonzero it defines the output arithmetic base, otherwise it is determined by the first assignment. Bases from 2 to 36 inclusive are allowed.</p>
<p>- <strong><code>-E</code> [ <em>n</em> ]</strong> — Use an internal double-precision floating point representation. On output the variable will be converted to scientific notation. If <em>n</em> is nonzero it defines the number of significant figures to display; the default is ten.</p>
<p>- <strong><code>-F</code> [ <em>n</em> ]</strong> — Use an internal double-precision floating point representation. On output the variable will be converted to fixed-point decimal notation. If <em>n</em> is nonzero it defines the number of digits to display after the decimal point; the default is ten.</p>
<p>- <strong><code>-l</code></strong> — Convert the result to lower case whenever the parameter is expanded. The value is <em>not</em> converted when assigned.</p>
<p>- <strong><code>-r</code></strong> — The given _name_s are marked readonly. Note that if <em>name</em> is a special parameter, the readonly attribute can be turned on, but cannot then be turned off.</p>
<p>If the <code>POSIX_BUILTINS</code> option is set, the readonly attribute is more restrictive: unset variables can be marked readonly and cannot then be set; furthermore, the readonly attribute cannot be removed from any variable.</p>
<p>It is still possible to change other attributes of the variable though, some of which like <code>-U</code> or <code>-Z</code> would affect the value. More generally, the readonly attribute should not be relied on as a security mechanism.</p>
<p>Note that in zsh (like in pdksh but unlike most other shells) it is still possible to create a local variable of the same name as this is considered a different variable (though this variable, too, can be marked readonly). Special variables that have been made readonly retain their value and readonly attribute when made local.</p>
<p>- <strong><code>-t</code></strong> — Tags the named parameters. Tags only exist to flag the parameter for the user's own purposes --- the list of tagged parameters can be queried using "typeset -t". Tags have no other use. Note that the <code>-t</code> flag has a different meaning when used with <code>-f</code>; see above.</p>
<p>- <strong><code>-u</code></strong> — Convert the result to upper case whenever the parameter is expanded. The value is <em>not</em> converted when assigned. This flag has different meanings when used with <code>-f</code> or <code>-n</code>; see above.</p>
<p>- <strong><code>-x</code></strong> — Mark for automatic export to the environment of subsequently executed commands. If the option <code>GLOBAL_EXPORT</code> is set, this implies the option <code>-g</code>, unless <code>+g</code> is also explicitly given; in other words the parameter is not made local to the enclosing function. This is for compatibility with previous versions of zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-until">
<h3><code>until</code> <a class="doc-anchor" href="#doc-lsp-keyword-until">¶</a></h3>
<p>Execute the <code>do</code> <em>list</em> as long as <code>until</code> <em>list</em> returns a nonzero exit status.</p>
</article>
<article class="doc-entry" id="doc-lsp-keyword-while">
<h3><code>while</code> <a class="doc-anchor" href="#doc-lsp-keyword-while">¶</a></h3>
<p>Execute the <code>do</code> <em>list</em> as long as the <code>while</code> <em>list</em> returns a zero exit status.</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-options">
<h2>Option Index</h2>
<p class="chapter-meta">197 entries · the canonical zsh option registry. Set / clear via <code>setopt NAME</code> / <code>unsetopt NAME</code>.</p>
<article class="doc-entry" id="doc-lsp-option-aliases">
<h3><code>aliases</code> <a class="doc-anchor" href="#doc-lsp-option-aliases">¶</a></h3>
<p>This maps the names of the regular aliases currently enabled to their expansions.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-aliasfuncdef">
<h3><code>aliasfuncdef</code> <a class="doc-anchor" href="#doc-lsp-option-aliasfuncdef">¶</a></h3>
<p>By default, zsh does not allow the definition of functions using the "<em>name</em> tt(())" syntax if <em>name</em> was expanded as an alias: this causes an error. This is usually the desired behaviour, as otherwise the combination of an alias and a function based on the same definition can easily cause problems.</p>
<p>When this option is set, aliases can be used for defining functions.</p>
<p>For example, consider the following definitions as they might occur in a startup file.</p>
<p>example(alias foo=bar foo+() { print This probably does not do what you expect. })</p>
<p>Here, <code>foo</code> is expanded as an alias to <code>bar</code> before the tt(()) is encountered, so the function defined would be named <code>bar</code>. By default this is instead an error in native mode. Note that quoting any part of the function name, or using the keyword <code>function</code>, avoids the problem, so is recommended when the function name can also be an alias.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-allexport">
<h3><code>allexport</code> <a class="doc-anchor" href="#doc-lsp-option-allexport">¶</a></h3>
<p>All parameters subsequently defined are automatically exported.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-alwayslastprompt">
<h3><code>alwayslastprompt</code> <a class="doc-anchor" href="#doc-lsp-option-alwayslastprompt">¶</a></h3>
<p>If unset, key functions that list completions try to return to the last prompt if given a numeric argument. If set these functions try to return to the last prompt if given <em>no</em> numeric argument.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-alwaystoend">
<h3><code>alwaystoend</code> <a class="doc-anchor" href="#doc-lsp-option-alwaystoend">¶</a></h3>
<p>If a completion is performed with the cursor within a word, and a full completion is inserted, the cursor is moved to the end of the word. That is, the cursor is moved to the end of the word if either a single match is inserted or menu completion is performed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-appendcreate">
<h3><code>appendcreate</code> <a class="doc-anchor" href="#doc-lsp-option-appendcreate">¶</a></h3>
<p>This option only applies when <code>NO_CLOBBER</code> (-<code>C</code>) is in effect.</p>
<p>If this option is not set, the shell will report an error when a append redirection (<code>>></code>) is used on a file that does not already exists (the traditional zsh behaviour of <code>NO_CLOBBER</code>). If the option is set, no error is reported (POSIX behaviour).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-appendhistory">
<h3><code>appendhistory</code> <a class="doc-anchor" href="#doc-lsp-option-appendhistory">¶</a></h3>
<p>If this is set, zsh sessions will append their history list to the history file, rather than replace it. Thus, multiple parallel zsh sessions will all have the new entries from their history lists added to the history file, in the order that they exit. The file will still be periodically re-written to trim it when the number of lines grows 20% beyond the value specified by <code>$SAVEHIST</code> (see also the <code>HIST_SAVE_BY_COPY</code> option).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autocd">
<h3><code>autocd</code> <a class="doc-anchor" href="#doc-lsp-option-autocd">¶</a></h3>
<p>If a command is issued that can't be executed as a normal command, and the command is the name of a directory, perform the <code>cd</code> command to that directory. This option is only applicable if the option <code>SHIN_STDIN</code> is set, i.e. if commands are being read from standard input. The option is designed for interactive use; it is recommended that <code>cd</code> be used explicitly in scripts to avoid ambiguity.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autocontinue">
<h3><code>autocontinue</code> <a class="doc-anchor" href="#doc-lsp-option-autocontinue">¶</a></h3>
<p>With this option set, stopped jobs that are removed from the job table with the <code>disown</code> builtin command are automatically sent a <code>CONT</code> signal to make them running.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autolist">
<h3><code>autolist</code> <a class="doc-anchor" href="#doc-lsp-option-autolist">¶</a></h3>
<p>Automatically list choices on an ambiguous completion.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-automenu">
<h3><code>automenu</code> <a class="doc-anchor" href="#doc-lsp-option-automenu">¶</a></h3>
<p>Automatically use menu completion after the second consecutive request for completion, for example by pressing the tab key repeatedly. This option is overridden by <code>MENU_COMPLETE</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autonamedirs">
<h3><code>autonamedirs</code> <a class="doc-anchor" href="#doc-lsp-option-autonamedirs">¶</a></h3>
<p>Any parameter that is set to the absolute name of a directory immediately becomes a name for that directory, that will be used by the "%~" and related prompt sequences, and will be available when completion is performed on a word starting with "~". (Otherwise, the parameter must be used in the form <code></code>~"<em>param</em>" first.)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autoparamkeys">
<h3><code>autoparamkeys</code> <a class="doc-anchor" href="#doc-lsp-option-autoparamkeys">¶</a></h3>
<p>If a parameter name was completed and a following character (normally a space) automatically inserted, and the next character typed is one of those that have to come directly after the name (like "}", ":", etc.), the automatically added character is deleted, so that the character typed comes immediately after the parameter name. Completion in a brace expansion is affected similarly: the added character is a ",", which will be removed if "}" is typed next.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autoparamslash">
<h3><code>autoparamslash</code> <a class="doc-anchor" href="#doc-lsp-option-autoparamslash">¶</a></h3>
<p>If a parameter is completed whose content is the name of a directory, then add a trailing slash instead of a space.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autopushd">
<h3><code>autopushd</code> <a class="doc-anchor" href="#doc-lsp-option-autopushd">¶</a></h3>
<p>Make <code>cd</code> push the old directory onto the directory stack.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autoremoveslash">
<h3><code>autoremoveslash</code> <a class="doc-anchor" href="#doc-lsp-option-autoremoveslash">¶</a></h3>
<p>When the last character resulting from a completion is a slash and the next character typed is a word delimiter, a slash, or a character that ends a command (such as a semicolon or an ampersand), remove the slash.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-autoresume">
<h3><code>autoresume</code> <a class="doc-anchor" href="#doc-lsp-option-autoresume">¶</a></h3>
<p>Treat single word simple commands without redirection as candidates for resumption of an existing job.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-badpattern">
<h3><code>badpattern</code> <a class="doc-anchor" href="#doc-lsp-option-badpattern">¶</a></h3>
<p>If a pattern for filename generation is badly formed, print an error message. (If this option is unset, the pattern will be left unchanged.)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-banghist">
<h3><code>banghist</code> <a class="doc-anchor" href="#doc-lsp-option-banghist">¶</a></h3>
<p>Perform textual history expansion, <strong>csh</strong>-style, treating the character "!" specially.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-bareglobqual">
<h3><code>bareglobqual</code> <a class="doc-anchor" href="#doc-lsp-option-bareglobqual">¶</a></h3>
<p>In a glob pattern, treat a trailing set of parentheses as a qualifier list, if it contains no unquoted "|", "tt(()" or (if special) "~" characters. See <em>Filename Generation</em> (zshexpn).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-bashautolist">
<h3><code>bashautolist</code> <a class="doc-anchor" href="#doc-lsp-option-bashautolist">¶</a></h3>
<p>On an ambiguous completion, automatically list choices when the completion function is called twice in succession. This takes precedence over <code>AUTO_LIST</code>. The setting of <code>LIST_AMBIGUOUS</code> is respected. If <code>AUTO_MENU</code> is set, the menu behaviour will then start with the third press. Note that this will not work with <code>MENU_COMPLETE</code>, since repeated completion calls immediately cycle through the list in that case.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-bashrematch">
<h3><code>bashrematch</code> <a class="doc-anchor" href="#doc-lsp-option-bashrematch">¶</a></h3>
<p>When set, matches performed with the <code>=~</code> operator will set the <code>BASH_REMATCH</code> array variable, instead of the default <code>MATCH</code> and <code>match</code> variables. The first element of the <code>BASH_REMATCH</code> array will contain the entire matched text and subsequent elements will contain extracted substrings. This option makes more sense when <code>KSH_ARRAYS</code> is also set, so that the entire matched portion is stored at index 0 and the first substring is at index 1. Without this option, the <code>MATCH</code> variable contains the entire matched text and the <code>match</code> array variable contains substrings.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-beep">
<h3><code>beep</code> <a class="doc-anchor" href="#doc-lsp-option-beep">¶</a></h3>
<p>Beep, unless the <code>BEEP</code> option is unset.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-bgnice">
<h3><code>bgnice</code> <a class="doc-anchor" href="#doc-lsp-option-bgnice">¶</a></h3>
<p>Run all background jobs at a lower priority. This option is set by default.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-braceccl">
<h3><code>braceccl</code> <a class="doc-anchor" href="#doc-lsp-option-braceccl">¶</a></h3>
<p>Expand expressions in braces which would not otherwise undergo brace expansion to a lexically ordered list of all the characters. See <em>Brace Expansion</em> (zshexpn).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-braceexpand">
<h3><code>braceexpand</code> <a class="doc-anchor" href="#doc-lsp-option-braceexpand">¶</a></h3>
<p><em>NO</em>_<code>IGNORE_BRACES</code> (ksh and bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-bsdecho">
<h3><code>bsdecho</code> <a class="doc-anchor" href="#doc-lsp-option-bsdecho">¶</a></h3>
<p>Make the <code>echo</code> builtin compatible with the BSD manref(echo)(1) command. This disables backslashed escape sequences in echo strings unless the <code>-e</code> option is specified.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-caseglob">
<h3><code>caseglob</code> <a class="doc-anchor" href="#doc-lsp-option-caseglob">¶</a></h3>
<p>Make globbing (filename generation) sensitive to case. Note that other uses of patterns are always sensitive to case. If the option is unset, the presence of any character which is special to filename generation will cause case-insensitive matching. For example, tt(cvs+(/+)) can match the directory <code>CVS</code> owing to the presence of the globbing flag (unless the option <code>BARE_GLOB_QUAL</code> is unset).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-casematch">
<h3><code>casematch</code> <a class="doc-anchor" href="#doc-lsp-option-casematch">¶</a></h3>
<p>Make regular expressions using the <code>zsh/regex</code> module (including matches with <code>=~</code>) sensitive to case.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-casepaths">
<h3><code>casepaths</code> <a class="doc-anchor" href="#doc-lsp-option-casepaths">¶</a></h3>
<p>If <code>CASE_PATHS</code> is not set (the default), <code>CASE_GLOB</code> affects the interpretation of <em>every</em> path component, whenever a special character appears in <em>any</em> component. When <code>CASE_PATHS</code> is set, file path components that do <em>not</em> contain special filename generation characters are always sensitive to case, thus restricting <code>NO_CASE_GLOB</code> to components that contain globbing characters.</p>
<p>Note that if the filesystem itself is not sensitive to case, then <code>CASE_PATHS</code> has no effect.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cbases">
<h3><code>cbases</code> <a class="doc-anchor" href="#doc-lsp-option-cbases">¶</a></h3>
<p>Output hexadecimal numbers in the standard C format, for example "0xFF" instead of the usual "16#FF". If the option <code>OCTAL_ZEROES</code> is also set (it is not by default), octal numbers will be treated similarly and hence appear as "077" instead of "8#77". This option has no effect on the choice of the output base, nor on the output of bases other than hexadecimal and octal. Note that these formats will be understood on input irrespective of the setting of <code>C_BASES</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cdablevars">
<h3><code>cdablevars</code> <a class="doc-anchor" href="#doc-lsp-option-cdablevars">¶</a></h3>
<p>If the argument to a <code>cd</code> command (or an implied <code>cd</code> with the <code>AUTO_CD</code> option set) is not a directory, and does not begin with a slash, try to expand the expression as if it were preceded by a "~" (see <em>Filename Expansion</em> (zshexpn)).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cdsilent">
<h3><code>cdsilent</code> <a class="doc-anchor" href="#doc-lsp-option-cdsilent">¶</a></h3>
<p>Never print the working directory after a <code>cd</code> (whether explicit or implied with the <code>AUTO_CD</code> option set). <code>cd</code> normally prints the working directory when the argument given to it was <code>-</code>, a stack entry, or the name of a directory found under <code>CDPATH</code>. Note that this is distinct from <code>pushd</code>'s stack-printing behaviour, which is controlled by <code>PUSHD_SILENT</code>. This option overrides the printing-related effects of <code>POSIX_CD</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-chasedots">
<h3><code>chasedots</code> <a class="doc-anchor" href="#doc-lsp-option-chasedots">¶</a></h3>
<p>When changing to a directory containing a path segment ".." which would otherwise be treated as canceling the previous segment in the path (in other words, "foo/.." would be removed from the path, or if ".." is the first part of the path, the last part of the current working directory would be removed), instead resolve the path to the physical directory. This option is overridden by <code>CHASE_LINKS</code>.</p>
<p>For example, suppose <code>/foo/bar</code> is a link to the directory <code>/alt/rod</code>. Without this option set, "cd /foo/bar/.." changes to <code>/foo</code>; with it set, it changes to <code>/alt</code>. The same applies if the current directory is <code>/foo/bar</code> and "cd .." is used. Note that all other symbolic links in the path will also be resolved.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-chaselinks">
<h3><code>chaselinks</code> <a class="doc-anchor" href="#doc-lsp-option-chaselinks">¶</a></h3>
<p>Resolve symbolic links to their true values when changing directory. This also has the effect of <code>CHASE_DOTS</code>, i.e. a ".." path segment will be treated as referring to the physical parent, even if the preceding path segment is a symbolic link.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-checkjobs">
<h3><code>checkjobs</code> <a class="doc-anchor" href="#doc-lsp-option-checkjobs">¶</a></h3>
<p>Report the status of background and suspended jobs before exiting a shell with job control; a second attempt to exit the shell will succeed. <code>NO_CHECK_JOBS</code> is best used only in combination with <code>NO_HUP</code>, else such jobs will be killed automatically.</p>
<p>The check is omitted if the commands run from the previous command line included a "jobs" command, since it is assumed the user is aware that there are background or suspended jobs. A "jobs" command run from one of the hook functions defined in <em>Special Functions</em> (zshmisc) is not counted for this purpose.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-checkrunningjobs">
<h3><code>checkrunningjobs</code> <a class="doc-anchor" href="#doc-lsp-option-checkrunningjobs">¶</a></h3>
<p>Check for both running and suspended jobs when <code>CHECK_JOBS</code> is enabled. When this option is disabled, zsh checks only for suspended jobs, which matches the default behavior of bash.</p>
<p>This option has no effect unless <code>CHECK_JOBS</code> is set.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-clobber">
<h3><code>clobber</code> <a class="doc-anchor" href="#doc-lsp-option-clobber">¶</a></h3>
<p>Allows ">" redirection to truncate existing files. Otherwise ">!" or ">|" must be used to truncate a file.</p>
<p>If the option is not set, and the option <code>APPEND_CREATE</code> is also not set, ">>!" or ">>|" must be used to create a file. If either option is set, ">>" may be used.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-clobberempty">
<h3><code>clobberempty</code> <a class="doc-anchor" href="#doc-lsp-option-clobberempty">¶</a></h3>
<p>This option is only used if the option <code>CLOBBER</code> is not set: note that it is set by default.</p>
<p>If this option is set, then regular files of zero length may be ovewritten ("clobbered"). Note that it is possible another process has written to the file between this test and use of the file by the current process. This option should therefore not be used in cases where files to be clobbered may be written to asynchronously.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-combiningchars">
<h3><code>combiningchars</code> <a class="doc-anchor" href="#doc-lsp-option-combiningchars">¶</a></h3>
<p>Assume that the terminal displays combining characters correctly. Specifically, if a base alphanumeric character is followed by one or more zero-width punctuation characters, assume that the zero-width characters will be displayed as modifications to the base character within the same width. Not all terminals handle this. If this option is not set, zero-width characters are displayed separately with special mark-up.</p>
<p>If this option is set, the pattern test <code>[[:WORD:]]</code> matches a zero-width punctuation character on the assumption that it will be used as part of a word in combination with a word character. Otherwise the base shell does not handle combining characters specially.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-completealiases">
<h3><code>completealiases</code> <a class="doc-anchor" href="#doc-lsp-option-completealiases">¶</a></h3>
<p>Prevents aliases on the command line from being internally substituted before completion is attempted. The effect is to make the alias a distinct command for completion purposes.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-completeinword">
<h3><code>completeinword</code> <a class="doc-anchor" href="#doc-lsp-option-completeinword">¶</a></h3>
<p>If unset, the cursor is set to the end of the word if completion is started. Otherwise it stays there and completion is done from both ends.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-continueonerror">
<h3><code>continueonerror</code> <a class="doc-anchor" href="#doc-lsp-option-continueonerror">¶</a></h3>
<p>If a fatal error is encountered (see <em>Errors</em> (zshmisc)), and the code is running in a script, the shell will resume execution at the next statement in the script at the top level, in other words outside all functions or shell constructs such as loops and conditions. This mimics the behaviour of interactive shells, where the shell returns to the line editor to read a new command; it was the normal behaviour in versions of zsh before 5.0.1.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-correct">
<h3><code>correct</code> <a class="doc-anchor" href="#doc-lsp-option-correct">¶</a></h3>
<p>Try to correct the spelling of commands. Note that, when the <code>HASH_LIST_ALL</code> option is not set or when some directories in the path are not readable, this may falsely report spelling errors the first time some commands are used.</p>
<p>Refer to the shell variable <code>SPROMPT</code> for an explanation of the "[nyae]" (no/yes/abort/edit) prompt that is offered.</p>
<p>The shell variable <code>CORRECT_IGNORE</code> may be set to a pattern to match words that will never be offered as corrections.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-correctall">
<h3><code>correctall</code> <a class="doc-anchor" href="#doc-lsp-option-correctall">¶</a></h3>
<p>Try to correct the spelling of all arguments in a line, in order from left to right, treating each as a file name. Answering "a" or "e" at any prompt stops all corrections, otherwise every correction is prompted for.</p>
<p>The shell variable <code>CORRECT_IGNORE_FILE</code> may be set to a pattern to match file names that will never be offered as corrections.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cprecedences">
<h3><code>cprecedences</code> <a class="doc-anchor" href="#doc-lsp-option-cprecedences">¶</a></h3>
<p>This alters the precedence of arithmetic operators to be more like C and other programming languages; <em>Arithmetic Evaluation</em> (zshmisc) has an explicit list.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cshjunkiehistory">
<h3><code>cshjunkiehistory</code> <a class="doc-anchor" href="#doc-lsp-option-cshjunkiehistory">¶</a></h3>
<p>A history reference without an event specifier will always refer to the previous command. Without this option, such a history reference refers to the same event as the previous history reference on the current command line, defaulting to the previous command.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cshjunkieloops">
<h3><code>cshjunkieloops</code> <a class="doc-anchor" href="#doc-lsp-option-cshjunkieloops">¶</a></h3>
<p>Allow loop bodies to take the form <code>_list_</code>; end<code>' instead of </code><code>do </code><em>list</em><code>; done</code>'.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cshjunkiequotes">
<h3><code>cshjunkiequotes</code> <a class="doc-anchor" href="#doc-lsp-option-cshjunkiequotes">¶</a></h3>
<p>Changes the rules for single- and double-quoted text to match that of <strong>csh</strong>. These require that embedded newlines be preceded by a backslash; unescaped newlines will cause an error message. In double-quoted strings, it is made impossible to escape "$", <code></code><code></code>' or """ (and "\" itself no longer needs escaping). Command substitutions are only expanded once, and cannot be nested.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cshnullcmd">
<h3><code>cshnullcmd</code> <a class="doc-anchor" href="#doc-lsp-option-cshnullcmd">¶</a></h3>
<p>Do not use the values of <code>NULLCMD</code> and <code>READNULLCMD</code> when running redirections with no command. This make such redirections fail (see <em>Redirection</em> (zshmisc)).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-cshnullglob">
<h3><code>cshnullglob</code> <a class="doc-anchor" href="#doc-lsp-option-cshnullglob">¶</a></h3>
<p>If a pattern for filename generation has no matches, delete the pattern from the argument list; do not report an error unless all the patterns in a command have no matches. Overrides <code>NOMATCH</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-debugbeforecmd">
<h3><code>debugbeforecmd</code> <a class="doc-anchor" href="#doc-lsp-option-debugbeforecmd">¶</a></h3>
<p>Run the <code>DEBUG</code> trap before each command; otherwise it is run after each command. Setting this option mimics the behaviour of ksh 93; with the option unset the behaviour is that of ksh 88.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-dotglob">
<h3><code>dotglob</code> <a class="doc-anchor" href="#doc-lsp-option-dotglob">¶</a></h3>
<p><code>GLOB_DOTS</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-dvorak">
<h3><code>dvorak</code> <a class="doc-anchor" href="#doc-lsp-option-dvorak">¶</a></h3>
<p>Use the Dvorak keyboard instead of the standard qwerty keyboard as a basis for examining spelling mistakes for the <code>CORRECT</code> and <code>CORRECT_ALL</code> options and the <code>spell-word</code> editor command.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-emacs">
<h3><code>emacs</code> <a class="doc-anchor" href="#doc-lsp-option-emacs">¶</a></h3>
<p>Move to the beginning of the previous word.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-equals">
<h3><code>equals</code> <a class="doc-anchor" href="#doc-lsp-option-equals">¶</a></h3>
<p>Perform <code>=</code> filename expansion. (See <em>Filename Expansion</em> (zshexpn).)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-errexit">
<h3><code>errexit</code> <a class="doc-anchor" href="#doc-lsp-option-errexit">¶</a></h3>
<p>If a command has a non-zero exit status, execute the <code>ZERR</code> trap, if set, and exit.</p>
<p>The option is ignored when executing the commands following <code>while</code>, <code>until</code>, <code>if</code>, or <code>elif</code>, a pipeline beginning with <code>!</code>, or any command other than the last in command list containing <code>&&</code> or <code>||</code>. Hence neither "if foo; then true; fi", nor <code></code>foo && true<code>' trigger exit when </code>foo<code> returns with a non-zero exit status. Note that if </code>foo<code> is a function, the option is also ignored during its whole execution.</code></p>
<p>The option is also ignored when executing a complex command (<code>if</code>, <code>for</code>, <code>while</code>, <code>until</code>, <code>repeat</code>, <code>case</code>, <code>select</code>, <code>always</code>, or a list in braces) if its exit status comes from a command executed while the option is ignored. Hence, the <code>if</code> command in "if true; then false && true; fi" does not trigger exit.</p>
<p>Finally, the option is also ignored while running initialization scripts and inside <code>DEBUG</code> traps. In the latter case, the option is handled specially: it is unset on entry to the trap. If the option <code>DEBUG_BEFORE_CMD</code> is set, as it is by default, and the option <code>ERR_EXIT</code> is found to have been set on exit, then the command for which the <code>DEBUG</code> trap is being executed is skipped. The option is restored after the trap exits.</p>
<p>Exiting due to <code>ERR_EXIT</code> has certain interactions with asynchronous jobs noted in <em>Signals</em> (zshmisc).</p>
<p>Note this behaviour is not disabled in interactive shells --- a non-zero status on the command line causes the shell to exit.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-errreturn">
<h3><code>errreturn</code> <a class="doc-anchor" href="#doc-lsp-option-errreturn">¶</a></h3>
<p>If a command has a non-zero exit status, return immediately from the enclosing function. Except as explained below, an implicit <code>return</code> statement is executed following the same logic described for <code>ERR_EXIT</code>. This will trigger an exit at the outermost level of a non-interactive script. At the top level of an interactive shell, it will trigger a return to the command prompt; in other words, the sequence of commands typed by the user may be thought of as a function for this purpose.</p>
<p>Unlike for <code>ERR_EXIT</code>, when a function is called while the option is being ignored, the option is NOT ignored during the execution of the function. Hence, if <code>foo</code> in "foo && true" is a function, code inside it is considered separately: it may force a return from <code>foo</code> (assuming the option remains set within <code>foo</code>).</p>
<p>Like for <code>ERR_EXIT</code>, the option is ignored inside <code>DEBUG</code> traps but it's not unset on entry to the trap and setting or unsetting it inside the trap has no special effect.</p>
<p>If <code>ERR_RETURN</code> and <code>ERR_EXIT</code> are both set, it may happen that both exit and return should be triggered. In that case only exit is triggered.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-evallineno">
<h3><code>evallineno</code> <a class="doc-anchor" href="#doc-lsp-option-evallineno">¶</a></h3>
<p>If set, line numbers of expressions evaluated using the builtin <code>eval</code> are tracked separately of the enclosing environment. This applies both to the parameter <code>LINENO</code> and the line number output by the prompt escape <code>%i</code>. If the option is set, the prompt escape <code>%N</code> will output the string "tt((eval))" instead of the script or function name as an indication. (The two prompt escapes are typically used in the parameter <code>PS4</code> to be output when the option <code>XTRACE</code> is set.) If <code>EVAL_LINENO</code> is unset, the line number of the surrounding script or function is retained during the evaluation.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-exec">
<h3><code>exec</code> <a class="doc-anchor" href="#doc-lsp-option-exec">¶</a></h3>
<p>The following command together with any arguments is run in place of the current process, rather than as a sub-process. The shell does not fork and is replaced. The shell does not invoke <code>TRAPEXIT</code>, nor does it source <code>zlogout</code> files. The options are provided for compatibility with other shells.</p>
<p>The <code>-c</code> option clears the environment.</p>
<p>The <code>-l</code> option is equivalent to the <code>-</code> precommand modifier, to treat the replacement command as a login shell; the command is executed with a <code>-</code> prepended to its <code>argv[0]</code> string. This flag has no effect if used together with the <code>-a</code> option.</p>
<p>The <code>-a</code> option is used to specify explicitly the <code>argv[0]</code> string (the name of the command as seen by the process itself) to be used by the replacement command and is directly equivalent to setting a value for the <code>ARGV0</code> environment variable.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-extendedglob">
<h3><code>extendedglob</code> <a class="doc-anchor" href="#doc-lsp-option-extendedglob">¶</a></h3>
<p>Treat the "#", "~" and "^" characters as part of patterns for filename generation, etc. (An initial unquoted "~" always produces named directory expansion.)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-extendedhistory">
<h3><code>extendedhistory</code> <a class="doc-anchor" href="#doc-lsp-option-extendedhistory">¶</a></h3>
<p>Save each command's beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is:</p>
<p><code></code>: <code>_<beginning time>_</code>:<code>_<elapsed seconds>_</code>;"<em><command></em>".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-flowcontrol">
<h3><code>flowcontrol</code> <a class="doc-anchor" href="#doc-lsp-option-flowcontrol">¶</a></h3>
<p>If this option is unset, output flow control via start/stop characters (usually assigned to ^S/^Q) is disabled in the shell's editor.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-forcefloat">
<h3><code>forcefloat</code> <a class="doc-anchor" href="#doc-lsp-option-forcefloat">¶</a></h3>
<p>Constants in arithmetic evaluation will be treated as floating point even without the use of a decimal point; the values of integer variables will be converted to floating point when used in arithmetic expressions. Integers in any base will be converted.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-functionargzero">
<h3><code>functionargzero</code> <a class="doc-anchor" href="#doc-lsp-option-functionargzero">¶</a></h3>
<p>When executing a shell function or sourcing a script, set <code>$0</code> temporarily to the name of the function/script. Note that toggling <code>FUNCTION_ARGZERO</code> from on to off (or off to on) does not change the current value of <code>$0</code>. Only the state upon entry to the function or script has an effect. Compare <code>POSIX_ARGZERO</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-glob">
<h3><code>glob</code> <a class="doc-anchor" href="#doc-lsp-option-glob">¶</a></h3>
<p>This is used by the <code>_expand</code> completer. If it is set to "true" (the default), globbing will be attempted on the words resulting from a previous substitution (see the <code>substitute</code> style) or else the original string from the line.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-globalexport">
<h3><code>globalexport</code> <a class="doc-anchor" href="#doc-lsp-option-globalexport">¶</a></h3>
<p>If this option is set, passing the <code>-x</code> flag to the builtins <code>declare</code>, <code>float</code>, <code>integer</code>, <code>readonly</code> and <code>typeset</code> (but not <code>local</code>) will also set the <code>-g</code> flag; hence parameters exported to the environment will not be made local to the enclosing function, unless they were already or the flag <code>+g</code> is given explicitly. If the option is unset, exported parameters will be made local in just the same way as any other parameter.</p>
<p>This option is set by default for backward compatibility; it is not recommended that its behaviour be relied upon. Note that the builtin <code>export</code> always sets both the <code>-x</code> and <code>-g</code> flags, and hence its effect extends beyond the scope of the enclosing function; this is the most portable way to achieve this behaviour.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-globalrcs">
<h3><code>globalrcs</code> <a class="doc-anchor" href="#doc-lsp-option-globalrcs">¶</a></h3>
<p>If this option is unset, the startup files tt(zprofile()), tt(zshrc()), tt(zlogin()) and tt(zlogout()) will not be run. It can be disabled and re-enabled at any time, including inside local startup files (<code>.zshrc</code>, etc.).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-globassign">
<h3><code>globassign</code> <a class="doc-anchor" href="#doc-lsp-option-globassign">¶</a></h3>
<p>If this option is set, filename generation (globbing) is performed on the right hand side of scalar parameter assignments of the form <code>_name_</code>=<code>_pattern_ (e.g. "foo=*"). If the result has more than one word the parameter will become an array with those words as arguments. This option is provided for backwards compatibility only: globbing is always performed on the right hand side of array assignments of the form </code>_name_tt(=()<em>value</em><code>")" (e.g. "tt(foo=(*))") and this form is recommended for clarity; with this option set, it is not possible to predict whether the result will be an array or a scalar.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-option-globcomplete">
<h3><code>globcomplete</code> <a class="doc-anchor" href="#doc-lsp-option-globcomplete">¶</a></h3>
<p>When the current word has a glob pattern, do not insert all the words resulting from the expansion but generate matches as for completion and cycle through them like <code>MENU_COMPLETE</code>. The matches are generated as if a "*" was added to the end of the word, or inserted at the cursor when <code>COMPLETE_IN_WORD</code> is set. This actually uses pattern matching, not globbing, so it works not only for files but for any completion, such as options, user names, etc.</p>
<p>Note that when the pattern matcher is used, matching control (for example, case-insensitive or anchored matching) cannot be used. This limitation only applies when the current word contains a pattern; simply turning on the <code>GLOB_COMPLETE</code> option does not have this effect.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-globdots">
<h3><code>globdots</code> <a class="doc-anchor" href="#doc-lsp-option-globdots">¶</a></h3>
<p>Do not require a leading "." in a filename to be matched explicitly.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-globstarshort">
<h3><code>globstarshort</code> <a class="doc-anchor" href="#doc-lsp-option-globstarshort">¶</a></h3>
<p>When this option is set and the default zsh-style globbing is in effect, the pattern "<strong>/*" can be abbreviated to "</strong>" and the pattern "<strong>*/*" can be abbreviated to <code></code></strong>*<code>. Hence "**.c" finds a file ending in </code>.c<code> in any subdirectory, and "***.c" does the same while also following symbolic links. A </code>/<code> immediately after the "**" or "***" forces the pattern to be treated as the unabbreviated form.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-option-globsubst">
<h3><code>globsubst</code> <a class="doc-anchor" href="#doc-lsp-option-globsubst">¶</a></h3>
<p>Treat any characters resulting from parameter expansion as being eligible for filename expansion and filename generation, and any characters resulting from command substitution as being eligible for filename generation. Braces (and commas in between) do not become eligible for expansion.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hashall">
<h3><code>hashall</code> <a class="doc-anchor" href="#doc-lsp-option-hashall">¶</a></h3>
<p><code>HASH_CMDS</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hashcmds">
<h3><code>hashcmds</code> <a class="doc-anchor" href="#doc-lsp-option-hashcmds">¶</a></h3>
<p>Note the location of each command the first time it is executed. Subsequent invocations of the same command will use the saved location, avoiding a path search. If this option is unset, no path hashing is done at all. However, when <code>CORRECT</code> is set, commands whose names do not appear in the functions or aliases hash tables are hashed in order to avoid reporting them as spelling errors.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hashdirs">
<h3><code>hashdirs</code> <a class="doc-anchor" href="#doc-lsp-option-hashdirs">¶</a></h3>
<p>Whenever a command name is hashed, hash the directory containing it, as well as all directories that occur earlier in the path. Has no effect if neither <code>HASH_CMDS</code> nor <code>CORRECT</code> is set.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hashexecutablesonly">
<h3><code>hashexecutablesonly</code> <a class="doc-anchor" href="#doc-lsp-option-hashexecutablesonly">¶</a></h3>
<p>When hashing commands because of <code>HASH_CMDS</code>, check that the file to be hashed is actually an executable. This option is unset by default as if the path contains a large number of commands, or consists of many remote files, the additional tests can take a long time. Trial and error is needed to show if this option is beneficial.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hashlistall">
<h3><code>hashlistall</code> <a class="doc-anchor" href="#doc-lsp-option-hashlistall">¶</a></h3>
<p>Whenever a command completion or spelling correction is attempted, make sure the entire command path is hashed first. This makes the first completion slower but avoids false reports of spelling errors.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histallowclobber">
<h3><code>histallowclobber</code> <a class="doc-anchor" href="#doc-lsp-option-histallowclobber">¶</a></h3>
<p>Add "|" to output redirections in the history. This allows history references to clobber files even when <code>CLOBBER</code> is unset.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histappend">
<h3><code>histappend</code> <a class="doc-anchor" href="#doc-lsp-option-histappend">¶</a></h3>
<p><code>APPEND_HISTORY</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histbeep">
<h3><code>histbeep</code> <a class="doc-anchor" href="#doc-lsp-option-histbeep">¶</a></h3>
<p>Beep in ZLE when a widget attempts to access a history entry which isn't there.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histexpand">
<h3><code>histexpand</code> <a class="doc-anchor" href="#doc-lsp-option-histexpand">¶</a></h3>
<p><code>BANG_HIST</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histexpiredupsfirst">
<h3><code>histexpiredupsfirst</code> <a class="doc-anchor" href="#doc-lsp-option-histexpiredupsfirst">¶</a></h3>
<p>If the internal history needs to be trimmed to add the current command line, setting this option will cause the oldest history event that has a duplicate to be lost before losing a unique event from the list. You should be sure to set the value of <code>HISTSIZE</code> to a larger number than <code>SAVEHIST</code> in order to give you some room for the duplicated events, otherwise this option will behave just like <code>HIST_IGNORE_ALL_DUPS</code> once the history fills up with unique events.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histfcntllock">
<h3><code>histfcntllock</code> <a class="doc-anchor" href="#doc-lsp-option-histfcntllock">¶</a></h3>
<p>When writing out the history file, by default zsh uses ad-hoc file locking to avoid known problems with locking on some operating systems. With this option locking is done by means of the system's <code>fcntl</code> call, where this method is available. On recent operating systems this may provide better performance, in particular avoiding history corruption when files are stored on NFS.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histfindnodups">
<h3><code>histfindnodups</code> <a class="doc-anchor" href="#doc-lsp-option-histfindnodups">¶</a></h3>
<p>When searching for history entries in the line editor, do not display duplicates of a line previously found, even if the duplicates are not contiguous.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histignorealldups">
<h3><code>histignorealldups</code> <a class="doc-anchor" href="#doc-lsp-option-histignorealldups">¶</a></h3>
<p>If a new command line being added to the history list duplicates an older one, the older command is removed from the list (even if it is not the previous event).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histignoredups">
<h3><code>histignoredups</code> <a class="doc-anchor" href="#doc-lsp-option-histignoredups">¶</a></h3>
<p>Do not enter command lines into the history list if they are duplicates of the previous event.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histignorespace">
<h3><code>histignorespace</code> <a class="doc-anchor" href="#doc-lsp-option-histignorespace">¶</a></h3>
<p>Remove command lines from the history list when the first character on the line is a space, or when one of the expanded aliases contains a leading space. Only normal aliases (not global or suffix aliases) have this behaviour. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. If you want to make it vanish right away without entering another command, type a space and press return.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histlexwords">
<h3><code>histlexwords</code> <a class="doc-anchor" href="#doc-lsp-option-histlexwords">¶</a></h3>
<p>By default, shell history that is read in from files is split into words on all white space. This means that arguments with quoted whitespace are not correctly handled, with the consequence that references to words in history lines that have been read from a file may be inaccurate. When this option is set, words read in from a history file are divided up in a similar fashion to normal shell command line handling. Although this produces more accurately delimited words, if the size of the history file is large this can be slow. Trial and error is necessary to decide.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histnofunctions">
<h3><code>histnofunctions</code> <a class="doc-anchor" href="#doc-lsp-option-histnofunctions">¶</a></h3>
<p>Remove function definitions from the history list. Note that the function lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the definition.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histnostore">
<h3><code>histnostore</code> <a class="doc-anchor" href="#doc-lsp-option-histnostore">¶</a></h3>
<p>Remove the <code>history</code> (<code>fc -l</code>) command from the history list when invoked. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histreduceblanks">
<h3><code>histreduceblanks</code> <a class="doc-anchor" href="#doc-lsp-option-histreduceblanks">¶</a></h3>
<p>Remove superfluous blanks from each command line being added to the history list.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histsavebycopy">
<h3><code>histsavebycopy</code> <a class="doc-anchor" href="#doc-lsp-option-histsavebycopy">¶</a></h3>
<p>When the history file is re-written, we normally write out a copy of the file named <code>$HISTFILE.new</code> and then rename it over the old one. However, if this option is unset, we instead truncate the old history file and write out the new version in-place. If one of the history-appending options is enabled, this option only has an effect when the enlarged history file needs to be re-written to trim it down to size. Disable this only if you have special needs, as doing so makes it possible to lose history entries if zsh gets interrupted during the save.</p>
<p>When writing out a copy of the history file, zsh preserves the old file's permissions and group information, but will refuse to write out a new file if it would change the history file's owner.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histsavenodups">
<h3><code>histsavenodups</code> <a class="doc-anchor" href="#doc-lsp-option-histsavenodups">¶</a></h3>
<p>When writing out the history file, older commands that duplicate newer ones are omitted.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histsubstpattern">
<h3><code>histsubstpattern</code> <a class="doc-anchor" href="#doc-lsp-option-histsubstpattern">¶</a></h3>
<p>Substitutions using the <code>:s</code> and <code>:&</code> history modifiers are performed with pattern matching instead of string matching. This occurs wherever history modifiers are valid, including glob qualifiers and parameters. See subref(Modifiers)(zshexpn).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-histverify">
<h3><code>histverify</code> <a class="doc-anchor" href="#doc-lsp-option-histverify">¶</a></h3>
<p>Whenever the user enters a line with history expansion, don't execute the line directly; instead, perform history expansion and reload the line into the editing buffer.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-hup">
<h3><code>hup</code> <a class="doc-anchor" href="#doc-lsp-option-hup">¶</a></h3>
<p>Send the <code>HUP</code> signal to running jobs when the shell exits.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-ignorebraces">
<h3><code>ignorebraces</code> <a class="doc-anchor" href="#doc-lsp-option-ignorebraces">¶</a></h3>
<p>Do not perform brace expansion. For historical reasons this also includes the effect of the <code>IGNORE_CLOSE_BRACES</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-ignoreclosebraces">
<h3><code>ignoreclosebraces</code> <a class="doc-anchor" href="#doc-lsp-option-ignoreclosebraces">¶</a></h3>
<p>When neither this option nor <code>IGNORE_BRACES</code> is set, a sole close brace character "}" is syntactically significant at any point on a command line. This has the effect that no semicolon or newline is necessary before the brace terminating a function or current shell construct. When either option is set, a closing brace is syntactically significant only in command position. Unlike <code>IGNORE_BRACES</code>, this option does not disable brace expansion.</p>
<p>For example, with both options unset a function may be defined in the following fashion:</p>
<p>example(args+() { echo $# })</p>
<p>while if either option is set, this does not work and something equivalent to the following is required:</p>
<p>example(args+() { echo $#; })</p>
</article>
<article class="doc-entry" id="doc-lsp-option-ignoreeof">
<h3><code>ignoreeof</code> <a class="doc-anchor" href="#doc-lsp-option-ignoreeof">¶</a></h3>
<p>Do not exit on end-of-file. Require the use of <code>exit</code> or <code>logout</code> instead. However, ten consecutive EOFs will cause the shell to exit anyway, to avoid the shell hanging if its tty goes away.</p>
<p>Also, if this option is set and the Zsh Line Editor is used, widgets implemented by shell functions can be bound to EOF (normally Control-D) without printing the normal warning message. This works only for normal widgets, not for completion widgets.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-incappendhistory">
<h3><code>incappendhistory</code> <a class="doc-anchor" href="#doc-lsp-option-incappendhistory">¶</a></h3>
<p>This option works like <code>APPEND_HISTORY</code> except that new history lines are added to the <code>$HISTFILE</code> incrementally (as soon as they are entered), rather than waiting until the shell exits. The file will still be periodically re-written to trim it when the number of lines grows 20% beyond the value specified by <code>$SAVEHIST</code> (see also the <code>HIST_SAVE_BY_COPY</code> option).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-incappendhistorytime">
<h3><code>incappendhistorytime</code> <a class="doc-anchor" href="#doc-lsp-option-incappendhistorytime">¶</a></h3>
<p>This option is a variant of <code>INC_APPEND_HISTORY</code> in which, where possible, the history entry is written out to the file after the command is finished, so that the time taken by the command is recorded correctly in the history file in <code>EXTENDED_HISTORY</code> format. This means that the history entry will not be available immediately from other instances of the shell that are using the same history file.</p>
<p>This option is only useful if <code>INC_APPEND_HISTORY</code> and <code>SHARE_HISTORY</code> are turned off. The three options should be considered mutually exclusive.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-interactive">
<h3><code>interactive</code> <a class="doc-anchor" href="#doc-lsp-option-interactive">¶</a></h3>
<p>This is an interactive shell. This option is set upon initialisation if the standard input is a tty and commands are being read from standard input. (See the discussion of <code>SHIN_STDIN</code>.) This heuristic may be overridden by specifying a state for this option on the command line. The value of this option can only be changed via flags supplied at invocation of the shell. It cannot be changed once zsh is running.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-interactivecomments">
<h3><code>interactivecomments</code> <a class="doc-anchor" href="#doc-lsp-option-interactivecomments">¶</a></h3>
<p>Allow comments even in interactive shells.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-ksharrays">
<h3><code>ksharrays</code> <a class="doc-anchor" href="#doc-lsp-option-ksharrays">¶</a></h3>
<p>Emulate <strong>ksh</strong> array handling as closely as possible. If this option is set, array elements are numbered from zero, an array parameter without subscript refers to the first element instead of the whole array, and braces are required to delimit a subscript ("${path[2]}" rather than just "$path[2]") or to apply modifiers to any parameter ("${PWD:h}" rather than "$PWD:h").</p>
</article>
<article class="doc-entry" id="doc-lsp-option-kshautoload">
<h3><code>kshautoload</code> <a class="doc-anchor" href="#doc-lsp-option-kshautoload">¶</a></h3>
<p>Emulate <strong>ksh</strong> function autoloading. This means that when a function is autoloaded, the corresponding file is merely executed, and must define the function itself. (By default, the function is defined to the contents of the file. However, the most common <strong>ksh</strong>-style case - of the file containing only a simple definition of the function - is always handled in the <strong>ksh</strong>-compatible manner.)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-kshglob">
<h3><code>kshglob</code> <a class="doc-anchor" href="#doc-lsp-option-kshglob">¶</a></h3>
<p>In pattern matching, the interpretation of parentheses is affected by a preceding "@", "*", "+", "?" or "!". See <em>Filename Generation</em> (zshexpn).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-kshoptionprint">
<h3><code>kshoptionprint</code> <a class="doc-anchor" href="#doc-lsp-option-kshoptionprint">¶</a></h3>
<p>Alters the way options settings are printed: instead of separate lists of set and unset options, all options are shown, marked "on" if they are in the non-default state, "off" otherwise.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-kshtypeset">
<h3><code>kshtypeset</code> <a class="doc-anchor" href="#doc-lsp-option-kshtypeset">¶</a></h3>
<p>This option is now obsolete: a better approximation to the behaviour of other shells is obtained with the reserved word interface to <code>declare</code>, <code>export</code>, <code>float</code>, <code>integer</code>, <code>local</code>, <code>readonly</code> and <code>typeset</code>. Note that the option is only applied when the reserved word interface is <em>not</em> in use.</p>
<p>Alters the way arguments to the <code>typeset</code> family of commands, including <code>declare</code>, <code>export</code>, <code>float</code>, <code>integer</code>, <code>local</code> and <code>readonly</code>, are processed. Without this option, zsh will perform normal word splitting after command and parameter expansion in arguments of an assignment; with it, word splitting does not take place in those cases.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-kshzerosubscript">
<h3><code>kshzerosubscript</code> <a class="doc-anchor" href="#doc-lsp-option-kshzerosubscript">¶</a></h3>
<p>Treat use of a subscript of value zero in array or string expressions as a reference to the first element, i.e. the element that usually has the subscript 1. Ignored if <code>KSH_ARRAYS</code> is also set.</p>
<p>If neither this option nor <code>KSH_ARRAYS</code> is set, accesses to an element of an array or string with subscript zero return an empty element or string, while attempts to set element zero of an array or string are treated as an error. However, attempts to set an otherwise valid subscript range that includes zero will succeed. For example, if <code>KSH_ZERO_SUBSCRIPT</code> is not set,</p>
<p>example(array[0]=(element))</p>
<p>is an error, while</p>
<p>example(array[0,1]=(element))</p>
<p>is not and will replace the first element of the array.</p>
<p>This option is for compatibility with older versions of the shell and is not recommended in new code.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-listambiguous">
<h3><code>listambiguous</code> <a class="doc-anchor" href="#doc-lsp-option-listambiguous">¶</a></h3>
<p>This option works when <code>AUTO_LIST</code> or <code>BASH_AUTO_LIST</code> is also set. If there is an unambiguous prefix to insert on the command line, that is done without a completion list being displayed; in other words, auto-listing behaviour only takes place when nothing would be inserted. In the case of <code>BASH_AUTO_LIST</code>, this means that the list will be delayed to the third call of the function.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-listbeep">
<h3><code>listbeep</code> <a class="doc-anchor" href="#doc-lsp-option-listbeep">¶</a></h3>
<p>Beep on an ambiguous completion. More accurately, this forces the completion widgets to return status 1 on an ambiguous completion, which causes the shell to beep if the option <code>BEEP</code> is also set; this may be modified if completion is called from a user-defined widget.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-listpacked">
<h3><code>listpacked</code> <a class="doc-anchor" href="#doc-lsp-option-listpacked">¶</a></h3>
<p>Try to make the completion list smaller (occupying less lines) by printing the matches in columns with different widths.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-listrowsfirst">
<h3><code>listrowsfirst</code> <a class="doc-anchor" href="#doc-lsp-option-listrowsfirst">¶</a></h3>
<p>Lay out the matches in completion lists sorted horizontally, that is, the second match is to the right of the first one, not under it as usual.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-listtypes">
<h3><code>listtypes</code> <a class="doc-anchor" href="#doc-lsp-option-listtypes">¶</a></h3>
<p>When listing files that are possible completions, show the type of each file with a trailing identifying mark.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-localloops">
<h3><code>localloops</code> <a class="doc-anchor" href="#doc-lsp-option-localloops">¶</a></h3>
<p>When this option is not set, the effect of <code>break</code> and <code>continue</code> commands may propagate outside function scope, affecting loops in calling functions. When the option is set in a calling function, a <code>break</code> or a <code>continue</code> that is not caught within a called function (regardless of the setting of the option within that function) produces a warning and the effect is cancelled.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-localoptions">
<h3><code>localoptions</code> <a class="doc-anchor" href="#doc-lsp-option-localoptions">¶</a></h3>
<p>If this option is set at the point of return from a shell function, most options (including this one) which were in force upon entry to the function are restored; the <code>PRIVILEGED</code> option is not restored. Otherwise, only this option, and the <code>LOCAL_LOOPS</code>, <code>XTRACE</code> and <code>PRINT_EXIT_VALUE</code> options are restored. Hence if this is explicitly unset by a shell function the other options in force at the point of return will remain so. A shell function can also guarantee itself a known shell configuration with a formulation like "emulate -L zsh"; the <code>-L</code> activates <code>LOCAL_OPTIONS</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-localpatterns">
<h3><code>localpatterns</code> <a class="doc-anchor" href="#doc-lsp-option-localpatterns">¶</a></h3>
<p>If this option is set at the point of return from a shell function, the state of pattern disables, as set with the builtin command "disable -p", is restored to what it was when the function was entered. The behaviour of this option is similar to the effect of <code>LOCAL_OPTIONS</code> on options; hence "emulate -L sh" (or indeed any other emulation with the <code>-L</code> option) activates <code>LOCAL_PATTERNS</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-localtraps">
<h3><code>localtraps</code> <a class="doc-anchor" href="#doc-lsp-option-localtraps">¶</a></h3>
<p>If this option is set when a signal trap is set inside a function, then the previous status of the trap for that signal will be restored when the function exits. Note that this option must be set <em>prior</em> to altering the trap behaviour in a function; unlike <code>LOCAL_OPTIONS</code>, the value on exit from the function is irrelevant. However, it does not need to be set before any global trap for that to be correctly restored by a function. For example,</p>
<p>example(unsetopt localtraps trap - INT fn+() { setopt localtraps; trap '' INT; sleep 3; })</p>
<p>will restore normal handling of <code>SIGINT</code> after the function exits.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-log">
<h3><code>log</code> <a class="doc-anchor" href="#doc-lsp-option-log">¶</a></h3>
<p>List all users currently logged in who are affected by the current setting of the <code>watch</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-login">
<h3><code>login</code> <a class="doc-anchor" href="#doc-lsp-option-login">¶</a></h3>
<p>This is a login shell. If this option is not explicitly set, the shell becomes a login shell if the first character of the <code>argv[0]</code> passed to the shell is a "-".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-longlistjobs">
<h3><code>longlistjobs</code> <a class="doc-anchor" href="#doc-lsp-option-longlistjobs">¶</a></h3>
<p>Print job notifications in the long format by default.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-magicequalsubst">
<h3><code>magicequalsubst</code> <a class="doc-anchor" href="#doc-lsp-option-magicequalsubst">¶</a></h3>
<p>All unquoted arguments of the form <code>_anything_</code>="<em>expression</em>" appearing after the command name have filename expansion (that is, where <em>expression</em> has a leading "~" or "=") performed on <em>expression</em> as if it were a parameter assignment. The argument is not otherwise treated specially; it is passed to the command as a single argument, and not used as an actual parameter assignment. For example, in <code>echo foo=~/bar:~/rod</code>, both occurrences of <code>~</code> would be replaced. Note that this happens anyway with <code>typeset</code> and similar statements.</p>
<p>This option respects the setting of the <code>KSH_TYPESET</code> option. In other words, if both options are in effect, arguments looking like assignments will not undergo word splitting.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-mailwarn">
<h3><code>mailwarn</code> <a class="doc-anchor" href="#doc-lsp-option-mailwarn">¶</a></h3>
<p><code>MAIL_WARNING</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-mailwarning">
<h3><code>mailwarning</code> <a class="doc-anchor" href="#doc-lsp-option-mailwarning">¶</a></h3>
<p>Print a warning message if a mail file has been accessed since the shell last checked.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-markdirs">
<h3><code>markdirs</code> <a class="doc-anchor" href="#doc-lsp-option-markdirs">¶</a></h3>
<p>Append a trailing "/" to all directory names resulting from filename generation (globbing).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-menucomplete">
<h3><code>menucomplete</code> <a class="doc-anchor" href="#doc-lsp-option-menucomplete">¶</a></h3>
<p>On an ambiguous completion, instead of listing possibilities or beeping, insert the first match immediately. Then when completion is requested again, remove the first match and insert the second match, etc. When there are no more matches, go back to the first one again. <code>reverse-menu-complete</code> may be used to loop through the list in the other direction. This option overrides <code>AUTO_MENU</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-monitor">
<h3><code>monitor</code> <a class="doc-anchor" href="#doc-lsp-option-monitor">¶</a></h3>
<p>Allow job control. Set by default in interactive shells.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-multibyte">
<h3><code>multibyte</code> <a class="doc-anchor" href="#doc-lsp-option-multibyte">¶</a></h3>
<p>Respect multibyte characters when found in strings. When this option is set, strings are examined using the system library to determine how many bytes form a character, depending on the current locale. This affects the way characters are counted in pattern matching, parameter values and various delimiters.</p>
<p>The option is on by default if the shell was compiled with <code>MULTIBYTE_SUPPORT</code>; otherwise it is off by default and has no effect if turned on.</p>
<p>If the option is off a single byte is always treated as a single character. This setting is designed purely for examining strings known to contain raw bytes or other values that may not be characters in the current locale. It is not necessary to unset the option merely because the character set for the current locale does not contain multibyte characters.</p>
<p>The option does not affect the shell's editor, which always uses the locale to determine multibyte characters. This is because the character set displayed by the terminal emulator is independent of shell settings.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-multifuncdef">
<h3><code>multifuncdef</code> <a class="doc-anchor" href="#doc-lsp-option-multifuncdef">¶</a></h3>
<p>Allow definitions of multiple functions at once in the form <code></code>fn1 fn2"_..._tt(())"; if the option is not set, this causes a parse error. Definition of multiple functions with the <code>function</code> keyword is always allowed. Multiple function definitions are not often used and can cause obscure errors.</p>
<p>Note that no error is raised if multiple functions are defined as a result of a set of names that were originally read as a single word on the command line, for example "TRAP{INT,QUIT}". Although there are no plans to change this behaviour at present, it is not guaranteed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-multios">
<h3><code>multios</code> <a class="doc-anchor" href="#doc-lsp-option-multios">¶</a></h3>
<p>Perform implicit <strong>tee</strong>s or <strong>cat</strong>s when multiple redirections are attempted (see <em>Redirection</em> (zshmisc)).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-nomatch">
<h3><code>nomatch</code> <a class="doc-anchor" href="#doc-lsp-option-nomatch">¶</a></h3>
<p>If a pattern for filename generation has no matches, print an error, instead of leaving it unchanged in the argument list. This also applies to file expansion of an initial "~" or "=".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-notify">
<h3><code>notify</code> <a class="doc-anchor" href="#doc-lsp-option-notify">¶</a></h3>
<p>Report the status of background jobs immediately, rather than waiting until just before printing a prompt.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-nullglob">
<h3><code>nullglob</code> <a class="doc-anchor" href="#doc-lsp-option-nullglob">¶</a></h3>
<p>If a pattern for filename generation has no matches, delete the pattern from the argument list instead of reporting an error. Overrides <code>NOMATCH</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-numericglobsort">
<h3><code>numericglobsort</code> <a class="doc-anchor" href="#doc-lsp-option-numericglobsort">¶</a></h3>
<p>If numeric filenames are matched by a filename generation pattern, sort the filenames numerically rather than lexicographically.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-octalzeroes">
<h3><code>octalzeroes</code> <a class="doc-anchor" href="#doc-lsp-option-octalzeroes">¶</a></h3>
<p>Interpret any integer constant beginning with a 0 as octal, per IEEE Std 1003.2-1992 (ISO 9945-2:1993). This is not enabled by default as it causes problems with parsing of, for example, date and time strings with leading zeroes.</p>
<p>Sequences of digits indicating a numeric base such as the "08" component in "08#77" are always interpreted as decimal, regardless of leading zeroes.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-onecmd">
<h3><code>onecmd</code> <a class="doc-anchor" href="#doc-lsp-option-onecmd">¶</a></h3>
<p><code>SINGLE_COMMAND</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-overstrike">
<h3><code>overstrike</code> <a class="doc-anchor" href="#doc-lsp-option-overstrike">¶</a></h3>
<p>Start up the line editor in overstrike mode.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pathdirs">
<h3><code>pathdirs</code> <a class="doc-anchor" href="#doc-lsp-option-pathdirs">¶</a></h3>
<p>Perform a path search even on command names with slashes in them. Thus if "/usr/local/bin" is in the user's path, and he or she types "X11/xinit", the command "/usr/local/bin/X11/xinit" will be executed (assuming it exists). Commands explicitly beginning with "/", "./" or "../" are not subject to the path search. This also applies to the "." and <code>source</code> builtins.</p>
<p>Note that subdirectories of the current directory are always searched for executables specified in this form. This takes place before any search indicated by this option, and regardless of whether "." or the current directory appear in the command search path.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pathscript">
<h3><code>pathscript</code> <a class="doc-anchor" href="#doc-lsp-option-pathscript">¶</a></h3>
<p>If this option is not set, a script passed as the first non-option argument to the shell must contain the name of the file to open. If this option is set, and the script does not specify a directory path, the script is looked for first in the current directory, then in the command path. See <em>Invocation</em> (zsh).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-physical">
<h3><code>physical</code> <a class="doc-anchor" href="#doc-lsp-option-physical">¶</a></h3>
<p><code>CHASE_LINKS</code> (ksh and bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pipefail">
<h3><code>pipefail</code> <a class="doc-anchor" href="#doc-lsp-option-pipefail">¶</a></h3>
<p>By default, when a pipeline exits the exit status recorded by the shell and returned by the shell variable <code>$?</code> reflects that of the rightmost element of a pipeline. If this option is set, the exit status instead reflects the status of the rightmost element of the pipeline that was non-zero, or zero if all elements exited with zero status.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixaliases">
<h3><code>posixaliases</code> <a class="doc-anchor" href="#doc-lsp-option-posixaliases">¶</a></h3>
<p>When this option is set, reserved words are not candidates for alias expansion: it is still possible to declare any of them as an alias, but the alias will never be expanded. Reserved words are described in <em>Reserved Words</em> (zshmisc).</p>
<p>Alias expansion takes place while text is being read; hence when this option is set it does not take effect until the end of any function or other piece of shell code parsed as one unit. Note this may cause differences from other shells even when the option is in effect. For example, when running a command with "zsh -c", or even "zsh -o posixaliases -c", the entire command argument is parsed as one unit, so aliases defined within the argument are not available even in later lines. If in doubt, avoid use of aliases in non-interactive code.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixargzero">
<h3><code>posixargzero</code> <a class="doc-anchor" href="#doc-lsp-option-posixargzero">¶</a></h3>
<p>This option may be used to temporarily disable <code>FUNCTION_ARGZERO</code> and thereby restore the value of <code>$0</code> to the name used to invoke the shell (or as set by the <code>-c</code> command line option). For compatibility with previous versions of the shell, emulations use <code>NO_FUNCTION_ARGZERO</code> instead of <code>POSIX_ARGZERO</code>, which may result in unexpected scoping of <code>$0</code> if the emulation mode is changed inside a function or script. To avoid this, explicitly enable <code>POSIX_ARGZERO</code> in the <code>emulate</code> command:</p>
<p> emulate sh -o POSIX_ARGZERO</p>
<p>Note that <code>NO_POSIX_ARGZERO</code> has no effect unless <code>FUNCTION_ARGZERO</code> was already enabled upon entry to the function or script.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixbuiltins">
<h3><code>posixbuiltins</code> <a class="doc-anchor" href="#doc-lsp-option-posixbuiltins">¶</a></h3>
<p>When this option is set the <code>command</code> builtin can be used to execute shell builtin commands. Parameter assignments specified before shell functions and special builtins are kept after the command completes unless the special builtin is prefixed with the <code>command</code> builtin. Special builtins are <code>.</code>, <code>:</code>, <code>break</code>, <code>continue</code>, <code>declare</code>, <code>eval</code>, <code>exit</code>, <code>export</code>, <code>integer</code>, <code>local</code>, <code>readonly</code>, <code>return</code>, <code>set</code>, <code>shift</code>, <code>source</code>, <code>times</code>, <code>trap</code> and <code>unset</code>.</p>
<p>In addition, various error conditions associated with the above builtins or <code>exec</code> cause a non-interactive shell to exit and an interactive shell to return to its top-level processing.</p>
<p>Furthermore, functions and shell builtins are not executed after an <code>exec</code> prefix; the command to be executed must be an external command found in the path.</p>
<p>Furthermore, the <code>getopts</code> builtin behaves in a POSIX-compatible fashion in that the associated variable <code>OPTIND</code> is not made local to functions, and its value is calculated differently to match other shells.</p>
<p>Moreover, the warning and special exit code from <code>[[ -o </code>_non_existent_option_<code> ]]</code> are suppressed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixcd">
<h3><code>posixcd</code> <a class="doc-anchor" href="#doc-lsp-option-posixcd">¶</a></h3>
<p>Modifies the behaviour of <code>cd</code>, <code>chdir</code> and <code>pushd</code> commands to make them more compatible with the POSIX standard. The behaviour with the option unset is described in the documentation for the <code>cd</code> builtin in nmref(Shell Builtin Commands)(zshbuiltins). If the option is set, the shell does not test for directories beneath the local directory (".") until after all directories in <code>cdpath</code> have been tested, and the <code>cd</code> and <code>chdir</code> commands do not recognise arguments of the form <code>{</code>+<code>|</code>-"}<em>n</em>" as directory stack entries.</p>
<p>Also, if the option is set, the conditions under which the shell prints the new directory after changing to it are modified. It is no longer restricted to interactive shells (although printing of the directory stack with <code>pushd</code> is still limited to interactive shells); and any use of a component of <code>CDPATH</code>, including a "." but excluding an empty component that is otherwise treated as ".", causes the directory to be printed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixidentifiers">
<h3><code>posixidentifiers</code> <a class="doc-anchor" href="#doc-lsp-option-posixidentifiers">¶</a></h3>
<p>When this option is set, only the ASCII characters <code>a</code> to <code>z</code>, <code>A</code> to <code>Z</code>, <code>0</code> to <code>9</code> and <code>_</code> may be used in identifiers (names of shell parameters and modules).</p>
<p>In addition, setting this option limits the effect of parameter substitution with no braces, so that the expression <code>$#</code> is treated as the parameter <code>$#</code> even if followed by a valid parameter name. When it is unset, zsh allows expressions of the form <code>$#</code><em>name</em> to refer to the length of <code>$</code><em>name</em>, even for special variables, for example in expressions such as <code>$#-</code> and <code>$#*</code>.</p>
<p>Another difference is that with the option set assignment to an unset variable in arithmetic context causes the variable to be created as a scalar rather than a numeric type. So after <code>tt(unset t; (( t = 3 )))', without </code>POSIX_IDENTIFIERS<code> set </code>t<code> has integer type, while with it set it has scalar type.</code></p>
<p>When the option is unset and multibyte character support is enabled (i.e. it is compiled in and the option <code>MULTIBYTE</code> is set), then additionally any alphanumeric characters in the local character set may be used in identifiers. Note that scripts and functions written with this feature are not portable, and also that both options must be set before the script or function is parsed; setting them during execution is not sufficient as the syntax <em>variable</em><code>=</code><em>value</em> has already been parsed as a command rather than an assignment.</p>
<p>If multibyte character support is not compiled into the shell this option is ignored; all octets with the top bit set may be used in identifiers. This is non-standard but is the traditional zsh behaviour.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixjobs">
<h3><code>posixjobs</code> <a class="doc-anchor" href="#doc-lsp-option-posixjobs">¶</a></h3>
<p>This option makes job control more compliant with the POSIX standard.</p>
<p>When the option is not set, the <code>MONITOR</code> option is unset on entry to subshells, so that job control is no longer active. When the option is set, the <code>MONITOR</code> option and job control remain active in the subshell, but note that the subshell has no access to jobs in the parent shell.</p>
<p>When the option is not set, jobs put in the background or foreground with <code>bg</code> or <code>fg</code> are displayed with the same information that would be reported by <code>jobs</code>. When the option is set, only the text is printed. The output from <code>jobs</code> itself is not affected by the option.</p>
<p>When the option is not set, job information from the parent shell is saved for output within a subshell (for example, within a pipeline). When the option is set, the output of <code>jobs</code> is empty until a job is started within the subshell.</p>
<p>In previous versions of the shell, it was necessary to enable <code>POSIX_JOBS</code> in order for the builtin command <code>wait</code> to return the status of background jobs that had already exited. This is no longer the case.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixstrings">
<h3><code>posixstrings</code> <a class="doc-anchor" href="#doc-lsp-option-posixstrings">¶</a></h3>
<p>This option affects processing of quoted strings. Currently it only affects the behaviour of null characters, i.e. character 0 in the portable character set corresponding to US ASCII.</p>
<p>When this option is not set, null characters embedded within strings of the form "$"<code>_..._</code>'<code> are treated as ordinary characters. The entire string is maintained within the shell and output to files where necessary, although owing to restrictions of the library interface the string is truncated at the null character in file names, environment variables, or in arguments to external programs.</code></p>
<p>When this option is set, the "$"<code>_..._</code>'<code> expression is truncated at the null character. Note that remaining parts of the same string beyond the termination of the quotes are not truncated.</code></p>
<p>For example, the command line argument "a$"b\0c'd<code> is treated with the option off as the characters </code>a<code>, </code>b<code>, null, </code>c<code>, </code>d<code>, and with the option on as the characters </code>a<code>, </code>b<code>, </code>d<code>.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-option-posixtraps">
<h3><code>posixtraps</code> <a class="doc-anchor" href="#doc-lsp-option-posixtraps">¶</a></h3>
<p>When this option is set, the usual zsh behaviour of executing traps for <code>EXIT</code> on exit from shell functions is suppressed. In that case, manipulating <code>EXIT</code> traps always alters the global trap for exiting the shell; the <code>LOCAL_TRAPS</code> option is ignored for the <code>EXIT</code> trap.</p>
<p>Also, a <code>return</code> statement executed in a trap with no argument passes back from the function the value from the surrounding context, not from code executed within the trap.</p>
<p>Furthermore, if a trap is set to be ignored, this state persists when a subshell is entered. Without the option, the trap would be reset to its default state at this point.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-printeightbit">
<h3><code>printeightbit</code> <a class="doc-anchor" href="#doc-lsp-option-printeightbit">¶</a></h3>
<p>Print eight bit characters literally in completion lists, etc. This option is not necessary if your system correctly returns the printability of eight bit characters (see manref(ctype)(3)).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-printexitvalue">
<h3><code>printexitvalue</code> <a class="doc-anchor" href="#doc-lsp-option-printexitvalue">¶</a></h3>
<p>Print the exit value of programs with non-zero exit status. This is only available at the command line in interactive shells.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-privileged">
<h3><code>privileged</code> <a class="doc-anchor" href="#doc-lsp-option-privileged">¶</a></h3>
<p>Turn on privileged mode. Typically this is used when script is to be run with elevated privileges. This should be done as follows directly with the <code>-p</code> option to zsh so that it takes effect during startup.</p>
<p> #!/bin/zsh -p</p>
<p>The option is enabled automatically on startup if the effective user (group) ID is not equal to the real user (group) ID. In this case, turning the option off causes the effective user and group IDs to be set to the real user and group IDs. Be aware that if that fails the shell may be running with different IDs than was intended so a script should check for failure and act accordingly, for example:</p>
<p> unsetopt privileged || exit</p>
<p>The <code>PRIVILEGED</code> option disables sourcing user startup files. If zsh is invoked as "sh" or "ksh" with this option set, <code>/etc/suid_profile</code> is sourced (after <code>/etc/profile</code> on interactive shells). Sourcing <code>~/.profile</code> is disabled and the contents of the <code>ENV</code> variable is ignored. This option cannot be changed using the <code>-m</code> option of <code>setopt</code> and <code>unsetopt</code>, and changing it inside a function always changes it globally regardless of the <code>LOCAL_OPTIONS</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptbang">
<h3><code>promptbang</code> <a class="doc-anchor" href="#doc-lsp-option-promptbang">¶</a></h3>
<p>If set, "!" is treated specially in prompt expansion. See <em>Expansion of Prompt Sequences</em> (zshmisc).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptcr">
<h3><code>promptcr</code> <a class="doc-anchor" href="#doc-lsp-option-promptcr">¶</a></h3>
<p>Print a carriage return just before printing a prompt in the line editor. This is on by default as multi-line editing is only possible if the editor knows where the start of the line appears.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptpercent">
<h3><code>promptpercent</code> <a class="doc-anchor" href="#doc-lsp-option-promptpercent">¶</a></h3>
<p>If set, "%" is treated specially in prompt expansion. See <em>Expansion of Prompt Sequences</em> (zshmisc).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptsp">
<h3><code>promptsp</code> <a class="doc-anchor" href="#doc-lsp-option-promptsp">¶</a></h3>
<p>Attempt to preserve a partial line (i.e. a line that did not end with a newline) that would otherwise be covered up by the command prompt due to the <code>PROMPT_CR</code> option. This works by outputting some cursor-control characters, including a series of spaces, that should make the terminal wrap to the next line when a partial line is present (note that this is only successful if your terminal has automatic margins, which is typical).</p>
<p>When a partial line is preserved, by default you will see an inverse+bold character at the end of the partial line: a "%" for a normal user or a "#" for root. If set, the shell parameter <code>PROMPT_EOL_MARK</code> can be used to customize how the end of partial lines are shown.</p>
<p>NOTE: if the <code>PROMPT_CR</code> option is not set, enabling this option will have no effect. This option is on by default.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptsubst">
<h3><code>promptsubst</code> <a class="doc-anchor" href="#doc-lsp-option-promptsubst">¶</a></h3>
<p>If set, <em>parameter expansion</em>, <em>command substitution</em> and <em>arithmetic expansion</em> are performed in prompts. Substitutions within prompts do not affect the command status.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-promptvars">
<h3><code>promptvars</code> <a class="doc-anchor" href="#doc-lsp-option-promptvars">¶</a></h3>
<p><code>PROMPT_SUBST</code> (bash compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pushdignoredups">
<h3><code>pushdignoredups</code> <a class="doc-anchor" href="#doc-lsp-option-pushdignoredups">¶</a></h3>
<p>Don't push multiple copies of the same directory onto the directory stack.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pushdminus">
<h3><code>pushdminus</code> <a class="doc-anchor" href="#doc-lsp-option-pushdminus">¶</a></h3>
<p>Exchanges the meanings of "+" and "-" when used with a number to specify a directory in the stack.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pushdsilent">
<h3><code>pushdsilent</code> <a class="doc-anchor" href="#doc-lsp-option-pushdsilent">¶</a></h3>
<p>Do not print the directory stack after <code>pushd</code> or <code>popd</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-pushdtohome">
<h3><code>pushdtohome</code> <a class="doc-anchor" href="#doc-lsp-option-pushdtohome">¶</a></h3>
<p>Have <code>pushd</code> with no arguments act like "pushd $HOME".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rcexpandparam">
<h3><code>rcexpandparam</code> <a class="doc-anchor" href="#doc-lsp-option-rcexpandparam">¶</a></h3>
<p>Array expansions of the form <code>_foo_</code>${<code>_xx_</code>}"<em>bar</em>", where the parameter <em>xx</em> is set to tt(()<em>a b c</em><code></code>), are substituted with "<em>fooabar foobbar foocbar</em>" instead of the default "<em>fooa b cbar</em>". Note that an empty array will therefore cause all arguments to be removed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rcquotes">
<h3><code>rcquotes</code> <a class="doc-anchor" href="#doc-lsp-option-rcquotes">¶</a></h3>
<p>Allow the character sequence <code></code>''<code>' to signify a single quote within singly quoted strings. Note this does not apply in quoted strings using the format "$"</code><em>...</em><code>'</code>, where a backslashed single quote can be used.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rcs">
<h3><code>rcs</code> <a class="doc-anchor" href="#doc-lsp-option-rcs">¶</a></h3>
<p>After tt(zshenv()) is sourced on startup, source the <code>.zshenv</code>, tt(zprofile()), <code>.zprofile</code>, tt(zshrc()), <code>.zshrc</code>, tt(zlogin()), <code>.zlogin</code>, and <code>.zlogout</code> files, as described in <em>Startup/Shutdown Files</em> (zsh). If this option is unset, the tt(zshenv()) file is still sourced, but any of the others will not be; it can be set at any time to prevent the remaining startup files after the currently executing one from being sourced.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-recexact">
<h3><code>recexact</code> <a class="doc-anchor" href="#doc-lsp-option-recexact">¶</a></h3>
<p>If the string on the command line exactly matches one of the possible completions, it is accepted, even if there is another completion (i.e. that string with something else added) that also matches.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rematchpcre">
<h3><code>rematchpcre</code> <a class="doc-anchor" href="#doc-lsp-option-rematchpcre">¶</a></h3>
<p>If set, regular expression matching with the <code>=~</code> operator will use Perl-Compatible Regular Expressions from the PCRE library. (The <code>zsh/pcre</code> module must be available.) If not set, regular expressions will use the extended regexp syntax provided by the system libraries.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-restricted">
<h3><code>restricted</code> <a class="doc-anchor" href="#doc-lsp-option-restricted">¶</a></h3>
<p>Enables restricted mode. This option cannot be changed using <code>unsetopt</code>, and setting it inside a function always changes it globally regardless of the <code>LOCAL_OPTIONS</code> option. See the Restricted Shell section of <code>man zshall</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rmstarsilent">
<h3><code>rmstarsilent</code> <a class="doc-anchor" href="#doc-lsp-option-rmstarsilent">¶</a></h3>
<p>Do not query the user before executing "rm *" or "rm path/*".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-rmstarwait">
<h3><code>rmstarwait</code> <a class="doc-anchor" href="#doc-lsp-option-rmstarwait">¶</a></h3>
<p>If querying the user before executing "rm *" or "rm path/*", first wait ten seconds and ignore anything typed in that time. This avoids the problem of reflexively answering "yes" to the query when one didn't really mean it. The wait and query can always be avoided by expanding the "*" in ZLE (with tab).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-sharehistory">
<h3><code>sharehistory</code> <a class="doc-anchor" href="#doc-lsp-option-sharehistory">¶</a></h3>
<p>This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying <code>INC_APPEND_HISTORY</code>, which should be turned off if this option is in effect). The history lines are also output with timestamps ala <code>EXTENDED_HISTORY</code> (which makes it easier to find the spot where we left off reading the file after it gets re-written).</p>
<p>By default, history movement commands visit the imported lines as well as the local lines, but you can toggle this on and off with the set-local-history zle binding. It is also possible to create a zle widget that will make some commands ignore imported commands, and some include them.</p>
<p>If you find that you want more control over when commands get imported, you may wish to turn <code>SHARE_HISTORY</code> off, <code>INC_APPEND_HISTORY</code> or <code>INC_APPEND_HISTORY_TIME</code> (see above) on, and then manually import commands whenever you need them using <code></code>fc -RI<code>'.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-option-shfileexpansion">
<h3><code>shfileexpansion</code> <a class="doc-anchor" href="#doc-lsp-option-shfileexpansion">¶</a></h3>
<p>Perform filename expansion (e.g., <code>~</code> expansion) <em>before</em> parameter expansion, command substitution, arithmetic expansion and brace expansion. If this option is unset, it is performed <em>after</em> brace expansion, so things like "~$USERNAME" and "~{pfalstad,rc}" will work.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shglob">
<h3><code>shglob</code> <a class="doc-anchor" href="#doc-lsp-option-shglob">¶</a></h3>
<p>Disables the special meaning of "tt(()", "|", <code></code>")" and '<code><</code>' for globbing the result of parameter and command substitutions, and in some other places where the shell accepts patterns. If <code>SH_GLOB</code> is set but <code>KSH_GLOB</code> is not, the shell allows the interpretation of subshell expressions enclosed in parentheses in some cases where there is no space before the opening parenthesis, e.g. tt(!(true+)) is interpreted as if there were a space after the <code>!</code>. This option is set by default if zsh is invoked as <code>sh</code> or <code>ksh</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shinstdin">
<h3><code>shinstdin</code> <a class="doc-anchor" href="#doc-lsp-option-shinstdin">¶</a></h3>
<p>Commands are being read from the standard input. Commands are read from standard input if no command is specified with <code>-c</code> and no file of commands is specified. If <code>SHIN_STDIN</code> is set explicitly on the command line, any argument that would otherwise have been taken as a file to run will instead be treated as a normal positional parameter. Note that setting or unsetting this option on the command line does not necessarily affect the state the option will have while the shell is running - that is purely an indicator of whether or not commands are <em>actually</em> being read from standard input. The value of this option can only be changed via flags supplied at invocation of the shell. It cannot be changed once zsh is running.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shnullcmd">
<h3><code>shnullcmd</code> <a class="doc-anchor" href="#doc-lsp-option-shnullcmd">¶</a></h3>
<p>Do not use the values of <code>NULLCMD</code> and <code>READNULLCMD</code> when doing redirections, use ":" instead (see <em>Redirection</em> (zshmisc)).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shoptionletters">
<h3><code>shoptionletters</code> <a class="doc-anchor" href="#doc-lsp-option-shoptionletters">¶</a></h3>
<p>If this option is set the shell tries to interpret single letter options (which are used with <code>set</code> and <code>setopt</code>) like <strong>ksh</strong> does. This also affects the value of the <code>-</code> special parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shortloops">
<h3><code>shortloops</code> <a class="doc-anchor" href="#doc-lsp-option-shortloops">¶</a></h3>
<p>Allow the short forms of <code>for</code>, <code>repeat</code>, <code>select</code>, <code>if</code>, and <code>function</code> constructs.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shortrepeat">
<h3><code>shortrepeat</code> <a class="doc-anchor" href="#doc-lsp-option-shortrepeat">¶</a></h3>
<p>Allow the short form <code>repeat</code> as <code>SHORT_LOOPS</code> but without enabling it for the other constructs.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-shwordsplit">
<h3><code>shwordsplit</code> <a class="doc-anchor" href="#doc-lsp-option-shwordsplit">¶</a></h3>
<p>Causes field splitting to be performed on unquoted parameter expansions. Note that this option has nothing to do with word splitting. (See <em>Parameter Expansion</em> (zshexpn).)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-singlecommand">
<h3><code>singlecommand</code> <a class="doc-anchor" href="#doc-lsp-option-singlecommand">¶</a></h3>
<p>If the shell is reading from standard input, it exits after a single command has been executed. This also makes the shell non-interactive, unless the <code>INTERACTIVE</code> option is explicitly set on the command line. The value of this option can only be changed via flags supplied at invocation of the shell. It cannot be changed once zsh is running.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-singlelinezle">
<h3><code>singlelinezle</code> <a class="doc-anchor" href="#doc-lsp-option-singlelinezle">¶</a></h3>
<p>Use single-line command line editing instead of multi-line.</p>
<p>Note that although this is on by default in ksh emulation it only provides superficial compatibility with the ksh line editor and reduces the effectiveness of the zsh line editor. As it has no effect on shell syntax, many users may wish to disable this option when using ksh emulation interactively.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-sourcetrace">
<h3><code>sourcetrace</code> <a class="doc-anchor" href="#doc-lsp-option-sourcetrace">¶</a></h3>
<p>If set, zsh will print an informational message announcing the name of each file it loads. The format of the output is similar to that for the <code>XTRACE</code> option, with the message <code><sourcetrace></code>. A file may be loaded by the shell itself when it starts up and shuts down (<code>Startup/Shutdown Files</code>) or by the use of the "source" and "dot" builtin commands.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-stdin">
<h3><code>stdin</code> <a class="doc-anchor" href="#doc-lsp-option-stdin">¶</a></h3>
<p><code>SHIN_STDIN</code> (ksh compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-sunkeyboardhack">
<h3><code>sunkeyboardhack</code> <a class="doc-anchor" href="#doc-lsp-option-sunkeyboardhack">¶</a></h3>
<p>If a line ends with a backquote, and there are an odd number of backquotes on the line, ignore the trailing backquote. This is useful on some keyboards where the return key is too small, and the backquote key lies annoyingly close to it. As an alternative the variable <code>KEYBOARD_HACK</code> lets you choose the character to be removed.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-trackall">
<h3><code>trackall</code> <a class="doc-anchor" href="#doc-lsp-option-trackall">¶</a></h3>
<p><code>HASH_CMDS</code> (ksh compatibility)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-transientrprompt">
<h3><code>transientrprompt</code> <a class="doc-anchor" href="#doc-lsp-option-transientrprompt">¶</a></h3>
<p>Remove any right prompt from display when accepting a command line. This may be useful with terminals with other cut/paste methods.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-trapsasync">
<h3><code>trapsasync</code> <a class="doc-anchor" href="#doc-lsp-option-trapsasync">¶</a></h3>
<p>While waiting for a program to exit, handle signals and run traps immediately. Otherwise the trap is run after a child process has exited. Note this does not affect the point at which traps are run for any case other than when the shell is waiting for a child process.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-typesetsilent">
<h3><code>typesetsilent</code> <a class="doc-anchor" href="#doc-lsp-option-typesetsilent">¶</a></h3>
<p>If this is unset, executing any of the "typeset" family of commands with no options and a list of parameters that have no values to be assigned but already exist will display the value of the parameter. If the option is set, they will only be shown when parameters are selected with the "-m" option. The option "-p" is available whether or not the option is set.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-typesettounset">
<h3><code>typesettounset</code> <a class="doc-anchor" href="#doc-lsp-option-typesettounset">¶</a></h3>
<p>When declaring a new parameter with any of the "typeset" family of related commands, the parameter remains unset unless and until a value is explicitly assigned to it, either in the "typeset" command itself or as a later assignment statement.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-unset">
<h3><code>unset</code> <a class="doc-anchor" href="#doc-lsp-option-unset">¶</a></h3>
<p>Each named parameter is unset. Local parameters remain local even if unset; they appear unset within scope, but the previous value will still reappear when the scope ends.</p>
<p>Individual elements of associative array parameters may be unset by using subscript syntax on <em>name</em>, which should be quoted (or the entire command prefixed with <code>noglob</code>) to protect the subscript from filename generation.</p>
<p>If the <code>-m</code> flag is specified the arguments are taken as patterns (should be quoted) and all parameters with matching names are unset. Note that this cannot be used when unsetting associative array elements, as the subscript will be treated as part of the pattern.</p>
<p>The <code>-v</code> flag specifies that <em>name</em> refers to parameters. This is the default behaviour. If the <code>-n</code> option is supplied, and <em>name</em> is a a named reference, <em>name</em> will be unset rather than the variable it references.</p>
<p><code>unset -f</code> is equivalent to <code>unfunction</code>. The <code>-n</code> option has no effect with <code>-f</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-verbose">
<h3><code>verbose</code> <a class="doc-anchor" href="#doc-lsp-option-verbose">¶</a></h3>
<p>If set, as it is by default, the completion listing is more verbose. In particular many commands show descriptions for options if this style is "true".</p>
</article>
<article class="doc-entry" id="doc-lsp-option-vi">
<h3><code>vi</code> <a class="doc-anchor" href="#doc-lsp-option-vi">¶</a></h3>
<p>Move backward one word, where a word is defined as a series of non-blank characters.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-warncreateglobal">
<h3><code>warncreateglobal</code> <a class="doc-anchor" href="#doc-lsp-option-warncreateglobal">¶</a></h3>
<p>Print a warning message when a global parameter is created in a function by an assignment or in math context. This often indicates that a parameter has not been declared local when it should have been. Parameters explicitly declared global from within a function using <code>typeset -g</code> do not cause a warning. Note that there is no warning when a local parameter is assigned to in a nested function, which may also indicate an error.</p>
</article>
<article class="doc-entry" id="doc-lsp-option-warnnestedvar">
<h3><code>warnnestedvar</code> <a class="doc-anchor" href="#doc-lsp-option-warnnestedvar">¶</a></h3>
<p>Print a warning message when an existing parameter from an enclosing function scope, or global, is set in a function by an assignment or in math context. Assignment to shell special parameters does not cause a warning. This is the companion to <code>WARN_CREATE_GLOBAL</code> as in this case the warning is only printed when a parameter is <em>not</em> created. Where possible, use of <code>typeset -g</code> to set the parameter suppresses the error, but note that this needs to be used every time the parameter is set. To restrict the effect of this option to a single function scope, use "functions -W".</p>
<p>For example, the following code produces a warning for the assignment inside the function <code>nested</code> as that overrides the value within <code>toplevel</code></p>
<p>example(toplevel+() { local foo="in fn" nested } nested+() { foo="in nested" } setopt warn_nested_var toplevel)</p>
</article>
<article class="doc-entry" id="doc-lsp-option-xtrace">
<h3><code>xtrace</code> <a class="doc-anchor" href="#doc-lsp-option-xtrace">¶</a></h3>
<p>Print commands and their arguments as they are executed. The output is preceded by the value of <code>$PS4</code>, formatted as described in <em>Expansion of Prompt Sequences</em> (zshmisc).</p>
</article>
<article class="doc-entry" id="doc-lsp-option-zle">
<h3><code>zle</code> <a class="doc-anchor" href="#doc-lsp-option-zle">¶</a></h3>
<p>The <code>zle</code> builtin performs a number of different actions concerning ZLE.</p>
<p>With no options and no arguments, only the return status will be set. It is zero if ZLE is currently active and widgets could be invoked using this builtin command and non-zero otherwise. Note that even if non-zero status is returned, zle may still be active as part of the completion system; this does not allow direct calls to ZLE widgets.</p>
<p>Otherwise, which operation it performs depends on its options:</p>
<p>- <strong><code>-l</code> [ <code>-L</code> | <code>-a</code> ] [ <em>string</em> ]</strong> — List all existing user-defined widgets. If the <code>-L</code> option is used, list in the form of <code>zle</code> commands to create the widgets.</p>
<p>When combined with the <code>-a</code> option, all widget names are listed, including the builtin ones. In this case the <code>-L</code> option is ignored.</p>
<p>If at least one <em>string</em> is given, and <code>-a</code> is present or <code>-L</code> is not used, nothing will be printed. The return status will be zero if all _string_s are names of existing widgets and non-zero if at least one <em>string</em> is not a name of a defined widget. If <code>-a</code> is also present, all widget names are used for the comparison including builtin widgets, else only user-defined widgets are used.</p>
<p>If at least one <em>string</em> is present and the <code>-L</code> option is used, user-defined widgets matching any <em>string</em> are listed in the form of <code>zle</code> commands to create the widgets.</p>
<p>- <strong><code>-D</code> <em>widget</em> ...</strong> — Delete the named _widget_s.</p>
<p>- <strong><code>-A</code> <em>old-widget</em> <em>new-widget</em></strong> — Make the <em>new-widget</em> name an alias for <em>old-widget</em>, so that both names refer to the same widget. The names have equal standing; if either is deleted, the other remains. If there is already a widget with the <em>new-widget</em> name, it is deleted.</p>
<p>- <strong><code>-N</code> <em>widget</em> [ <em>function</em> ]</strong> — Create a user-defined widget. If there is already a widget with the specified name, it is overwritten. When the new widget is invoked from within the editor, the specified shell <em>function</em> is called. If no function name is specified, it defaults to the same name as the widget. For further information, see <em>Zle Widgets</em> (below).</p>
<p>- <strong><code>-f</code> <em>flag</em> [ <em>flag</em>... ]</strong> — Set various flags on the running widget. Possible values for <em>flag</em> are:</p>
<p><code>yank</code> for indicating that the widget has yanked text into the buffer. If the widget is wrapping an existing internal widget, no further action is necessary, but if it has inserted the text manually, then it should also take care to set <code>YANK_START</code> and <code>YANK_END</code> correctly. <code>yankbefore</code> does the same but is used when the yanked text appears after the cursor.</p>
<p><code>kill</code> for indicating that text has been killed into the cutbuffer. When repeatedly invoking a kill widget, text is appended to the cutbuffer instead of replacing it, but when wrapping such widgets, it is necessary to call "zle -f kill" to retain this effect.</p>
<p><code>vichange</code> for indicating that the widget represents a vi change that can be repeated as a whole with "vi-repeat-change". The flag should be set early in the function before inspecting the value of <code>NUMERIC</code> or invoking other widgets. This has no effect for a widget invoked from insert mode. If insert mode is active when the widget finishes, the change extends until next returning to command mode.</p>
<p>cindex(completion widgets, creating)</p>
<p>- <strong><code>-C</code> <em>widget</em> <em>completion-widget</em> <em>function</em></strong> — Create a user-defined completion widget named <em>widget</em>. The completion widget will behave like the built-in completion-widget whose name is given as <em>completion-widget</em>. To generate the completions, the shell function <em>function</em> will be called. For further information, see nmref(Completion Widgets)(zshcompwid).</p>
<p>- <strong><code>-R</code> [ <code>-c</code> ] [ <em>display-string</em> ] [ <em>string</em> ... ]</strong> — Redisplay the command line. If a <em>display-string</em> is given and not empty, this is shown in the status line (immediately below the line being edited).</p>
<p>If the optional _string_s are given they are listed below the prompt in the same way as completion lists are printed. If no _string_s are given but the <code>-c</code> option is used such a list is cleared.</p>
<p>Note that immediately after returning from running widgets, the command line will be redisplayed and the strings displayed will be erased. Therefore, this option is only useful for widgets that do not exit immediately after using it.</p>
<p>This command can safely be called outside user defined widgets; if zle is active, the display will be refreshed, while if zle is not active, the command has no effect. In this case there will usually be no other arguments.</p>
<p>The status is zero if zle was active, else one.</p>
<p>- <strong><code>-M</code> <em>string</em></strong> — As with the <code>-R</code> option, the <em>string</em> will be displayed below the command line; unlike the <code>-R</code> option, the string will not be put into the status line but will instead be printed normally below the prompt. This means that the <em>string</em> will still be displayed after the widget returns (until it is overwritten by subsequent commands).</p>
<p>- <strong><code>-U</code> <em>string</em></strong> — This pushes the characters in the <em>string</em> onto the input stack of ZLE. After the widget currently executed finishes ZLE will behave as if the characters in the <em>string</em> were typed by the user.</p>
<p>As ZLE uses a stack, if this option is used repeatedly the last string pushed onto the stack will be processed first. However, the characters in each <em>string</em> will be processed in the order in which they appear in the string.</p>
<p>- <strong><code>-K</code> <em>keymap</em></strong> — Selects the keymap named <em>keymap</em>. An error message will be displayed if there is no such keymap.</p>
<p>This keymap selection affects the interpretation of following keystrokes within this invocation of ZLE. Any following invocation (e.g., the next command line) will start as usual with the "main" keymap selected.</p>
<p>- <strong><code>-F</code> [ <code>-L</code> | <code>-w</code> ] [ <em>fd</em> [ <em>handler</em> ] ]</strong> — Only available if your system supports one of the "poll" or "select" system calls; most modern systems do.</p>
<p>Installs <em>handler</em> (the name of a shell function) to handle input from file descriptor <em>fd</em>. Installing a handler for an <em>fd</em> which is already handled causes the existing handler to be replaced. Any number of handlers for any number of readable file descriptors may be installed. Note that zle makes no attempt to check whether this <em>fd</em> is actually readable when installing the handler. The user must make their own arrangements for handling the file descriptor when zle is not active.</p>
<p>When zle is attempting to read data, it will examine both the terminal and the list of handled <em>fd</em>'s. If data becomes available on a handled <em>fd</em>, zle calls <em>handler</em> with the fd which is ready for reading as the first argument. Under normal circumstances this is the only argument, but if an error was detected, a second argument provides details: "hup" for a disconnect, "nval" for a closed or otherwise invalid descriptor, or "err" for any other condition. Systems that support only the "select" system call always use "err".</p>
<p>If the option <code>-w</code> is also given, the <em>handler</em> is instead a line editor widget, typically a shell function made into a widget using "zle -N". In that case <em>handler</em> can use all the facilities of zle to update the current editing line. Note, however, that as handling <em>fd</em> takes place at a low level changes to the display will not automatically appear; the widget should call "zle -R" to force redisplay. As of this writing, widget handlers only support a single argument and thus are never passed a string for error state, so widgets must be prepared to test the descriptor themselves.</p>
<p>If either type of handler produces output to the terminal, it should call "zle -I" before doing so (see below). Handlers should not attempt to read from the terminal.</p>
<p>If no <em>handler</em> is given, but an <em>fd</em> is present, any handler for that <em>fd</em> is removed. If there is none, an error message is printed and status 1 is returned.</p>
<p>If no arguments are given, or the <code>-L</code> option is supplied, a list of handlers is printed in a form which can be stored for later execution.</p>
<p>An <em>fd</em> (but not a <em>handler</em>) may optionally be given with the <code>-L</code> option; in this case, the function will list the handler if any, else silently return status 1.</p>
<p>Note that this feature should be used with care. Activity on one of the <em>fd</em>'s which is not properly handled can cause the terminal to become unusable. Removing an <em>fd</em> handler from within a signal trap may cause unpredictable behavior.</p>
<p>Here is a simple example of using this feature. A connection to a remote TCP port is created using the ztcp command; see <em>The zsh/net/tcp Module</em> (zshmodules). Then a handler is installed which simply prints out any data which arrives on this connection. Note that "select" will indicate that the file descriptor needs handling if the remote side has closed the connection; we handle that by testing for a failed read.</p>
<p>example(if ztcp pwspc 2811; then tcpfd=$REPLY handler+() { zle -I local line if ! read -r line <&$1; then # select marks this fd if we reach EOF, # so handle this specially. print "[Read on fd $1 failed, removing.]" >&2 zle -F $1 return 1 fi print -r - $line } zle -F $tcpfd handler fi)</p>
<p>- <strong><code>-I</code></strong> — Unusually, this option is most useful outside ordinary widget functions, though it may be used within if normal output to the terminal is required. It invalidates the current zle display in preparation for output; typically this will be from a trap function. It has no effect if zle is not active. When a trap exits, the shell checks to see if the display needs restoring, hence the following will print output in such a way as not to disturb the line being edited:</p>
<p>example(TRAPUSR1() { # Invalidate zle display [[ -o zle ]] && zle -I # Show output print Hello })</p>
<p>In general, the trap function may need to test whether zle is active before using this method (as shown in the example), since the <code>zsh/zle</code> module may not even be loaded; if it is not, the command can be skipped.</p>
<p>It is possible to call "zle -I" several times before control is returned to the editor; the display will only be invalidated the first time to minimise disruption.</p>
<p>Note that there are normally better ways of manipulating the display from within zle widgets; see, for example, "zle -R" above.</p>
<p>The returned status is zero if zle was invalidated, even though this may have been by a previous call to "zle -I" or by a system notification. To test if a zle widget may be called at this point, execute <code>zle</code> with no arguments and examine the return status.</p>
<p>- <strong><code>-T</code></strong> — This is used to add, list or remove internal transformations on the processing performed by the line editor. It is typically used only for debugging or testing and is therefore of little interest to the general user.</p>
<p><code></code>zle -T" <em>transformation</em> <em>func</em>" specifies that the given <em>transformation</em> (see below) is effected by shell function <em>func</em>.</p>
<p><code></code>zle -Tr" <em>transformation</em>" removes the given <em>transformation</em> if it was present (it is not an error if none was).</p>
<p>"zle -TL" can be used to list all transformations currently in operation.</p>
<p>Currently the only transformation is <code>tc</code>. This is used instead of outputting termcap codes to the terminal. When the transformation is in operation the shell function is passed the termcap code that would be output as its first argument; if the operation required a numeric argument, that is passed as a second argument. The function should set the shell variable <code>REPLY</code> to the transformed termcap code. Typically this is used to produce some simply formatted version of the code and optional argument for debugging or testing. Note that this transformation is not applied to other non-printing characters such as carriage returns and newlines.</p>
<p>- <strong><em>widget</em> [ <code>-n</code> <em>num</em> ] [ <code>-f</code> <em>flag</em> ] [ <code>-Nw</code> ] [ <code>-K</code> <em>keymap</em> ] <em>args</em> ...</strong> — Invoke the specified <em>widget</em>. This can only be done when ZLE is active; normally this will be within a user-defined widget.</p>
<p>With the options <code>-n</code> and <code>-N</code>, the current numeric argument will be saved and then restored after the call to <em>widget</em>; <code></code>-n" <em>num</em>" sets the numeric argument temporarily to <em>num</em>, while "-N" sets it to the default, i.e. as if there were none.</p>
<p>With the option <code>-K</code>, <em>keymap</em> will be used as the current keymap during the execution of the widget. The previous keymap will be restored when the widget exits.</p>
<p>Normally, calling a widget in this way does not set the special parameter <code>WIDGET</code> and related parameters, so that the environment appears as if the top-level widget called by the user were still active. With the option <code>-w</code>, <code>WIDGET</code> and related parameters are set to reflect the widget being executed by the <code>zle</code> call.</p>
<p>Normally, when <em>widget</em> returns the special parameter <code>LASTWIDGET</code> will point to it. This can be inhibited by passing the option <code>-f nolast</code>.</p>
<p>Any further arguments will be passed to the widget; note that as standard argument handling is performed, any general argument list should be preceded by <code>-</code><code>-</code>. If it is a shell function, these are passed down as positional parameters; for builtin widgets it is up to the widget in question what it does with them. Currently arguments are only handled by the incremental-search commands, the <code>history-search-forward</code> and <code>-backward</code> and the corresponding functions prefixed by <code>vi-</code>, and by <code>universal-argument</code>. No error is flagged if the command does not use the arguments, or only uses some of them.</p>
<p>The return status reflects the success or failure of the operation carried out by the widget, or if it is a user-defined widget the return status of the shell function.</p>
<p>A non-zero return status causes the shell to beep when the widget exits, unless the <code>BEEP</code> options was unset or the widget was called via the <code>zle</code> command. Thus if a user defined widget requires an immediate beep, it should call the <code>beep</code> widget directly.</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-specials">
<h2>Special Variable Index</h2>
<p class="chapter-meta">256 entries · zsh-defined parameters and well-known env vars. Includes both scalar (<code>$?</code>) and array (<code>$path</code>) forms.</p>
<article class="doc-entry" id="doc-lsp-special-bang">
<h3><code>!</code> <a class="doc-anchor" href="#doc-lsp-special-bang">¶</a></h3>
<p>Pipeline negation (also a reserved word). <code>! cmd</code> inverts <code>cmd</code>'s exit status — zero becomes 1, non-zero becomes 0. Distinct from <code>!</code> history expansion (lexer-stage).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-hash">
<h3><code>#</code> <a class="doc-anchor" href="#doc-lsp-special-hash">¶</a></h3>
<p>The number of positional parameters in decimal. Note that some confusion may occur with the syntax <code>$#</code><em>param</em> which substitutes the length of <em>param</em>. Use <code>${#}</code> to resolve ambiguities. In particular, the sequence <code></code>$#-"<em>...</em>" in an arithmetic expression is interpreted as the length of the parameter <code>-</code>, q.v.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollar">
<h3><code>$</code> <a class="doc-anchor" href="#doc-lsp-special-dollar">¶</a></h3>
<p>The process ID of this shell, set when the shell initializes. Processes forked from the shell without executing a new program, such as command substitutions and commands grouped with tt(()<em>...</em><code></code>), are subshells that duplicate the current shell, and thus substitute the same value for <code>$$</code> as their parent shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarARGC">
<h3><code>$ARGC</code> <a class="doc-anchor" href="#doc-lsp-special-dollarARGC">¶</a></h3>
<p>Same as <code>#</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarARGV0">
<h3><code>$ARGV0</code> <a class="doc-anchor" href="#doc-lsp-special-dollarARGV0">¶</a></h3>
<p>If exported, its value is used as the <code>argv[0]</code> of external commands. Usually used in constructs like "ARGV0=emacs nethack".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarBAUD">
<h3><code>$BAUD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarBAUD">¶</a></h3>
<p>The rate in bits per second at which data reaches the terminal. The line editor will use this value in order to compensate for a slow terminal by delaying updates to the display until necessary. If the parameter is unset or the value is zero the compensation mechanism is turned off. The parameter is not set by default.</p>
<p>This parameter may be profitably set in some circumstances, e.g. for slow modems dialing into a communications server, or on a slow wide area network. It should be set to the baud rate of the slowest part of the link for best performance.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarBUFFER">
<h3><code>$BUFFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarBUFFER">¶</a></h3>
<p>The entire contents of the edit buffer. If it is written to, the cursor remains at the same offset, unless that would put it outside the buffer.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarBUFFERLINES">
<h3><code>$BUFFERLINES</code> <a class="doc-anchor" href="#doc-lsp-special-dollarBUFFERLINES">¶</a></h3>
<p>The number of screen lines needed for the edit buffer currently displayed on screen (i.e. without any changes to the preceding parameters done after the last redisplay); read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCOLUMNS">
<h3><code>$COLUMNS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCOLUMNS">¶</a></h3>
<p>The number of columns for this terminal session. Used for printing select lists and for the line editor.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCONTEXT">
<h3><code>$CONTEXT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCONTEXT">¶</a></h3>
<p>The context in which zle was called to read a line; read-only. One of the values:</p>
<p>- <strong><code>start</code></strong> — The start of a command line (at prompt <code>PS1</code>).</p>
<p>- <strong><code>cont</code></strong> — A continuation to a command line (at prompt <code>PS2</code>).</p>
<p>- <strong><code>select</code></strong> — In a <code>select</code> loop (at prompt <code>PS3</code>).</p>
<p>- <strong><code>vared</code></strong> — Editing a variable in <code>vared</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCORRECT_IGNORE">
<h3><code>$CORRECT_IGNORE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCORRECT_IGNORE">¶</a></h3>
<p>If set, is treated as a pattern during spelling correction. Any potential correction that matches the pattern is ignored. For example, if the value is "<em>*" then completion functions (which, by convention, have names beginning with "</em>") will never be offered as spelling corrections. The pattern does not apply to the correction of file names, as applied by the <code>CORRECT_ALL</code> option (so with the example just given files beginning with "_" in the current directory would still be completed).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCORRECT_IGNORE_FILE">
<h3><code>$CORRECT_IGNORE_FILE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCORRECT_IGNORE_FILE">¶</a></h3>
<p>If set, is treated as a pattern during spelling correction of file names. Any file name that matches the pattern is never offered as a correction. For example, if the value is ".*" then dot file names will never be offered as spelling corrections. This is useful with the <code>CORRECT_ALL</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCPUTYPE">
<h3><code>$CPUTYPE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCPUTYPE">¶</a></h3>
<p>The machine type (microprocessor class or machine model), as determined at run time.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCURSOR">
<h3><code>$CURSOR</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCURSOR">¶</a></h3>
<p>The offset of the cursor, within the edit buffer. This is in the range 0 to <code>$#BUFFER</code>, and is by definition equal to <code>$#LBUFFER</code>. Attempts to move the cursor outside the buffer will result in the cursor being moved to the appropriate end of the buffer.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarCUTBUFFER">
<h3><code>$CUTBUFFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarCUTBUFFER">¶</a></h3>
<p>The last item cut using one of the "kill-" commands; the string which the next yank would insert in the line. Later entries in the kill ring are in the array <code>killring</code>. Note that the command <code></code>zle copy-region-as-kill" <em>string</em>" can be used to set the text of the cut buffer from a shell function and cycle the kill ring in the same way as interactively killing text.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarDIRSTACKSIZE">
<h3><code>$DIRSTACKSIZE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarDIRSTACKSIZE">¶</a></h3>
<p>The maximum size of the directory stack, by default there is no limit. If the stack gets larger than this, it will be truncated automatically. This is useful with the <code>AUTO_PUSHD</code> option. pindex(AUTO_PUSHD, use of)</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarEGID">
<h3><code>$EGID</code> <a class="doc-anchor" href="#doc-lsp-special-dollarEGID">¶</a></h3>
<p>The effective group ID of the shell process. If you have sufficient privileges, you may change the effective group ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective group ID by <code>tt((EGID=)_gid_</code>; command+")"</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarENV">
<h3><code>$ENV</code> <a class="doc-anchor" href="#doc-lsp-special-dollarENV">¶</a></h3>
<p>If the <code>ENV</code> environment variable is set when zsh is invoked as <code>sh</code> or <code>ksh</code>, <code>$ENV</code> is sourced after the profile scripts. The value of <code>ENV</code> is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. Note that <code>ENV</code> is <em>not</em> used unless the shell is interactive and zsh is emulating <strong>sh</strong> or <strong>ksh</strong>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarEPOCHREALTIME">
<h3><code>$EPOCHREALTIME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarEPOCHREALTIME">¶</a></h3>
<p>A floating point value representing the number of seconds since the epoch. The notional accuracy is to nanoseconds if the <code>clock_gettime</code> call is available and to microseconds otherwise, but in practice the range of double precision floating point and shell scheduling latencies may be significant effects.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarEPOCHSECONDS">
<h3><code>$EPOCHSECONDS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarEPOCHSECONDS">¶</a></h3>
<p>An integer value representing the number of seconds since the epoch.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarERRNO">
<h3><code>$ERRNO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarERRNO">¶</a></h3>
<p>The value of <code>errno</code> (see manref(errno)(3)) as set by the most recently failed system call. This value is system dependent and is intended for debugging purposes. It is also useful with the <code>zsh/system</code> module which allows the number to be turned into a name or message.</p>
<p>To use this parameter, it must first be assigned a value (typically 0 (zero)). It is initially unset for scripting compatibility.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarEUID">
<h3><code>$EUID</code> <a class="doc-anchor" href="#doc-lsp-special-dollarEUID">¶</a></h3>
<p>The effective user ID of the shell process. If you have sufficient privileges, you may change the effective user ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective user ID by <code>tt((EUID=)_uid_</code>; command+")"</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarFCEDIT">
<h3><code>$FCEDIT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarFCEDIT">¶</a></h3>
<p>The default editor for the <code>fc</code> builtin. If <code>FCEDIT</code> is not set, the parameter <code>EDITOR</code> is used; if that is not set either, a builtin default, usually <code>vi</code>, is used.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarFUNCNEST">
<h3><code>$FUNCNEST</code> <a class="doc-anchor" href="#doc-lsp-special-dollarFUNCNEST">¶</a></h3>
<p>Integer. If greater than or equal to zero, the maximum nesting depth of shell functions. When it is exceeded, an error is raised at the point where a function is called. The default value is determined when the shell is configured, but is typically 500. Increasing the value increases the danger of a runaway function recursion causing the shell to crash. Setting a negative value turns off the check.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarGID">
<h3><code>$GID</code> <a class="doc-anchor" href="#doc-lsp-special-dollarGID">¶</a></h3>
<p>The real group ID of the shell process. If you have sufficient privileges, you may change the group ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different group ID by <code>tt((GID=)_gid_</code>; command+")"</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTCHARS">
<h3><code>$HISTCHARS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTCHARS">¶</a></h3>
<p>Same as <code>histchars</code>. (Deprecated.)</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTCMD">
<h3><code>$HISTCMD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTCMD">¶</a></h3>
<p>The current history event number in an interactive shell, in other words the event number for the command that caused <code>$HISTCMD</code> to be read. If the current history event modifies the history, <code>HISTCMD</code> changes to the new maximum history event number.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTFILE">
<h3><code>$HISTFILE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTFILE">¶</a></h3>
<p>The file to save the history in when an interactive shell exits. If unset, the history is not saved.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTNO">
<h3><code>$HISTNO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTNO">¶</a></h3>
<p>The current history number. Setting this has the same effect as moving up or down in the history to the corresponding history line. An attempt to set it is ignored if the line is not stored in the history. Note this is not the same as the parameter <code>HISTCMD</code>, which always gives the number of the history line being added to the main shell's history. <code>HISTNO</code> refers to the line being retrieved within zle.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTORY_IGNORE">
<h3><code>$HISTORY_IGNORE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTORY_IGNORE">¶</a></h3>
<p>If set, is treated as a pattern at the time history files are written. Any potential history entry that matches the pattern is skipped. For example, if the value is "fc *" then commands that invoke the interactive history editor are never written to the history file.</p>
<p>Note that <code>HISTORY_IGNORE</code> defines a single pattern: to specify alternatives use the <code>tt(()_first_</code>|<code>_second_</code>|<code>_..._</code>")" syntax.</p>
<p>Compare the <code>HIST_NO_STORE</code> option or the <code>zshaddhistory</code> hook, either of which would prevent such commands from being added to the interactive history at all. If you wish to use <code>HISTORY_IGNORE</code> to stop history being added in the first place, you can define the following hook:</p>
<p>example(zshaddhistory+() { emulate -L zsh ## uncomment if HISTORY_IGNORE ## should use EXTENDED_GLOB syntax # setopt extendedglob [[ $1 != ${~HISTORY_IGNORE} ]] })</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHISTSIZE">
<h3><code>$HISTSIZE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHISTSIZE">¶</a></h3>
<p>The maximum number of events stored in the internal history list. If you use the <code>HIST_EXPIRE_DUPS_FIRST</code> option, setting this value larger than the <code>SAVEHIST</code> size will give you the difference as a cushion for saving duplicated history events.</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHOME">
<h3><code>$HOME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHOME">¶</a></h3>
<p>The default argument for the <code>cd</code> command. This is not set automatically by the shell in <code>sh</code>, <code>ksh</code> or <code>csh</code> emulation, but it is typically present in the environment anyway, and if it becomes set it has its usual special behaviour.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarHOST">
<h3><code>$HOST</code> <a class="doc-anchor" href="#doc-lsp-special-dollarHOST">¶</a></h3>
<p>The current hostname.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarIFS">
<h3><code>$IFS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarIFS">¶</a></h3>
<p>Internal field separators (by default space, tab, newline and NUL), that are used to separate words which result from command or parameter expansion and words read by the <code>read</code> builtin. Any characters from the set space, tab and newline that appear in the <code>IFS</code> are called <em>IFS white space</em>. One or more IFS white space characters or one non-IFS white space character together with any adjacent IFS white space character delimit a field. If an IFS white space character appears twice consecutively in the <code>IFS</code>, this character is treated as if it were not an IFS white space character.</p>
<p>If the parameter is unset, the default is used. Note this has a different effect from setting the parameter to an empty string.</p>
<p>If <code>MULTIBYTE</code> option is on and <code>IFS</code> contains invalid characters in the current locale, it is reset to the default.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarISEARCHMATCH_END">
<h3><code>$ISEARCHMATCH_END</code> <a class="doc-anchor" href="#doc-lsp-special-dollarISEARCHMATCH_END">¶</a></h3>
<p><code>ISEARCHMATCH_ACTIVE</code> indicates whether a part of the <code>BUFFER</code> is currently matched by an incremental search pattern. <code>ISEARCHMATCH_START</code> and <code>ISEARCHMATCH_END</code> give the location of the matched part and are in the same units as <code>CURSOR</code>. They are only valid for reading when <code>ISEARCHMATCH_ACTIVE</code> is non-zero.</p>
<p>All parameters are read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarKEYBOARD_HACK">
<h3><code>$KEYBOARD_HACK</code> <a class="doc-anchor" href="#doc-lsp-special-dollarKEYBOARD_HACK">¶</a></h3>
<p>This variable defines a character to be removed from the end of the command line before interpreting it (interactive shells only). It is intended to fix the problem with keys placed annoyingly close to return and replaces the <code>SUNKEYBOARDHACK</code> option which did this for backquotes only. Should the chosen character be one of singlequote, doublequote or backquote, there must also be an odd number of them on the command line for the last one to be removed.</p>
<p>For backward compatibility, if the <code>SUNKEYBOARDHACK</code> option is explicitly set, the value of <code>KEYBOARD_HACK</code> reverts to backquote. If the option is explicitly unset, this variable is set to empty.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarKEYMAP">
<h3><code>$KEYMAP</code> <a class="doc-anchor" href="#doc-lsp-special-dollarKEYMAP">¶</a></h3>
<p>The name of the currently selected keymap; read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarKEYS">
<h3><code>$KEYS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarKEYS">¶</a></h3>
<p>The keys typed to invoke this widget, as a literal string; read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarKEYS_QUEUED_COUNT">
<h3><code>$KEYS_QUEUED_COUNT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarKEYS_QUEUED_COUNT">¶</a></h3>
<p>The number of bytes pushed back to the input queue and therefore available for reading immediately before any I/O is done; read-only. See also <code>PENDING</code>; the two values are distinct.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarKEYTIMEOUT">
<h3><code>$KEYTIMEOUT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarKEYTIMEOUT">¶</a></h3>
<p>The time the shell waits, in hundredths of seconds, for another key to be pressed when reading bound multi-character sequences.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLANG">
<h3><code>$LANG</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLANG">¶</a></h3>
<p>This variable determines the locale category for any category not specifically selected via a variable starting with "LC_".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLASTABORTEDSEARCH">
<h3><code>$LASTABORTEDSEARCH</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLASTABORTEDSEARCH">¶</a></h3>
<p>The last search string used by an interactive search that was aborted by the user (status 3 returned by the search widget).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLASTSEARCH">
<h3><code>$LASTSEARCH</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLASTSEARCH">¶</a></h3>
<p>The last search string used by an interactive search; read-only. This is set even if the search failed (status 0, 1 or 2 returned by the search widget), but not if it was aborted by the user.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLASTWIDGET">
<h3><code>$LASTWIDGET</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLASTWIDGET">¶</a></h3>
<p>The name of the last widget that was executed; read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLBUFFER">
<h3><code>$LBUFFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLBUFFER">¶</a></h3>
<p>The part of the buffer that lies to the left of the cursor position. If it is assigned to, only that part of the buffer is replaced, and the cursor remains between the new <code>$LBUFFER</code> and the old <code>$RBUFFER</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_ALL">
<h3><code>$LC_ALL</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_ALL">¶</a></h3>
<p>This variable overrides the value of the "LANG" variable and the value of any of the other variables starting with "LC_".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_COLLATE">
<h3><code>$LC_COLLATE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_COLLATE">¶</a></h3>
<p>This variable determines the locale category for character collation information within ranges in glob brackets and for sorting.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_CTYPE">
<h3><code>$LC_CTYPE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_CTYPE">¶</a></h3>
<p>This variable determines the locale category for character handling functions. If the <code>MULTIBYTE</code> option is in effect this variable or <code>LANG</code> should contain a value that reflects the character set in use, even if it is a single-byte character set, unless only the 7-bit subset (ASCII) is used. For example, if the character set is ISO-8859-1, a suitable value might be <code>en_US.iso88591</code> (certain Linux distributions) or <code>en_US.ISO8859-1</code> (MacOS).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_MESSAGES">
<h3><code>$LC_MESSAGES</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_MESSAGES">¶</a></h3>
<p>This variable determines the language in which messages should be written. Note that zsh does not use message catalogs.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_NUMERIC">
<h3><code>$LC_NUMERIC</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_NUMERIC">¶</a></h3>
<p>This variable affects the decimal point character and thousands separator character for the formatted input/output functions and string conversion functions. Note that zsh ignores this setting when parsing floating point mathematical expressions.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLC_TIME">
<h3><code>$LC_TIME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLC_TIME">¶</a></h3>
<p>This variable determines the locale category for date and time formatting in prompt escape sequences.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLINENO">
<h3><code>$LINENO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLINENO">¶</a></h3>
<p>The line number of the current line within the current script, sourced file, or shell function being executed, whichever was started most recently. Note that in the case of shell functions the line number refers to the function as it appeared in the original definition, not necessarily as displayed by the <code>functions</code> builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLINES">
<h3><code>$LINES</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLINES">¶</a></h3>
<p>The number of lines for this terminal session. Used for printing select lists and for the line editor.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLISTMAX">
<h3><code>$LISTMAX</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLISTMAX">¶</a></h3>
<p>In the line editor, the number of matches to list without asking first. If the value is negative, the list will be shown if it spans at most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLOGCHECK">
<h3><code>$LOGCHECK</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLOGCHECK">¶</a></h3>
<p>The interval in seconds between checks for login/logout activity using the <code>watch</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarLOGNAME">
<h3><code>$LOGNAME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarLOGNAME">¶</a></h3>
<p>If the corresponding variable is not set in the environment of the shell, it is initialized to the login name corresponding to the current login session. This parameter is exported by default but this can be disabled using the <code>typeset</code> builtin. The value is set to the string returned by the manref(getlogin)(3) system call if that is available.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarMACHTYPE">
<h3><code>$MACHTYPE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarMACHTYPE">¶</a></h3>
<p>The machine type (microprocessor class or machine model), as determined at compile time.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarMAIL">
<h3><code>$MAIL</code> <a class="doc-anchor" href="#doc-lsp-special-dollarMAIL">¶</a></h3>
<p>If this parameter is set and <code>mailpath</code> is not set, the shell looks for mail in the specified file.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarMAILCHECK">
<h3><code>$MAILCHECK</code> <a class="doc-anchor" href="#doc-lsp-special-dollarMAILCHECK">¶</a></h3>
<p>The interval in seconds between checks for new mail.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarMARK">
<h3><code>$MARK</code> <a class="doc-anchor" href="#doc-lsp-special-dollarMARK">¶</a></h3>
<p>Like <code>CURSOR</code>, but for the mark. With vi-mode operators that wait for a movement command to select a region of text, setting <code>MARK</code> allows the selection to extend in both directions from the initial cursor position.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarNULLCMD">
<h3><code>$NULLCMD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarNULLCMD">¶</a></h3>
<p>The command name to assume if a redirection is specified with no command. Defaults to <code>cat</code>. For <strong>sh</strong>/<strong>ksh</strong> behavior, change this to <code>:</code>. For <strong>csh</strong>-like behavior, unset this parameter; the shell will print an error message if null commands are entered.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarNUMERIC">
<h3><code>$NUMERIC</code> <a class="doc-anchor" href="#doc-lsp-special-dollarNUMERIC">¶</a></h3>
<p>The numeric argument. If no numeric argument was given, this parameter is unset. When this is set inside a widget function, builtin widgets called with the <code>zle</code> builtin command will use the value assigned. If it is unset inside a widget function, builtin widgets called behave as if no numeric argument was given.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarOLDPWD">
<h3><code>$OLDPWD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarOLDPWD">¶</a></h3>
<p>The previous working directory. This is set when the shell initializes and whenever the directory changes.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarOPTARG">
<h3><code>$OPTARG</code> <a class="doc-anchor" href="#doc-lsp-special-dollarOPTARG">¶</a></h3>
<p>The value of the last option argument processed by the <code>getopts</code> command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarOPTIND">
<h3><code>$OPTIND</code> <a class="doc-anchor" href="#doc-lsp-special-dollarOPTIND">¶</a></h3>
<p>The index of the last option argument processed by the <code>getopts</code> command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarOSTYPE">
<h3><code>$OSTYPE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarOSTYPE">¶</a></h3>
<p>The operating system, as determined at compile time.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPENDING">
<h3><code>$PENDING</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPENDING">¶</a></h3>
<p>The number of bytes pending for input, i.e. the number of bytes which have already been typed and can immediately be read. On systems where the shell is not able to get this information, this parameter will always have a value of zero. Read-only. See also <code>KEYS_QUEUED_COUNT</code>; the two values are distinct.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPOSTDISPLAY">
<h3><code>$POSTDISPLAY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPOSTDISPLAY">¶</a></h3>
<p>Text to be displayed after the end of the editable text buffer. This does not have to be a complete line; to display a complete line, a newline must be prepended explicitly. The text is reset on each new invocation (but not recursive invocation) of zle.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPOSTEDIT">
<h3><code>$POSTEDIT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPOSTEDIT">¶</a></h3>
<p>This string is output whenever the line editor exits. It usually contains termcap strings to reset the terminal.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPPID">
<h3><code>$PPID</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPPID">¶</a></h3>
<p>The process ID of the parent of the shell, set when the shell initializes. As with <code>$$</code>, the value does not change in subshells created as a duplicate of the current shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPREBUFFER">
<h3><code>$PREBUFFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPREBUFFER">¶</a></h3>
<p>In a multi-line input at the secondary prompt, this read-only parameter contains the contents of the lines before the one the cursor is currently in.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPREDISPLAY">
<h3><code>$PREDISPLAY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPREDISPLAY">¶</a></h3>
<p>Text to be displayed before the start of the editable text buffer. This does not have to be a complete line; to display a complete line, a newline must be appended explicitly. The text is reset on each new invocation (but not recursive invocation) of zle.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPROMPT4">
<h3><code>$PROMPT4</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPROMPT4">¶</a></h3>
<p>Same as <code>PS1</code>, <code>PS2</code>, <code>PS3</code> and <code>PS4</code>, respectively.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPROMPT_EOL_MARK">
<h3><code>$PROMPT_EOL_MARK</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPROMPT_EOL_MARK">¶</a></h3>
<p>When the <code>PROMPT_CR</code> and <code>PROMPT_SP</code> options are set, the <code>PROMPT_EOL_MARK</code> parameter can be used to customize how the end of partial lines are shown. This parameter undergoes prompt expansion, with the <code>PROMPT_PERCENT</code> option set. If not set, the default behavior is equivalent to the value "%B%S%#%s%b".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPS1">
<h3><code>$PS1</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPS1">¶</a></h3>
<p>The primary prompt string, printed before a command is read. It undergoes a special form of expansion before being displayed; see <em>Expansion of Prompt Sequences</em> (zshmisc). The default is "%m%# ".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPS2">
<h3><code>$PS2</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPS2">¶</a></h3>
<p>The secondary prompt, printed when the shell needs more information to complete a command. It is expanded in the same way as <code>PS1</code>. The default is "%_> ", which displays any shell constructs or quotation marks which are currently being processed.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPS3">
<h3><code>$PS3</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPS3">¶</a></h3>
<p>Selection prompt used within a <code>select</code> loop. It is expanded in the same way as <code>PS1</code>. The default is "?# ".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPS4">
<h3><code>$PS4</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPS4">¶</a></h3>
<p>The execution trace prompt. Default is "+%N:%i> ", which displays the name of the current shell structure and the line number within it. In sh or ksh emulation, the default is "+ ".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarPWD">
<h3><code>$PWD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarPWD">¶</a></h3>
<p>The present working directory. This is set when the shell initializes and whenever the directory changes.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarRANDOM">
<h3><code>$RANDOM</code> <a class="doc-anchor" href="#doc-lsp-special-dollarRANDOM">¶</a></h3>
<p>A pseudo-random integer from 0 to 32767, newly generated each time this parameter is referenced. The random number generator can be seeded by assigning a numeric value to <code>RANDOM</code>.</p>
<p>The values of <code>RANDOM</code> form an intentionally-repeatable pseudo-random sequence; subshells that reference <code>RANDOM</code> will result in identical pseudo-random values unless the value of <code>RANDOM</code> is referenced or seeded in the parent shell in between subshell invocations.</p>
<p><code>RANDOM" uses the system"s library function manref(rand)(3). If higher degree of randomness is required, please consider using the autoloadable parameter </code>SRANDOM<code> from ifzman(the </code>zsh/random<code> module (see zmanref(zshmodules)))\ ifnzman((The zsh/random Module)).</code></p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarRBUFFER">
<h3><code>$RBUFFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarRBUFFER">¶</a></h3>
<p>The part of the buffer that lies to the right of the cursor position. If it is assigned to, only that part of the buffer is replaced, and the cursor remains between the old <code>$LBUFFER</code> and the new <code>$RBUFFER</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarREADNULLCMD">
<h3><code>$READNULLCMD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarREADNULLCMD">¶</a></h3>
<p>The command name to assume if a single input redirection is specified with no command. Defaults to <code>more</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarREGION_ACTIVE">
<h3><code>$REGION_ACTIVE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarREGION_ACTIVE">¶</a></h3>
<p>Indicates if the region is currently active. It can be assigned 0 or 1 to deactivate and activate the region respectively. A value of 2 activates the region in line-wise mode with the highlighted text extending for whole lines only; see <em>Character Highlighting</em> (below).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarREPLY">
<h3><code>$REPLY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarREPLY">¶</a></h3>
<p>This parameter is reserved by convention to pass string values between shell scripts and shell builtins in situations where a function call or redirection are impossible or undesirable. The <code>read</code> builtin and the <code>select</code> complex command may set <code>REPLY</code>, and filename generation both sets and examines its value when evaluating certain expressions. Some modules also employ <code>REPLY</code> for similar purposes.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarREPORTMEMORY">
<h3><code>$REPORTMEMORY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarREPORTMEMORY">¶</a></h3>
<p>If nonnegative, commands whose maximum resident set size (roughly speaking, main memory usage) in kilobytes is greater than this value have timing statistics reported. The format used to output statistics is the value of the <code>TIMEFMT</code> parameter, which is the same as for the <code>REPORTTIME</code> variable and the <code>time</code> builtin; note that by default this does not output memory usage. Appending <code>" max RSS %M"</code> to the value of <code>TIMEFMT</code> causes it to output the value that triggered the report. If <code>REPORTTIME</code> is also in use, at most a single report is printed for both triggers. This feature requires the tt(getrusage+()) system call, commonly supported by modern Unix-like systems.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarREPORTTIME">
<h3><code>$REPORTTIME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarREPORTTIME">¶</a></h3>
<p>If nonnegative, commands whose combined user and system execution times (measured in seconds) are greater than this value have timing statistics printed for them. Output is suppressed for commands executed within the line editor, including completion; commands explicitly marked with the <code>time</code> keyword still cause the summary to be printed in this case.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarRPS1">
<h3><code>$RPS1</code> <a class="doc-anchor" href="#doc-lsp-special-dollarRPS1">¶</a></h3>
<p>This prompt is displayed on the right-hand side of the screen when the primary prompt is being displayed on the left. This does not work if the <code>SINGLE_LINE_ZLE</code> option is set. It is expanded in the same way as <code>PS1</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarRPS2">
<h3><code>$RPS2</code> <a class="doc-anchor" href="#doc-lsp-special-dollarRPS2">¶</a></h3>
<p>This prompt is displayed on the right-hand side of the screen when the secondary prompt is being displayed on the left. This does not work if the <code>SINGLE_LINE_ZLE</code> option is set. It is expanded in the same way as <code>PS2</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSAVEHIST">
<h3><code>$SAVEHIST</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSAVEHIST">¶</a></h3>
<p>The maximum number of history events to save in the history file.</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSECONDS">
<h3><code>$SECONDS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSECONDS">¶</a></h3>
<p>The number of seconds since shell invocation. On most platforms, this is a monotonic value, so it is not affected by NTP time jumps or other clock changes (though it may be affected by slewing). If this parameter is assigned a value, then the value returned upon reference will be the value that was assigned plus the number of seconds since the assignment.</p>
<p>Unlike other special parameters, the type of the <code>SECONDS</code> parameter can be changed using the <code>typeset</code> command. The type may be changed only to one of the floating point types or back to integer. For example, "typeset -F SECONDS" causes the value to be reported as a floating point number. The value is nominally available to nanosecond precision, although this varies by platform (and probably isn't accurate to 1 ns regardless), and the shell may show more or fewer digits depending on the use of <code>typeset</code>. See the documentation for the builtin <code>typeset</code> in nmref(Shell Builtin Commands)(zshbuiltins) for more details.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSHLVL">
<h3><code>$SHLVL</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSHLVL">¶</a></h3>
<p>Incremented by one each time a new shell is started.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSPROMPT">
<h3><code>$SPROMPT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSPROMPT">¶</a></h3>
<p>The prompt used for spelling correction. The sequence "%R" expands to the string which presumably needs spelling correction, and "%r" expands to the proposed correction. All other prompt escapes are also allowed.</p>
<p>The actions available at the prompt are <code>[nyae]</code>:</p>
<p>- <strong><code>n</code> +("no"+) +(default+)</strong> — Discard the correction. If there are no more corrections, accept the command line, else (with <code>CORRECT_ALL</code>) prompt for the next.</p>
<p>- <strong><code>y</code> +("yes"+)</strong> — Make the correction. If there are no more corrections, accept the command line.</p>
<p>- <strong><code>a</code> +("abort"+)</strong> — Place the entire command line in the history for later edit, but without accepting it.</p>
<p>- <strong><code>e</code> +("edit"+)</strong> — Resume editing the command line.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSRANDOM">
<h3><code>$SRANDOM</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSRANDOM">¶</a></h3>
<p>A random positive 32-bit integer between 0 and 4,294,967,295. This parameter is read-only. The name was chosen for compatibility with Bash and to distinguish it from <code>RANDOM</code> which has a documented repeatable behavior.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSTTY">
<h3><code>$STTY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSTTY">¶</a></h3>
<p>If this parameter is set in a command's environment, the shell runs the <code>stty</code> command with the value of this parameter as arguments in order to set up the terminal before executing the command. The modes apply only to the command, and are reset when it finishes or is suspended. If the command is suspended and continued later with the <code>fg</code> or <code>wait</code> builtins it will see the modes specified by <code>STTY</code>, as if it were not suspended. This (intentionally) does not apply if the command is continued via <code></code>kill -CONT<code>'. </code>STTY<code> is ignored if the command is run in the background, or if it is in the environment of the shell but not explicitly assigned to in the input line. This avoids running stty at every external command by accidentally exporting it. Also note that </code>STTY<code> should not be used for window size specifications; these will not be local to the command.</code></p>
<p>If the parameter is set and empty, all of the above applies except that <code>stty</code> is not run. This can be useful as a way to freeze the tty around a single command, blocking its changes to tty settings, similar to the <code>ttyctl</code> builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarSUFFIX_END">
<h3><code>$SUFFIX_END</code> <a class="doc-anchor" href="#doc-lsp-special-dollarSUFFIX_END">¶</a></h3>
<p><code>SUFFIX_ACTIVE</code> indicates whether an auto-removable completion suffix is currently active. <code>SUFFIX_START</code> and <code>SUFFIX_END</code> give the location of the suffix and are in the same units as <code>CURSOR</code>. They are only valid for reading when <code>SUFFIX_ACTIVE</code> is non-zero.</p>
<p>All parameters are read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTERM">
<h3><code>$TERM</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTERM">¶</a></h3>
<p>The type of terminal in use. This is used when looking up termcap sequences. An assignment to <code>TERM</code> causes zsh to re-initialize the terminal, even if the value does not change (e.g., "TERM=$TERM"). It is necessary to make such an assignment upon any change to the terminal definition database or terminal type in order for the new settings to take effect.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTERMINFO">
<h3><code>$TERMINFO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTERMINFO">¶</a></h3>
<p>A reference to your terminfo database, used by the "terminfo" library when the system has it; see manref(terminfo)(5). If set, this causes the shell to reinitialise the terminal, making the workaround "TERM=$TERM" unnecessary.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTERMINFO_DIRS">
<h3><code>$TERMINFO_DIRS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTERMINFO_DIRS">¶</a></h3>
<p>A colon-seprarated list of terminfo databases, used by the "terminfo" library when the system has it; see manref(terminfo)(5). This variable is only used by certain terminal libraries, in particular ncurses; see manref(terminfo)(5) to check support on your system. If set, this causes the shell to reinitialise the terminal, making the workaround "TERM=$TERM" unnecessary. Note that unlike other colon-separated arrays this is not tied to a zsh array.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTIMEFMT">
<h3><code>$TIMEFMT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTIMEFMT">¶</a></h3>
<p>The format of process time reports with the <code>time</code> keyword. The default is "%J %U user %S system %P cpu %*E total". Recognizes the following escape sequences, although not all may be available on all systems, and some that are available may not be useful:</p>
<p>- <code>%%</code> — A "%". - <code>%U</code> — CPU seconds spent in user mode. - <code>%S</code> — CPU seconds spent in kernel mode. - <code>%E</code> — Elapsed time in seconds.</p>
<p>- <strong><code>%P</code></strong> — The CPU percentage, computed as 100*(<code>%U</code>+<code>%S</code>)/<code>%E</code>.</p>
<p>- <code>%W</code> — Number of times the process was swapped.</p>
<p>- <strong><code>%X</code></strong> — The average amount in (shared) text space used in kilobytes.</p>
<p>- <strong><code>%D</code></strong> — The average amount in (unshared) data/stack space used in kilobytes.</p>
<p>- <strong><code>%K</code></strong> — The total space used (<code>%X</code>+<code>%D</code>) in kilobytes.</p>
<p>- <code>%M</code> — The maximum memory the process had in use at any time in kilobytes.</p>
<p>- <strong><code>%F</code></strong> — The number of major page faults (page needed to be brought from disk).</p>
<p>- <code>%R</code> — The number of minor page faults. - <code>%I</code> — The number of input operations. - <code>%O</code> — The number of output operations. - <code>%r</code> — The number of socket messages received. - <code>%s</code> — The number of socket messages sent. - <code>%k</code> — The number of signals received.</p>
<p>- <strong><code>%w</code></strong> — Number of voluntary context switches (waits).</p>
<p>- <code>%c</code> — Number of involuntary context switches. - <code>%J</code> — The name of this job.</p>
<p>A star may be inserted between the percent sign and flags printing time (e.g., "%*E"); this causes the time to be printed in <code>_hh_</code>:<code>_mm_</code>:<code>_ss_</code>."<em>ttt</em>" format (hours and minutes are only printed if they are not zero). Alternatively, "m", "u", or "n" may be used (e.g., "%mE") to produce time output in milliseconds, microseconds, or nanoseconds, respectively. Note that some timings on some platforms are not actually nanosecond-precise (nor accurate to 1 ns when they are); in fact on many systems user and kernel times are not even microsecond-precise.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTMOUT">
<h3><code>$TMOUT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTMOUT">¶</a></h3>
<p>If this parameter is nonzero, the shell will receive an <code>ALRM</code> signal if a command is not entered within the specified number of seconds after issuing a prompt. If there is a trap on <code>SIGALRM</code>, it will be executed and a new alarm is scheduled using the value of the <code>TMOUT</code> parameter after executing the trap. If no trap is set, and the idle time of the terminal is not less than the value of the <code>TMOUT</code> parameter, zsh terminates. Otherwise a new alarm is scheduled to <code>TMOUT</code> seconds after the last keypress.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTMPPREFIX">
<h3><code>$TMPPREFIX</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTMPPREFIX">¶</a></h3>
<p>A pathname prefix which the shell will use for all temporary files. Note that this should include an initial part for the file name as well as any directory names. The default is "/tmp/zsh".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTMPSUFFIX">
<h3><code>$TMPSUFFIX</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTMPSUFFIX">¶</a></h3>
<p>A filename suffix which the shell will use for temporary files created by process substitutions (e.g., <code>tt(=()_list_</code>")"). Note that the value should include a leading dot "." if intended to be interpreted as a file extension. The default is not to append any suffix, thus this parameter should be assigned only when needed and then unset again.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTRY_BLOCK_ERROR">
<h3><code>$TRY_BLOCK_ERROR</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTRY_BLOCK_ERROR">¶</a></h3>
<p>In an <code>always</code> block, indicates whether the preceding list of code caused an error. The value is 1 to indicate an error, 0 otherwise. It may be reset, clearing the error condition. See <em>Complex Commands</em> (zshmisc)</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTRY_BLOCK_INTERRUPT">
<h3><code>$TRY_BLOCK_INTERRUPT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTRY_BLOCK_INTERRUPT">¶</a></h3>
<p>This variable works in a similar way to <code>TRY_BLOCK_ERROR</code>, but represents the status of an interrupt from the signal SIGINT, which typically comes from the keyboard when the user types <code>^C</code>. If set to 0, any such interrupt will be reset; otherwise, the interrupt is propagated after the <code>always</code> block.</p>
<p>Note that it is possible that an interrupt arrives during the execution of the <code>always</code> block; this interrupt is also propagated.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTTY">
<h3><code>$TTY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTTY">¶</a></h3>
<p>The name of the tty associated with the shell, if any.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarTTYIDLE">
<h3><code>$TTYIDLE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarTTYIDLE">¶</a></h3>
<p>The idle time of the tty associated with the shell in seconds or -1 if there is no such tty.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarUID">
<h3><code>$UID</code> <a class="doc-anchor" href="#doc-lsp-special-dollarUID">¶</a></h3>
<p>The real user ID of the shell process. If you have sufficient privileges, you may change the user ID of the shell by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different user ID by <code>tt((UID=)_uid_</code>; command+")"</p>
<p>If this is made local, it is not implicitly set to 0, but may be explicitly set locally.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarUNDO_CHANGE_NO">
<h3><code>$UNDO_CHANGE_NO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarUNDO_CHANGE_NO">¶</a></h3>
<p>A number representing the state of the undo history. The only use of this is passing as an argument to the <code>undo</code> widget in order to undo back to the recorded point. Read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarUNDO_LIMIT_NO">
<h3><code>$UNDO_LIMIT_NO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarUNDO_LIMIT_NO">¶</a></h3>
<p>A number corresponding to an existing change in the undo history; compare <code>UNDO_CHANGE_NO</code>. If this is set to a value greater than zero, the <code>undo</code> command will not allow the line to be undone beyond the given change number. It is still possible to use <code></code>zle undo" <em>change</em>" in a widget to undo beyond that point; in that case, it will not be possible to undo at all until <code>UNDO_LIMIT_NO</code> is reduced. Set to 0 to disable the limit.</p>
<p>A typical use of this variable in a widget function is as follows (note the additional function scope is required):</p>
<p>example(() { local UNDO_LIMIT_NO=$UNDO_CHANGE_NO # Perform some form of recursive edit. })</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarUSERNAME">
<h3><code>$USERNAME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarUSERNAME">¶</a></h3>
<p>The username corresponding to the real user ID of the shell process. If you have sufficient privileges, you may change the username (and also the user ID and group ID) of the shell by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different username (and user ID and group ID) by <code>tt((USERNAME=)_username_</code>; command+")"</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarVENDOR">
<h3><code>$VENDOR</code> <a class="doc-anchor" href="#doc-lsp-special-dollarVENDOR">¶</a></h3>
<p>The vendor, as determined at compile time.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarWATCHFMT">
<h3><code>$WATCHFMT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarWATCHFMT">¶</a></h3>
<p>The format of login/logout reports if the <code>watch</code> parameter is set. Default is "%n has %a %l from %m". Recognizes the following escape sequences:</p>
<p>- <strong><code>%n</code></strong> — The name of the user that logged in/out.</p>
<p>- <strong><code>%a</code></strong> — The observed action, i.e. "logged on" or "logged off".</p>
<p>- <strong><code>%l</code></strong> — The line (tty) the user is logged in on.</p>
<p>- <strong><code>%M</code></strong> — The full hostname of the remote host.</p>
<p>- <strong><code>%m</code></strong> — The hostname up to the first ".". If only the IP address is available or the utmp field contains the name of an X-windows display, the whole name is printed.</p>
<p><em>NOTE:</em> The "%m" and "%M" escapes will work only if there is a host name field in the utmp on your machine. Otherwise they are treated as ordinary strings.</p>
<p>- <strong><code>%F{</code><em>color</em><code>}</code> (<code>%f</code>)</strong> — Start (stop) using a different foreground color.</p>
<p>- <strong><code>%K{</code><em>color</em><code>}</code> (<code>%k</code>)</strong> — Start (stop) using a different background color.</p>
<p>- <strong><code>%S</code> (<code>%s</code>)</strong> — Start (stop) standout mode.</p>
<p>- <strong><code>%U</code> (<code>%u</code>)</strong> — Start (stop) underline mode.</p>
<p>- <strong><code>%B</code> (<code>%b</code>)</strong> — Start (stop) boldface mode.</p>
<p>- <strong><code>%t</code></strong></p>
<p>- <strong><code>%@</code></strong> — The time, in 12-hour, am/pm format.</p>
<p>- <strong><code>%T</code></strong> — The time, in 24-hour format.</p>
<p>- <strong><code>%w</code></strong> — The date in <code>_day_</code>-"<em>dd</em>" format.</p>
<p>- <strong><code>%W</code></strong> — The date in <code>_mm_</code>/<code>_dd_</code>/"<em>yy</em>" format.</p>
<p>- <strong><code>%D</code></strong> — The date in <code>_yy_</code>-<code>_mm_</code>-"<em>dd</em>" format.</p>
<p>- <strong><code>%D{</code><em>string</em><code>}</code></strong> — The date formatted as <em>string</em> using the <code>strftime</code> function, with zsh extensions as described for <code>%D{</code><em>string</em><code>}</code> escape sequence in <em>Simple Prompt Escapes</em> (zshmisc).</p>
<p>- <strong><code>%()_x_</code>:<code>_true-text_</code>:<code>_false-text_</code><code></code></strong> — Specifies a ternary expression. The character following the <em>x</em> is arbitrary; the same character is used to separate the text for the "true" result from that for the "false" result. Both the separator and the right parenthesis may be escaped with a backslash. Ternary expressions may be nested.</p>
<p>The test character <em>x</em> may be any one of "l", "n", "m" or "M", which indicate a "true" result if the corresponding escape sequence would return a non-empty value; or it may be "a", which indicates a "true" result if the watched user has logged in, or "false" if he has logged out. Other characters evaluate to neither true nor false; the entire expression is omitted in this case.</p>
<p>If the result is "true", then the <em>true-text</em> is formatted according to the rules above and printed, and the <em>false-text</em> is skipped. If "false", the <em>true-text</em> is skipped and the <em>false-text</em> is formatted and printed. Either or both of the branches may be empty, but both separators must be present in any case.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarWIDGET">
<h3><code>$WIDGET</code> <a class="doc-anchor" href="#doc-lsp-special-dollarWIDGET">¶</a></h3>
<p>The name of the widget currently being executed; read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarWIDGETFUNC">
<h3><code>$WIDGETFUNC</code> <a class="doc-anchor" href="#doc-lsp-special-dollarWIDGETFUNC">¶</a></h3>
<p>The name of the shell function that implements a widget defined with either <code>zle -N</code> or <code>zle -C</code>. In the former case, this is the second argument to the <code>zle -N</code> command that defined the widget, or the first argument if there was no second argument. In the latter case this is the third argument to the <code>zle -C</code> command that defined the widget. Read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarWIDGETSTYLE">
<h3><code>$WIDGETSTYLE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarWIDGETSTYLE">¶</a></h3>
<p>Describes the implementation behind the completion widget currently being executed; the second argument that followed <code>zle -C</code> when the widget was defined. This is the name of a builtin completion widget. For widgets defined with <code>zle -N</code> this is set to the empty string. Read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarWORDCHARS">
<h3><code>$WORDCHARS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarWORDCHARS">¶</a></h3>
<p>A list of non-alphanumeric characters considered part of a word by the line editor.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarYANK_END">
<h3><code>$YANK_END</code> <a class="doc-anchor" href="#doc-lsp-special-dollarYANK_END">¶</a></h3>
<p><code>YANK_ACTIVE</code> indicates whether text has just been yanked (pasted) into the buffer. <code>YANK_START</code> and <code>YANK_END</code> give the location of the pasted text and are in the same units as <code>CURSOR</code>. They are only valid for reading when <code>YANK_ACTIVE</code> is non-zero. They can also be assigned by widgets that insert text in a yank-like fashion, for example wrappers of <code>bracketed-paste</code>. See also <code>zle -f</code>.</p>
<p><code>YANK_ACTIVE</code> is read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZBEEP">
<h3><code>$ZBEEP</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZBEEP">¶</a></h3>
<p>If set, this gives a string of characters, which can use all the same codes as the <code>bindkey</code> command as described in <em>The zsh/zle Module</em> (zshmodules), that will be output to the terminal instead of beeping. This may have a visible instead of an audible effect; for example, the string "\e[?5h\e[?5l" on a vt100 or xterm will have the effect of flashing reverse video on and off (if you usually use reverse video, you should use the string "\e[?5l\e[?5h" instead). This takes precedence over the <code>NOBEEP</code> option.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZCURSES_COLORS">
<h3><code>$ZCURSES_COLORS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZCURSES_COLORS">¶</a></h3>
<p>Readonly integer. The maximum number of colors the terminal supports. This value is initialised by the curses library and is not available until the first time <code>zcurses init</code> is run.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZCURSES_COLOR_PAIRS">
<h3><code>$ZCURSES_COLOR_PAIRS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZCURSES_COLOR_PAIRS">¶</a></h3>
<p>Readonly integer. The maximum number of color pairs _fg_col_<code>/</code>_bg_col_ that may be defined in "zcurses attr" commands; note this limit applies to all color pairs that have been used whether or not they are currently active. This value is initialised by the curses library and is not available until the first time <code>zcurses init</code> is run.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZDOTDIR">
<h3><code>$ZDOTDIR</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZDOTDIR">¶</a></h3>
<p>The directory to search for shell startup files (.zshrc, etc), if not <code>$HOME</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_ACCOUNT">
<h3><code>$ZFTP_ACCOUNT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_ACCOUNT">¶</a></h3>
<p>Readonly. The account name of the current user, if any. Most servers do not require an account name.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_CODE">
<h3><code>$ZFTP_CODE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_CODE">¶</a></h3>
<p>Readonly. The three digit code of the last FTP reply from the server as a string. This can still be read after the connection is closed, and is not changed when the current session changes.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_COUNT">
<h3><code>$ZFTP_COUNT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_COUNT">¶</a></h3>
<p>The amount of data so far transferred; a number between zero and <code>$ZFTP_SIZE</code>, if that is set. This number is always available.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_FILE">
<h3><code>$ZFTP_FILE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_FILE">¶</a></h3>
<p>The name of the remote file being transferred from or to.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_HOST">
<h3><code>$ZFTP_HOST</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_HOST">¶</a></h3>
<p>Readonly. The hostname of the current remote server. If the host was opened as an IP number, <code>ZFTP_HOST</code> contains that instead; this saves the overhead for a name lookup, as IP numbers are most commonly used when a nameserver is unavailable.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_IP">
<h3><code>$ZFTP_IP</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_IP">¶</a></h3>
<p>Readonly. The IP address of the current connection in dot notation.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_PORT">
<h3><code>$ZFTP_PORT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_PORT">¶</a></h3>
<p>Readonly. The number of the remote TCP port to which the connection is open (even if the port was originally specified as a named service). Usually this is the standard FTP port, 21.</p>
<p>In the unlikely event that your system does not have the appropriate conversion functions, this appears in network byte order. If your system is little-endian, the port then consists of two swapped bytes and the standard port will be reported as 5376. In that case, numeric ports passed to <code>zftp open</code> will also need to be in this format.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_PREFS">
<h3><code>$ZFTP_PREFS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_PREFS">¶</a></h3>
<p>A string of preferences for altering aspects of <code>zftp</code>'s behaviour. Each preference is a single character. The following are defined:</p>
<p>- <strong><code>P</code></strong> — Passive: attempt to make the remote server initiate data transfers. This is slightly more efficient than sendport mode. If the letter <code>S</code> occurs later in the string, <code>zftp</code> will use sendport mode if passive mode is not available.</p>
<p>- <strong><code>S</code></strong> — Sendport: initiate transfers by the FTP <code>PORT</code> command. If this occurs before any <code>P</code> in the string, passive mode will never be attempted.</p>
<p>- <strong><code>D</code></strong> — Dumb: use only the bare minimum of FTP commands. This prevents the variables <code>ZFTP_SYSTEM</code> and <code>ZFTP_PWD</code> from being set, and will mean all connections default to ASCII type. It may prevent <code>ZFTP_SIZE</code> from being set during a transfer if the server does not send it anyway (many servers do).</p>
<p>If <code>ZFTP_PREFS</code> is not set when <code>zftp</code> is loaded, it will be set to a default of "PS", i.e. use passive mode if available, otherwise fall back to sendport mode.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_PWD">
<h3><code>$ZFTP_PWD</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_PWD">¶</a></h3>
<p>Readonly. The current directory on the server.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_REPLY">
<h3><code>$ZFTP_REPLY</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_REPLY">¶</a></h3>
<p>Readonly. The last line of the last reply sent by the server. This can still be read after the connection is closed, and is not changed when the current session changes.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_SESSION">
<h3><code>$ZFTP_SESSION</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_SESSION">¶</a></h3>
<p>Readonly. The name of the current FTP session; see the description of the <code>session</code> subcommand.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_SIZE">
<h3><code>$ZFTP_SIZE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_SIZE">¶</a></h3>
<p>The total size of the complete file being transferred: the same as the first value provided by the <code>remote</code> and <code>local</code> subcommands for a particular file. If the server cannot supply this value for a remote file being retrieved, it will not be set. If input is from a pipe the value may be incorrect and correspond simply to a full pipe buffer.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_SYSTEM">
<h3><code>$ZFTP_SYSTEM</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_SYSTEM">¶</a></h3>
<p>Readonly. The system type string returned by the server in response to an FTP <code>SYST</code> request. The most interesting case is a string beginning <code>"UNIX Type: L8"</code>, which ensures maximum compatibility with a local UNIX host.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_TMOUT">
<h3><code>$ZFTP_TMOUT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_TMOUT">¶</a></h3>
<p>Integer. The time in seconds to wait for a network operation to complete before returning an error. If this is not set when the module is loaded, it will be given the default value 60. A value of zero turns off timeouts. If a timeout occurs on the control connection it will be closed. Use a larger value if this occurs too frequently.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_TRANSFER">
<h3><code>$ZFTP_TRANSFER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_TRANSFER">¶</a></h3>
<p>A <code>G</code> for a <code>get</code> operation and a <code>P</code> for a <code>put</code> operation.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_TYPE">
<h3><code>$ZFTP_TYPE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_TYPE">¶</a></h3>
<p>Readonly. The type to be used for data transfers , either "A" or "I". Use the <code>type</code> subcommand to change this.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_USER">
<h3><code>$ZFTP_USER</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_USER">¶</a></h3>
<p>Readonly. The username currently logged in, if any.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZFTP_VERBOSE">
<h3><code>$ZFTP_VERBOSE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZFTP_VERBOSE">¶</a></h3>
<p>A string of digits between 0 and 5 inclusive, specifying which responses from the server should be printed. All responses go to standard error. If any of the numbers 1 to 5 appear in the string, raw responses from the server with reply codes beginning with that digit will be printed to standard error. The first digit of the three digit reply code is defined by RFC959 to correspond to:</p>
<p>- <strong>1.</strong> — A positive preliminary reply.</p>
<p>- <strong>2.</strong> — A positive completion reply.</p>
<p>- <strong>3.</strong> — A positive intermediate reply.</p>
<p>- <strong>4.</strong> — A transient negative completion reply.</p>
<p>- <strong>5.</strong> — A permanent negative completion reply.</p>
<p>It should be noted that, for unknown reasons, the reply <code>Service not available', which forces termination of a connection, is classified as 421, i.e. "transient negative", an interesting interpretation of the word "transient".</code></p>
<p>The code 0 is special: it indicates that all but the last line of multiline replies read from the server will be printed to standard error in a processed format. By convention, servers use this mechanism for sending information for the user to read. The appropriate reply code, if it matches the same response, takes priority.</p>
<p>If <code>ZFTP_VERBOSE</code> is not set when <code>zftp</code> is loaded, it will be set to the default value <code>450</code>, i.e., messages destined for the user and all errors will be printed. A null string is valid and specifies that no messages should be printed.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZLE_LINE_ABORTED">
<h3><code>$ZLE_LINE_ABORTED</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZLE_LINE_ABORTED">¶</a></h3>
<p>This parameter is set by the line editor when an error occurs. It contains the line that was being edited at the point of the error. "print -zr -- $ZLE_LINE_ABORTED" can be used to recover the line. Only the most recent line of this kind is remembered.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZLE_RECURSIVE">
<h3><code>$ZLE_RECURSIVE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZLE_RECURSIVE">¶</a></h3>
<p>Usually zero, but incremented inside any instance of <code>recursive-edit</code>. Hence indicates the current recursion level.</p>
<p><code>ZLE_RECURSIVE</code> is read-only.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZLE_RPROMPT_INDENT">
<h3><code>$ZLE_RPROMPT_INDENT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZLE_RPROMPT_INDENT">¶</a></h3>
<p>If set, used to give the indentation between the right hand side of the right prompt in the line editor as given by <code>RPS1</code> or <code>RPROMPT</code> and the right hand side of the screen. If not set, the value 1 is used.</p>
<p>Typically this will be used to set the value to 0 so that the prompt appears flush with the right hand side of the screen. This is not the default as many terminals do not handle this correctly, in particular when the prompt appears at the extreme bottom right of the screen. Recent virtual terminals are more likely to handle this case correctly. Some experimentation is necessary.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZLE_SPACE_SUFFIX_CHARS">
<h3><code>$ZLE_SPACE_SUFFIX_CHARS</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZLE_SPACE_SUFFIX_CHARS">¶</a></h3>
<p>These parameters are used by the line editor. In certain circumstances suffixes (typically space or slash) added by the completion system will be removed automatically, either because the next editing command was not an insertable character, or because the character was marked as requiring the suffix to be removed.</p>
<p>These variables can contain the sets of characters that will cause the suffix to be removed. If <code>ZLE_REMOVE_SUFFIX_CHARS</code> is set, those characters will cause the suffix to be removed; if <code>ZLE_SPACE_SUFFIX_CHARS</code> is set, those characters will cause the suffix to be removed and replaced by a space.</p>
<p>If <code>ZLE_REMOVE_SUFFIX_CHARS</code> is not set, the default behaviour is equivalent to:</p>
<p> ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'</p>
<p>If <code>ZLE_REMOVE_SUFFIX_CHARS</code> is set but is empty, no characters have this behaviour. <code>ZLE_SPACE_SUFFIX_CHARS</code> takes precedence, so that the following:</p>
<p> ZLE_SPACE_SUFFIX_CHARS=$'&|'</p>
<p>causes the characters "&" and "|" to remove the suffix but to replace it with a space.</p>
<p>To illustrate the difference, suppose that the option <code>AUTO_REMOVE_SLASH</code> is in effect and the directory <code>DIR</code> has just been completed, with an appended <code>/</code>, following which the user types "&". The default result is "DIR&". With <code>ZLE_REMOVE_SUFFIX_CHARS</code> set but without including "&" the result is "DIR/&". With <code>ZLE_SPACE_SUFFIX_CHARS</code> set to include "&" the result is "DIR &".</p>
<p>Note that certain completions may provide their own suffix removal or replacement behaviour which overrides the values described here. See the completion system documentation in nmref(Completion System)(zshcompsys).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZLE_STATE">
<h3><code>$ZLE_STATE</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZLE_STATE">¶</a></h3>
<p>Contains a set of space-separated words that describe the current <code>zle</code> state.</p>
<p>Currently, the states shown are the insert mode as set by the <code>overwrite-mode</code> or <code>vi-replace</code> widgets and whether history commands will visit imported entries as controlled by the set-local-history widget. The string contains "insert" if characters to be inserted on the command line move existing characters to the right or "overwrite" if characters to be inserted overwrite existing characters. It contains "localhistory" if only local history commands will be visited or "globalhistory" if imported history commands will also be visited.</p>
<p>The substrings are sorted in alphabetical order so that if you want to test for two specific substrings in a future-proof way, you can do match by doing:</p>
<p> if [[ $ZLE_STATE == *globalhistory*insert* ]]; then ...; fi</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_ARGZERO">
<h3><code>$ZSH_ARGZERO</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_ARGZERO">¶</a></h3>
<p>If zsh was invoked to run a script, this is the name of the script. Otherwise, it is the name used to invoke the current shell. This is the same as the value of <code>$0</code> when the <code>POSIX_ARGZERO</code> option is set, but is always available.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_EXECUTION_STRING">
<h3><code>$ZSH_EXECUTION_STRING</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_EXECUTION_STRING">¶</a></h3>
<p>If the shell was started with the option <code>-c</code>, this contains the argument passed to the option. Otherwise it is not set.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_EXEPATH">
<h3><code>$ZSH_EXEPATH</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_EXEPATH">¶</a></h3>
<p>Full pathname of the executable file of the current zsh process.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_NAME">
<h3><code>$ZSH_NAME</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_NAME">¶</a></h3>
<p>Expands to the basename of the command used to invoke this instance of zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_PATCHLEVEL">
<h3><code>$ZSH_PATCHLEVEL</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_PATCHLEVEL">¶</a></h3>
<p>The output of "git describe --tags --long" for the zsh repository used to build the shell. This is most useful in order to keep track of versions of the shell during development between releases; hence most users should not use it and should instead rely on <code>$ZSH_VERSION</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_SCRIPT">
<h3><code>$ZSH_SCRIPT</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_SCRIPT">¶</a></h3>
<p>If zsh was invoked to run a script, this is the name of the script, otherwise it is unset.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_SUBSHELL">
<h3><code>$ZSH_SUBSHELL</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_SUBSHELL">¶</a></h3>
<p>Readonly integer. Initially zero, incremented each time the shell forks to create a subshell for executing code. Hence "tt((print $ZSH_SUBSHELL))" and "tt(print $(print $ZSH_SUBSHELL))" output 1, while "tt(( (print $ZSH_SUBSHELL) ))" outputs 2.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarZSH_VERSION">
<h3><code>$ZSH_VERSION</code> <a class="doc-anchor" href="#doc-lsp-special-dollarZSH_VERSION">¶</a></h3>
<p>The version number of the release of zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollar_">
<h3><code>$_</code> <a class="doc-anchor" href="#doc-lsp-special-dollar_">¶</a></h3>
<p>Initially, if <code>_</code> exists in the environment, then this parameter is set to its value. This value may be the full pathname of the current zsh executable or the script command file. Later, this parameter is set to the last argument of the previous command. Also, this parameter is set in the environment of every command executed to the full pathname of the command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollaraliases">
<h3><code>$aliases</code> <a class="doc-anchor" href="#doc-lsp-special-dollaraliases">¶</a></h3>
<p>This maps the names of the regular aliases currently enabled to their expansions.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarargv">
<h3><code>$argv</code> <a class="doc-anchor" href="#doc-lsp-special-dollarargv">¶</a></h3>
<p>Same as <code>*</code>. Assigning to <code>argv</code> changes the local positional parameters, but <code>argv</code> is <em>not</em> itself a local parameter. Deleting <code>argv</code> with <code>unset</code> in any function deletes it everywhere. This can be avoided by declaring "local +h argv" before unsetting. Even when not so declared, only the innermost positional parameter array is deleted (so <code>*</code> and <code>@</code> in other scopes are not affected).</p>
<p>A named reference to <code>argv</code> <em>does not</em> permit a called function to access the positional parameters of its caller.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarbuiltins">
<h3><code>$builtins</code> <a class="doc-anchor" href="#doc-lsp-special-dollarbuiltins">¶</a></h3>
<p>This associative array gives information about the builtin commands currently enabled. The keys are the names of the builtin commands and the values are either "undefined" for builtin commands that will automatically be loaded from a module if invoked or "defined" for builtin commands that are already loaded.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarcdpath">
<h3><code>$cdpath</code> <a class="doc-anchor" href="#doc-lsp-special-dollarcdpath">¶</a></h3>
<p>An array (colon-separated list) of directories specifying the search path for the <code>cd</code> command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarcommands">
<h3><code>$commands</code> <a class="doc-anchor" href="#doc-lsp-special-dollarcommands">¶</a></h3>
<p>This array gives access to the command hash table. The keys are the names of external commands, the values are the pathnames of the files that would be executed when the command would be invoked. Setting a key in this array defines a new entry in this table in the same way as with the <code>hash</code> builtin. Unsetting a key as in <code></code>unset "commands[foo]"<code>' removes the entry for the given key from the command hash table.</code></p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardirstack">
<h3><code>$dirstack</code> <a class="doc-anchor" href="#doc-lsp-special-dollardirstack">¶</a></h3>
<p>A normal array holding the elements of the directory stack. Note that the output of the <code>dirs</code> builtin command includes one more directory, the current working directory.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_aliases">
<h3><code>$dis_aliases</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_aliases">¶</a></h3>
<p>Like <code>aliases</code> but for disabled regular aliases.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_builtins">
<h3><code>$dis_builtins</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_builtins">¶</a></h3>
<p>Like <code>builtins</code> but for disabled builtin commands.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_functions">
<h3><code>$dis_functions</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_functions">¶</a></h3>
<p>Like <code>functions</code> but for disabled functions.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_functions_source">
<h3><code>$dis_functions_source</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_functions_source">¶</a></h3>
<p>Like <code>functions_source</code> but for disabled functions.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_galiases">
<h3><code>$dis_galiases</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_galiases">¶</a></h3>
<p>Like <code>galiases</code> but for disabled global aliases.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_patchars">
<h3><code>$dis_patchars</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_patchars">¶</a></h3>
<p>Like <code>patchars</code> but for disabled pattern characters.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_reswords">
<h3><code>$dis_reswords</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_reswords">¶</a></h3>
<p>Like <code>reswords</code> but for disabled reserved words.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollardis_saliases">
<h3><code>$dis_saliases</code> <a class="doc-anchor" href="#doc-lsp-special-dollardis_saliases">¶</a></h3>
<p>Like <code>saliases</code> but for disabled suffix aliases.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarepochtime">
<h3><code>$epochtime</code> <a class="doc-anchor" href="#doc-lsp-special-dollarepochtime">¶</a></h3>
<p>An array value containing the number of seconds since the epoch in the first element and the remainder of the time since the epoch in nanoseconds in the second element. To ensure the two elements are consistent the array should be copied or otherwise referenced as a single substitution before the values are used. The following idiom may be used:</p>
<p> for secs nsecs in $epochtime; do ... done</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarerrnos">
<h3><code>$errnos</code> <a class="doc-anchor" href="#doc-lsp-special-dollarerrnos">¶</a></h3>
<p>A readonly array of the names of errors defined on the system. These are typically macros defined in C by including the system header file <code>errno.h</code>. The index of each name (assuming the option <code>KSH_ARRAYS</code> is unset) corresponds to the error number. Error numbers <em>num</em> before the last known error which have no name are given the name <code>E</code><em>num</em> in the array.</p>
<p>Note that aliases for errors are not handled; only the canonical name is used.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfignore">
<h3><code>$fignore</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfignore">¶</a></h3>
<p>An array (colon separated list) containing the suffixes of files to be ignored during filename completion. However, if completion only generates files with suffixes in this list, then these files are completed anyway.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfpath">
<h3><code>$fpath</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfpath">¶</a></h3>
<p>An array (colon separated list) of directories specifying the search path for function definitions. This path is searched when a function with the <code>-u</code> attribute is referenced. If an executable file is found, then it is read and executed in the current environment.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfuncfiletrace">
<h3><code>$funcfiletrace</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfuncfiletrace">¶</a></h3>
<p>This array contains the absolute line numbers and corresponding file names for the point where the current function, sourced file, or (if <code>EVAL_LINENO</code> is set) <code>eval</code> command was called. The array is of the same length as <code>funcsourcetrace</code> and <code>functrace</code>, but differs from <code>funcsourcetrace</code> in that the line and file are the point of call, not the point of definition, and differs from <code>functrace</code> in that all values are absolute line numbers in files, rather than relative to the start of a function, if any.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfuncsourcetrace">
<h3><code>$funcsourcetrace</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfuncsourcetrace">¶</a></h3>
<p>This array contains the file names and line numbers of the points where the functions, sourced files, and (if <code>EVAL_LINENO</code> is set) <code>eval</code> commands currently being executed were defined. The line number is the line where the <code></code>function" <em>name</em>" or "<em>name</em> tt(())" started. In the case of an autoloaded function the line number is reported as zero. The format of each element is <em>filename</em><code>:</code><em>lineno</em>.</p>
<p>For functions autoloaded from a file in native zsh format, where only the body of the function occurs in the file, or for files that have been executed by the <code>source</code> or "." builtins, the trace information is shown as <em>filename</em><code>:</code><em>0</em>, since the entire file is the definition. The source file name is resolved to an absolute path when the function is loaded or the path to it otherwise resolved.</p>
<p>Most users will be interested in the information in the <code>funcfiletrace</code> array instead.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfuncstack">
<h3><code>$funcstack</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfuncstack">¶</a></h3>
<p>This array contains the names of the functions, sourced files, and (if <code>EVAL_LINENO</code> is set) <code>eval</code> commands. currently being executed. The first element is the name of the function using the parameter.</p>
<p>The standard shell array <code>zsh_eval_context</code> can be used to determine the type of shell construct being executed at each depth: note, however, that is in the opposite order, with the most recent item last, and it is more detailed, for example including an entry for <code>toplevel</code>, the main shell code being executed either interactively or from a script, which is not present in <code>$funcstack</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfunctions">
<h3><code>$functions</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfunctions">¶</a></h3>
<p>This associative array maps names of enabled functions to their definitions. Setting a key in it is like defining a function with the name given by the key and the body given by the value. Unsetting a key removes the definition for the function named by the key.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfunctions_source">
<h3><code>$functions_source</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfunctions_source">¶</a></h3>
<p>This readonly associative array maps names of enabled functions to the name of the file containing the source of the function.</p>
<p>For an autoloaded function that has already been loaded, or marked for autoload with an absolute path, or that has had its path resolved with "functions -r", this is the file found for autoloading, resolved to an absolute path.</p>
<p>For a function defined within the body of a script or sourced file, this is the name of that file. In this case, this is the exact path originally used to that file, which may be a relative path.</p>
<p>For any other function, including any defined at an interactive prompt or an autoload function whose path has not yet been resolved, this is the empty string. However, the hash element is reported as defined just so long as the function is present: the keys to this hash are the same as those to <code>$functions</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarfunctrace">
<h3><code>$functrace</code> <a class="doc-anchor" href="#doc-lsp-special-dollarfunctrace">¶</a></h3>
<p>This array contains the names and line numbers of the callers corresponding to the functions currently being executed. The format of each element is <em>name</em><code>:</code><em>lineno</em>. Callers are also shown for sourced files; the caller is the point where the <code>source</code> or "." command was executed.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollargaliases">
<h3><code>$galiases</code> <a class="doc-anchor" href="#doc-lsp-special-dollargaliases">¶</a></h3>
<p>Like <code>aliases</code>, but for global aliases.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarhistchars">
<h3><code>$histchars</code> <a class="doc-anchor" href="#doc-lsp-special-dollarhistchars">¶</a></h3>
<p>Three characters used by the shell's history and lexical analysis mechanism. The first character signals the start of a history expansion (default "!"). The second character signals the start of a quick history substitution (default "^"). The third character is the comment character (default "#").</p>
<p>The characters must be in the ASCII character set; any attempt to set <code>histchars</code> to characters with a locale-dependent meaning will be rejected with an error message.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarhistory">
<h3><code>$history</code> <a class="doc-anchor" href="#doc-lsp-special-dollarhistory">¶</a></h3>
<p>This associative array maps history event numbers to the full history lines. Although it is presented as an associative array, the array of all values (<code>${history[@]}</code>) is guaranteed to be returned in order from most recent to oldest history event, that is, by decreasing history event number.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarhistorywords">
<h3><code>$historywords</code> <a class="doc-anchor" href="#doc-lsp-special-dollarhistorywords">¶</a></h3>
<p>A special array containing the words stored in the history. These also appear in most to least recent order.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarincarg">
<h3><code>$incarg</code> <a class="doc-anchor" href="#doc-lsp-special-dollarincarg">¶</a></h3>
<p>This widget allows you to increment integers on the current line. In addition to decimals, it can handle hexadecimals prefixed with <code>0x</code>, binaries with <code>0b</code>, and octals with <code>0o</code>.</p>
<p>By default, the target integer will be incremented by one. With a numeric argument, the integer is incremented by the amount of the argument. The shell parameter <code>incarg</code> may be set to change the default increment to something other than one.</p>
<p>The behavior of this widget changes depending on the widget name.</p>
<p>When the widget is named <code>incarg</code>, the widget will increment an integer placed under the cursor placed or just to the left of it. <code>decarg</code>, on the other hand, decrements the integer. When the name is prefixed with <code>vi</code>, the cursor will jump to the nearest integer after the cursor before incrementing it. The <code>vi</code> prefix can also be combined with a <code>backward-</code> prefix to make the widget search backwards for numbers.</p>
<p>There's also a <code>sync-</code> prefix that can be added to the widget name. This variant is used for creating a sequence of numbers on split terminals with synchronized key input. The first pane won't increment the integer at all, but each pane after that will have the integer incremented once more than the previous pane. It currently supports tmux and iTerm2.</p>
<p>The prefixes <code>vi</code>, <code>backward-</code>, and <code>sync-</code> can be combined, for example, into <code>vim-sync-</code> or <code>vim-backward-sync-</code>. The <code>vi</code> prefix needs to be at the very beginning.</p>
<p> bindkey '^X+' incarg</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarjobdirs">
<h3><code>$jobdirs</code> <a class="doc-anchor" href="#doc-lsp-special-dollarjobdirs">¶</a></h3>
<p>This associative array maps job numbers to the directories from which the job was started (which may not be the current directory of the job).</p>
<p>The keys of the associative arrays are usually valid job numbers, and these are the values output with, for example, tt(${(k)jobdirs}). Non-numeric job references may be used when looking up a value; for example, <code>${jobdirs[%+]}</code> refers to the current job.</p>
<p>See the <code>jobs</code> builtin for how job information is provided in a subshell.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarjobstates">
<h3><code>$jobstates</code> <a class="doc-anchor" href="#doc-lsp-special-dollarjobstates">¶</a></h3>
<p>This associative array gives information about the states of the jobs currently known. The keys are the job numbers and the values are strings of the form <code>_job-state_</code>:<code>_mark_</code>:<code>_pid_</code>="<em>state</em>...". The <em>job-state</em> gives the state the whole job is currently in, one of "running", "suspended", or "done". The <em>mark</em> is "+" for the current job, "-" for the previous job and empty otherwise. This is followed by one <code></code>:<code>_pid_</code>="<em>state</em>" for every process in the job. The _pid_s are, of course, the process IDs and the <em>state</em> describes the state of that process.</p>
<p>Handling of the keys of the associative array is as described for <code>jobdirs</code> above.</p>
<p>See the <code>jobs</code> builtin for how job information is provided in a subshell.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarjobtexts">
<h3><code>$jobtexts</code> <a class="doc-anchor" href="#doc-lsp-special-dollarjobtexts">¶</a></h3>
<p>This associative array maps job numbers to the texts of the command lines that were used to start the jobs.</p>
<p>Handling of the keys of the associative array is as described for <code>jobdirs</code> above.</p>
<p>See the <code>jobs</code> builtin for how job information is provided in a subshell.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarkeymaps">
<h3><code>$keymaps</code> <a class="doc-anchor" href="#doc-lsp-special-dollarkeymaps">¶</a></h3>
<p>This array contains the names of the keymaps currently defined.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarkillring">
<h3><code>$killring</code> <a class="doc-anchor" href="#doc-lsp-special-dollarkillring">¶</a></h3>
<p>The array of previously killed items, with the most recently killed first. This gives the items that would be retrieved by a <code>yank-pop</code> in the same order. Note, however, that the most recently killed item is in <code>$CUTBUFFER</code>; <code>$killring</code> shows the array of previous entries.</p>
<p>The default size for the kill ring is eight, however the length may be changed by normal array operations. Any empty string in the kill ring is ignored by the <code>yank-pop</code> command, hence the size of the array effectively sets the maximum length of the kill ring, while the number of non-zero strings gives the current length, both as seen by the user at the command line.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarlanginfo">
<h3><code>$langinfo</code> <a class="doc-anchor" href="#doc-lsp-special-dollarlanginfo">¶</a></h3>
<p>An associative array that maps langinfo elements to their values.</p>
<p>Your implementation may support a number of the following keys:</p>
<p><code>CODESET</code>, <code>D_T_FMT</code>, <code>D_FMT</code>, <code>T_FMT</code>, <code>RADIXCHAR</code>, <code>THOUSEP</code>, <code>YESEXPR</code>, <code>NOEXPR</code>, <code>CRNCYSTR</code>, <code>ABDAY_{1..7}</code>, <code>DAY_{1..7}</code>, <code>ABMON_{1..12}</code>, <code>MON_{1..12}</code>, <code>T_FMT_AMPM</code>, <code>AM_STR</code>, <code>PM_STR</code>, <code>ERA</code>, <code>ERA_D_FMT</code>, <code>ERA_D_T_FMT</code>, <code>ERA_T_FMT</code>, <code>ALT_DIGITS</code></p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarlog">
<h3><code>$log</code> <a class="doc-anchor" href="#doc-lsp-special-dollarlog">¶</a></h3>
<p>List all users currently logged in who are affected by the current setting of the <code>watch</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarmailpath">
<h3><code>$mailpath</code> <a class="doc-anchor" href="#doc-lsp-special-dollarmailpath">¶</a></h3>
<p>An array (colon-separated list) of filenames to check for new mail. Each filename can be followed by a "?" and a message that will be printed. The message will undergo parameter expansion, command substitution and arithmetic expansion with the variable <code>$_</code> defined as the name of the file that has changed. The default message is "You have new mail". If an element is a directory instead of a file the shell will recursively check every file in every subdirectory of the element.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarmanpath">
<h3><code>$manpath</code> <a class="doc-anchor" href="#doc-lsp-special-dollarmanpath">¶</a></h3>
<p>An array (colon-separated list) whose value is not used by the shell. The <code>manpath</code> array can be useful, however, since setting it also sets <code>MANPATH</code>, and vice versa.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarmapfile">
<h3><code>$mapfile</code> <a class="doc-anchor" href="#doc-lsp-special-dollarmapfile">¶</a></h3>
<p>This associative array takes as keys the names of files; the resulting value is the content of the file. The value is treated identically to any other text coming from a parameter. The value may also be assigned to, in which case the file in question is written (whether or not it originally existed); or an element may be unset, which will delete the file in question. For example, ""vared "mapfile[myfile]"<code>' works as expected, editing the file "myfile".</code></p>
<p>When the array is accessed as a whole, the keys are the names of files in the current directory, and the values are empty (to save a huge overhead in memory). Thus tt(${(k)mapfile}) has the same effect as the glob operator tt(*(D)), since files beginning with a dot are not special. Care must be taken with expressions such as tt(rm ${(k)mapfile}), which will delete every file in the current directory without the usual "rm *" test.</p>
<p>The parameter <code>mapfile</code> may be made read-only; in that case, files referenced may not be written or deleted.</p>
<p>A file may conveniently be read into an array as one line per element with the form <code>_array_tt(=("${(f@)mapfile[)_filename_</code>]}"")". The double quotes and the "@" are necessary to prevent empty lines from being removed. Note that if the file ends with a newline, the shell will split on the final newline, generating an additional empty field; this can be suppressed by using "_array_tt(=("${(f@)${mapfile[)<em>filename</em>"]%$"\n"}}"")".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarmodule_path">
<h3><code>$module_path</code> <a class="doc-anchor" href="#doc-lsp-special-dollarmodule_path">¶</a></h3>
<p>An array (colon-separated list) of directories that <code>zmodload</code> searches for dynamically loadable modules. This is initialized to a standard pathname, usually "/usr/local/lib/zsh/$ZSH_VERSION". (The "/usr/local/lib" part varies from installation to installation.) For security reasons, any value set in the environment when the shell is started will be ignored.</p>
<p>These parameters only exist if the installation supports dynamic module loading.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarmodules">
<h3><code>$modules</code> <a class="doc-anchor" href="#doc-lsp-special-dollarmodules">¶</a></h3>
<p>An associative array giving information about modules. The keys are the names of the modules loaded, registered to be autoloaded, or aliased. The value says which state the named module is in and is one of the strings "loaded", "autoloaded", or <code></code>alias:"<em>name</em>", where <em>name</em> is the name the module is aliased to.</p>
<p>Setting or unsetting keys in this array is not possible.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarnameddirs">
<h3><code>$nameddirs</code> <a class="doc-anchor" href="#doc-lsp-special-dollarnameddirs">¶</a></h3>
<p>This associative array maps the names of named directories to the pathnames they stand for.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollaroptions">
<h3><code>$options</code> <a class="doc-anchor" href="#doc-lsp-special-dollaroptions">¶</a></h3>
<p>The keys for this associative array are the names of the options that can be set and unset using the <code>setopt</code> and <code>unsetopt</code> builtins. The value of each key is either the string <code>on</code> if the option is currently set, or the string <code>off</code> if the option is unset. Setting a key to one of these strings is like setting or unsetting the option, respectively. Unsetting a key in this array is like setting it to the value <code>off</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarparameters">
<h3><code>$parameters</code> <a class="doc-anchor" href="#doc-lsp-special-dollarparameters">¶</a></h3>
<p>The keys in this associative array are the names of the parameters currently defined. The values are strings describing the type of the parameter, in the same format used by the <code>t</code> parameter flag, see subref(Parameter Expansion Flags)(zshexpn). The value may also be "undefined" indicating a parameter that may be autoloaded from a module but has not yet been referenced. When the key is the name of a named reference, the value is "nameref-" prepended to the type of the referenced parameter, for example ifzman()</p>
<p> <code>% typeset -n parms=parameters</code> <code>% print -r ${parameters[parms]}</code> <code>nameref-association-readonly-hide-hideval-special</code></p>
<p>Setting or unsetting keys in this array is not possible.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarpatchars">
<h3><code>$patchars</code> <a class="doc-anchor" href="#doc-lsp-special-dollarpatchars">¶</a></h3>
<p>This array contains the enabled pattern characters.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarpath">
<h3><code>$path</code> <a class="doc-anchor" href="#doc-lsp-special-dollarpath">¶</a></h3>
<p>An array (colon-separated list) of directories to search for commands. When this parameter is set, each directory is scanned and all files found are put in a hash table. Directories named by relative path are not scanned for hashing.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarpipestatus">
<h3><code>$pipestatus</code> <a class="doc-anchor" href="#doc-lsp-special-dollarpipestatus">¶</a></h3>
<p>An array containing the exit statuses returned by all commands in the last pipeline.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarprompt">
<h3><code>$prompt</code> <a class="doc-anchor" href="#doc-lsp-special-dollarprompt">¶</a></h3>
<p>Same as <code>PS1</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarpsvar">
<h3><code>$psvar</code> <a class="doc-anchor" href="#doc-lsp-special-dollarpsvar">¶</a></h3>
<p>An array (colon-separated list) whose elements can be used in <code>PROMPT</code> strings. Setting <code>psvar</code> also sets <code>PSVAR</code>, and vice versa.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarregion_highlight">
<h3><code>$region_highlight</code> <a class="doc-anchor" href="#doc-lsp-special-dollarregion_highlight">¶</a></h3>
<p>Each element of this array may be set to a string that describes highlighting for an arbitrary region of the command line that will take effect the next time the command line is redisplayed. Highlighting of the non-editable parts of the command line in <code>PREDISPLAY</code> and <code>POSTDISPLAY</code> are possible, but note that the <code>P</code> flag is needed for character indexing to include <code>PREDISPLAY</code>.</p>
<p>Each string consists of the following whitespace-separated parts:</p>
<p>startitemize() itemiz(Optionally, a "P" to signify that the start and end offset that follow include any string set by the <code>PREDISPLAY</code> special parameter; this is needed if the predisplay string itself is to be highlighted. Whitespace between the "P" and the start offset is optional.) itemiz(A start offset in the same units as <code>CURSOR</code>.) itemiz(An end offset in the same units as <code>CURSOR</code>.) itemiz(A highlight specification in the same format as used for contexts in the parameter <code>zle_highlight</code>, see <em>Character Highlighting</em> (below); for example, <code>standout</code> or <code>fg=red,bold</code>.) itemiz(Optionally, a string of the form <code></code>memo="<em>token</em>". The <em>token</em> consists of everything between the "=" and the next whitespace, comma, NUL, or the end of the string. The <em>token</em> is preserved verbatim but not parsed in any way.</p>
<p>Plugins may use this to identify array elements they have added: for example, a plugin might set <em>token</em> to its (the plugin's) name and then use <code>tt(region_highlight=+( ${region_highlight:#*memo=)_token_</code>} +")" in order to remove array elements it added.</p>
<p>(This example uses the <code></code>${<code>_name_</code>:#<code>_pattern_</code>}<code>' array-grepping syntax described in _Parameter Expansion_ (zshexpn).)) enditemize()</code></p>
<p>For example,</p>
<p>example(region_highlight=("P0 20 bold memo=foobar"))</p>
<p>specifies that the first twenty characters of the text including any predisplay string should be highlighted in bold.</p>
<p>Note that the effect of <code>region_highlight</code> is not saved and disappears as soon as the line is accepted.</p>
<p>Note that zsh 5.8 and older do not support the <code></code>memo="<em>token</em>" field and may misparse the third (highlight specification) field when a memo is given. COMMENT(The syntax "0 20 bold, memo=foobar" (with an auxiliary comma) happens to work on both zsh <=5.8 and zsh 5.9, but that seems to be more of an accident of implementation than something we should make a first-class-citizen API promise. It's mentioned in the "Incompatibilities" section of README.)</p>
<p>Where a particular region is covered by multiple entries in <code>region_highlight</code>, their effects are merged. In the case of conflicts, later entries take precedence over earlier ones. This precedence ordering can be overridden by specifying layers.</p>
<p>The final highlighting on the command line depends on both <code>region_highlight</code> and <code>zle_highlight</code>; see <em>Character Highlighting</em> (below) for details.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarregisters">
<h3><code>$registers</code> <a class="doc-anchor" href="#doc-lsp-special-dollarregisters">¶</a></h3>
<p>The contents of each of the vi register buffers. These are typically set using <code>vi-set-buffer</code> followed by a delete, change or yank command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarreply">
<h3><code>$reply</code> <a class="doc-anchor" href="#doc-lsp-special-dollarreply">¶</a></h3>
<p>As <code>REPLY</code>, but for array values rather than strings.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarreswords">
<h3><code>$reswords</code> <a class="doc-anchor" href="#doc-lsp-special-dollarreswords">¶</a></h3>
<p>This array contains the enabled reserved words.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarsaliases">
<h3><code>$saliases</code> <a class="doc-anchor" href="#doc-lsp-special-dollarsaliases">¶</a></h3>
<p>Like <code>raliases</code>, but for suffix aliases.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarsignals">
<h3><code>$signals</code> <a class="doc-anchor" href="#doc-lsp-special-dollarsignals">¶</a></h3>
<p>An array containing the names of the signals. Note that with the standard zsh numbering of array indices, where the first element has index 1, the signals are offset by 1 from the signal number used by the operating system. For example, on typical Unix-like systems <code>HUP</code> is signal number 1, but is referred to as <code>$signals[2]</code>. This is because of <code>EXIT</code> at position 1 in the array, which is used internally by zsh but is not known to the operating system. On many systems there is a block of reserved or unused signal numbers before the POSIX real-time signals so the array index can't be used as an accurate indicator of their signal number. Use, for example, <code>kill -l SIGRTMIN</code> instead.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarstatus">
<h3><code>$status</code> <a class="doc-anchor" href="#doc-lsp-special-dollarstatus">¶</a></h3>
<p>Same as <code>?</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarsysparams">
<h3><code>$sysparams</code> <a class="doc-anchor" href="#doc-lsp-special-dollarsysparams">¶</a></h3>
<p>A readonly associative array. The keys are:</p>
<p>- <strong><code>pid</code></strong> — vindex(pid, sysparams) Returns the process ID of the current process, even in subshells. Compare <code>$$</code>, which returns the process ID of the main shell process.</p>
<p>- <strong><code>ppid</code></strong> — vindex(ppid, sysparams) Returns the current process ID of the parent of the current process, even in subshells. Compare <code>$PPID</code>, which returns the process ID of the initial parent of the main shell process.</p>
<p>- <strong><code>procsubstpid</code></strong> — Returns the process ID of the last process started for process substitution, i.e. the tt(<()<em>...</em><code></code>) and tt(>()<em>...</em><code></code>) expansions.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollartermcap">
<h3><code>$termcap</code> <a class="doc-anchor" href="#doc-lsp-special-dollartermcap">¶</a></h3>
<p>An associative array that maps termcap capability codes to their values.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarterminfo">
<h3><code>$terminfo</code> <a class="doc-anchor" href="#doc-lsp-special-dollarterminfo">¶</a></h3>
<p>An associative array that maps terminfo capability names to their values.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollaruserdirs">
<h3><code>$userdirs</code> <a class="doc-anchor" href="#doc-lsp-special-dollaruserdirs">¶</a></h3>
<p>This associative array maps user names to the pathnames of their home directories.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarusergroups">
<h3><code>$usergroups</code> <a class="doc-anchor" href="#doc-lsp-special-dollarusergroups">¶</a></h3>
<p>This associative array maps names of system groups of which the current user is a member to the corresponding group identifiers. The contents are the same as the groups output by the <code>id</code> command.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarwatch">
<h3><code>$watch</code> <a class="doc-anchor" href="#doc-lsp-special-dollarwatch">¶</a></h3>
<p>An array (colon-separated list) of login/logout events to report.</p>
<p>If it contains the single word "all", then all login/logout events are reported. If it contains the single word "notme", then all events are reported as with "all" except <code>$USERNAME</code>.</p>
<p>An entry in this list may consist of a username, an "@" followed by a remote hostname, and a "%" followed by a line (tty). Any of these may be a pattern (be sure to quote this during the assignment to <code>watch</code> so that it does not immediately perform file generation); the setting of the <code>EXTENDED_GLOB</code> option is respected. Any or all of these components may be present in an entry; if a login/logout event matches all of them, it is reported.</p>
<p>For example, with the <code>EXTENDED_GLOB</code> option set, the following:</p>
<p>example(watch=('^(pws|barts)'))</p>
<p>causes reports for activity associated with any user other than <code>pws</code> or <code>barts</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarwidgets">
<h3><code>$widgets</code> <a class="doc-anchor" href="#doc-lsp-special-dollarwidgets">¶</a></h3>
<p>This associative array contains one entry per widget. The name of the widget is the key and the value gives information about the widget. It is either the string "builtin" for builtin widgets, a string of the form <code></code>user:"<em>name</em>" for user-defined widgets, where <em>name</em> is the name of the shell function implementing the widget, a string of the form <code></code>completion:<code>_type_</code>:"<em>name</em>" for completion widgets, or a null value if the widget is not yet fully defined. In the penultimate case, <em>type</em> is the name of the builtin widget the completion widget imitates in its behavior and <em>name</em> is the name of the shell function implementing the completion widget.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzcurses_attrs">
<h3><code>$zcurses_attrs</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzcurses_attrs">¶</a></h3>
<p>Readonly array. The attributes supported by <code>zsh/curses</code>; available as soon as the module is loaded.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzcurses_colors">
<h3><code>$zcurses_colors</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzcurses_colors">¶</a></h3>
<p>Readonly array. The colors supported by <code>zsh/curses</code>; available as soon as the module is loaded.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzcurses_keycodes">
<h3><code>$zcurses_keycodes</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzcurses_keycodes">¶</a></h3>
<p>Readonly array. The values that may be returned in the second parameter supplied to "zcurses input" in the order in which they are defined internally by curses. Not all function keys are listed, only <code>F0</code>; curses reserves space for <code>F0</code> up to <code>F63</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzcurses_windows">
<h3><code>$zcurses_windows</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzcurses_windows">¶</a></h3>
<p>Readonly array. The current list of windows, i.e. all windows that have been created with "zcurses addwin" and not removed with "zcurses delwin".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzle_bracketed_paste">
<h3><code>$zle_bracketed_paste</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzle_bracketed_paste">¶</a></h3>
<p>This two-element array contains the terminal escape sequences for enabling and disabling the bracketed paste feature which allows ZLE to discern text that is pasted into the terminal. These escape sequences are used to enable bracketed paste when ZLE is active and disable it at other times. Unsetting the parameter has the effect of ensuring that bracketed paste remains disabled. However, see also the <code>.term.extensions</code> parameter which provides a single place to enable or disable terminal features.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzle_cursorform">
<h3><code>$zle_cursorform</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzle_cursorform">¶</a></h3>
<p>An array describing contexts in which ZLE should change the shape and color of the cursor. See ifzman(<em>Cursor Shape and Color</em> in zmanref(zshzle))\ ifnzman((Cursor Shape and Color)).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzle_highlight">
<h3><code>$zle_highlight</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzle_highlight">¶</a></h3>
<p>An array describing contexts in which ZLE should highlight the input text. See <em>Character Highlighting</em> (zshzle).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzsh_eval_context">
<h3><code>$zsh_eval_context</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzsh_eval_context">¶</a></h3>
<p>An array (colon-separated list) indicating the context of shell code that is being run. Each time a piece of shell code that is stored within the shell is executed a string is temporarily appended to the array to indicate the type of operation that is being performed. Read in order the array gives an indication of the stack of operations being performed with the most immediate context last.</p>
<p>Note that the variable does not give information on syntactic context such as pipelines or subshells. Use <code>$ZSH_SUBSHELL</code> to detect subshells.</p>
<p>The context is one of the following:</p>
<p>- <strong><code>cmdarg</code></strong> — Code specified by the <code>-c</code> option to the command line that invoked the shell.</p>
<p>- <strong><code>cmdsubst</code></strong> — Command substitution using of the <code></code><code>_..._</code><code></code>, tt($+()<em>...</em><code></code>), <code>${{</code><em>name</em><code>}</code> <em>...</em><code>}</code>, <code>${|</code><em>...</em><code>}</code>, or <code>${ </code><em>...</em><code> }</code> constructs.</p>
<p>- <strong><code>equalsubst</code></strong> — The tt(=+()<em>...</em><code></code>) form of process substitution.</p>
<p>- <strong><code>eval</code></strong> — Code executed by the <code>eval</code> builtin.</p>
<p>- <strong><code>evalautofunc</code></strong> — Code executed with the <code>KSH_AUTOLOAD</code> mechanism in order to define an autoloaded function.</p>
<p>- <strong><code>fc</code></strong> — Code from the shell history executed by the <code>-e</code> option to the <code>fc</code> builtin.</p>
<p>- <strong><code>file</code></strong> — Lines of code being read directly from a file, for example by the <code>source</code> builtin.</p>
<p>- <strong><code>filecode</code></strong> — Lines of code being read from a <code>.zwc</code> file instead of directly from the source file.</p>
<p>- <strong><code>globqual</code></strong> — Code executed by the <code>e</code> or <code>+</code> glob qualifier.</p>
<p>- <strong><code>globsort</code></strong> — Code executed to order files by the <code>o</code> glob qualifier.</p>
<p>- <strong><code>insubst</code></strong> — The tt(<()<em>...</em><code></code>) form of process substitution.</p>
<p>- <strong><code>loadautofunc</code></strong> — Code read directly from a file to define an autoloaded function.</p>
<p>- <strong><code>outsubst</code></strong> — The tt(>()<em>...</em><code></code>) form of process substitution.</p>
<p>- <strong><code>sched</code></strong> — Code executed by the <code>sched</code> builtin.</p>
<p>- <strong><code>shfunc</code></strong> — A shell function.</p>
<p>- <strong><code>stty</code></strong> — Code passed to <code>stty</code> by the <code>STTY</code> environment variable. Normally this is passed directly to the system's <code>stty</code> command, so this value is unlikely to be seen in practice.</p>
<p>- <strong><code>style</code></strong> — Code executed as part of a style retrieved by the <code>zstyle</code> builtin from the <code>zsh/zutil</code> module.</p>
<p>- <strong><code>toplevel</code></strong> — The highest execution level of a script or interactive shell.</p>
<p>- <strong><code>trap</code></strong> — Code executed as a trap defined by the <code>trap</code> builtin. Traps defined as functions have the context <code>shfunc</code>. As traps are asynchronous they may have a different hierarchy from other code.</p>
<p>- <strong><code>zpty</code></strong> — Code executed by the <code>zpty</code> builtin from the <code>zsh/zpty</code> module.</p>
<p>- <strong><code>zregexparse-guard</code></strong> — Code executed as a guard by the <code>zregexparse</code> command from the <code>zsh/zutil</code> module.</p>
<p>- <strong><code>zregexparse-action</code></strong> — Code executed as an action by the <code>zregexparse</code> command from the <code>zsh/zutil</code> module.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzsh_scheduled_events">
<h3><code>$zsh_scheduled_events</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzsh_scheduled_events">¶</a></h3>
<p>A readonly array corresponding to the events scheduled by the <code>sched</code> builtin. The indices of the array correspond to the numbers shown when <code>sched</code> is run with no arguments (provided that the <code>KSH_ARRAYS</code> option is not set). The value of the array consists of the scheduled time in seconds since the epoch (see <em>The zsh/datetime Module</em> (zshmodules) for facilities for using this number), followed by a colon, followed by any options (which may be empty but will be preceded by a "-" otherwise), followed by a colon, followed by the command to be executed.</p>
<p>The <code>sched</code> builtin should be used for manipulating the events. Note that this will have an immediate effect on the contents of the array, so that indices may become invalid.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dollarzstyle">
<h3><code>$zstyle</code> <a class="doc-anchor" href="#doc-lsp-special-dollarzstyle">¶</a></h3>
<p>Delete style definitions. Without arguments all definitions are deleted, with a <em>pattern</em> all definitions for that pattern are deleted and if any _style_s are given, then only those styles are deleted for the <em>pattern</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-star">
<h3><code>*</code> <a class="doc-anchor" href="#doc-lsp-special-star">¶</a></h3>
<p>Glob: match zero or more characters of any name (excluding leading <code>.</code> unless <code>GLOB_DOTS</code> is set). Also a multiplication operator inside <code>(( … ))</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dash">
<h3><code>-</code> <a class="doc-anchor" href="#doc-lsp-special-dash">¶</a></h3>
<p>The command is executed with a "-" prepended to its <code>argv[0]</code> string.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotcommand">
<h3><code>.sh.command</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotcommand">¶</a></h3>
<p>A named reference to "ZSH_DEBUG_CMD"</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotedchar">
<h3><code>.sh.edchar</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotedchar">¶</a></h3>
<p>In a ZLE widget, equivalent to the "KEYS" special parameter. In a future release, assignments to this parameter will affect the input stream seen by ZLE.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotedcol">
<h3><code>.sh.edcol</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotedcol">¶</a></h3>
<p>A named reference to the ZLE special parameter "CURSOR".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotedmode">
<h3><code>.sh.edmode</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotedmode">¶</a></h3>
<p>In a ZLE widget, this parameter has the value <code>ESC" ("$"\e"</code>) if the <code>VI</code> option is set and the "main" keymap is selected. This is intended for use with vi-mode key bindings ("bindkey -v"). In a future revision, assigning ".sh.edchar=${.sh.edmode}" is expected to initiate "vicmd" mode when "viins" is active, and do nothing when "vicmd" is already active.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotedtext">
<h3><code>.sh.edtext</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotedtext">¶</a></h3>
<p>A named reference to the "BUFFER" special ZLE parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotfile">
<h3><code>.sh.file</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotfile">¶</a></h3>
<p>A named reference to the "ZSH_SCRIPT" parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotfun">
<h3><code>.sh.fun</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotfun">¶</a></h3>
<p>In a shell function, the function's name. Usually the same as "$0", but not affected by <code>POSIX_ARGZERO</code> or <code>FUNCTION_ARGZERO</code> options.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotlevel">
<h3><code>.sh.level</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotlevel">¶</a></h3>
<p>In a shell function, initially set to the depth of the call stack. This may be assigned to change the apparent depth. However, such assignment does not affect the scope of local parameters.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotlineno">
<h3><code>.sh.lineno</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotlineno">¶</a></h3>
<p>A named reference to the "LINENO" special parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotmatch">
<h3><code>.sh.match</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotmatch">¶</a></h3>
<p>An array equivalent to the "match" parameter as assigned by the <code>tt((#b)</code>")" extended globbing flag. When the <code>KSH_ARRAYS</code> option is set, "${.sh.match[0]}" gives the value of the "MATCH" parameter as set by the <code>tt((#m)</code>")" extended globbing flag. Currently, the <code>EXTENDED_GLOB</code> option must be enabled and those flags must be explicitly used in a pattern in order for these values of ".sh.match" to be set.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotname">
<h3><code>.sh.name</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotname">¶</a></h3>
<p>When the "vared" command is used, this parameter may be used in user-defined ZLE widgets to get the name of the variable being edited. A future release is expected to use this parameter in the implementation of "discipline functions".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotsubscript">
<h3><code>.sh.subscript</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotsubscript">¶</a></h3>
<p>When "vared" has been used on an array element, this parameter holds the array index (either a number, or an associative array key).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotsubshell">
<h3><code>.sh.subshell</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotsubshell">¶</a></h3>
<p>A named reference to the "ZSH_SUBSHELL" parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotvalue">
<h3><code>.sh.value</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotvalue">¶</a></h3>
<p>In "vared" this is a named reference to the ZLE special "BUFFER". A future release is expected to use this parameter in the implementation of "discipline functions".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotshdotversion">
<h3><code>.sh.version</code> <a class="doc-anchor" href="#doc-lsp-special-dotshdotversion">¶</a></h3>
<p>A named reference to "ZSH_PATCHLEVEL".</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotbg">
<h3><code>.term.bg</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotbg">¶</a></h3>
<p>The background color of the terminal if the terminal supports the necessary interface for retrieving this information.</p>
<p>See also the <code>.term.extensions</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotcursor">
<h3><code>.term.cursor</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotcursor">¶</a></h3>
<p>The default color of the cursor.</p>
<p>See also the <code>.term.extensions</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotextensions">
<h3><code>.term.extensions</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotextensions">¶</a></h3>
<p>An array containing a list of extension features of the terminal. See <em>Terminal Extensions</em> (zshzle).</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotfg">
<h3><code>.term.fg</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotfg">¶</a></h3>
<p>Like <code>.term.bg</code> but for the foreground color.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotid">
<h3><code>.term.id</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotid">¶</a></h3>
<p>Like the <code>TERM</code> parameter, this identifies the terminal but is obtained by querying the terminal. Many terminals name a different common terminal in <code>TERM</code> that they then emulate, often imperfectly. This allows them to work without the need to distribute updates to terminal capability databases. The more accurate identification in this parameter may be useful when configuring aspects of the shell differently for specific terminals.</p>
<p>See also the <code>.term.extensions</code> parameter.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotmode">
<h3><code>.term.mode</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotmode">¶</a></h3>
<p>Either <code>light</code> or <code>dark</code>. In cases where the terminal background color is detected and set in <code>.term.bg</code>, this is set to provide a basic indication of how light that color is. This may help with configuring readable color combinations.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotquerywait">
<h3><code>.term.querywait</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotquerywait">¶</a></h3>
<p>The time the shell waits, in hundredths of seconds, for the response to terminal queries. A value of <code>"0"</code> disables the timeout and the shell will wait indefinitely. If not set, a default of <code>"50"</code> or half a second is used.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dottermdotversion">
<h3><code>.term.version</code> <a class="doc-anchor" href="#doc-lsp-special-dottermdotversion">¶</a></h3>
<p>The version number of the terminal application, set in conjunction with <code>.term.id</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotzledotesc">
<h3><code>.zle.esc</code> <a class="doc-anchor" href="#doc-lsp-special-dotzledotesc">¶</a></h3>
<p>This associative array contains the literal escape sequences used to apply the highlighting for each group. An example use would be when setting the <code>LESS_TERMCAP_xx</code> environment variables for the <code>less</code> pager.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-dotzledotsgr">
<h3><code>.zle.sgr</code> <a class="doc-anchor" href="#doc-lsp-special-dotzledotsgr">¶</a></h3>
<p>Where highlighting makes use of CSI escape sequences, this parameter contains the "Select Graphic Rendition" number sequence. This is useful with, for example the <code>GREP_COLORS</code> and <code>LSCOLORS</code> environment variables and the <code>list-colors</code> style.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-0">
<h3><code>0</code> <a class="doc-anchor" href="#doc-lsp-special-0">¶</a></h3>
<p>The name used to invoke the current shell, or as set by the <code>-c</code> command line option upon invocation. If the <code>FUNCTION_ARGZERO</code> option is set, <code>$0</code> is set upon entry to a shell function to the name of the function, and upon entry to a sourced script to the name of the script, and reset to its previous value when the function or script returns.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-qmark">
<h3><code>?</code> <a class="doc-anchor" href="#doc-lsp-special-qmark">¶</a></h3>
<p>Glob: match exactly one character. Also the last-exit-status variable when used as <code>$?</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-special-at">
<h3><code>@</code> <a class="doc-anchor" href="#doc-lsp-special-at">¶</a></h3>
<p>Same as <code>argv[@]</code>, even when <code>argv</code> is not set.</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-compsys">
<h2>Compsys Function Index</h2>
<p class="chapter-meta">52 entries</p>
<article class="doc-entry" id="doc-lsp-compsys-_all_labels">
<h3><code>_all_labels</code> <a class="doc-anchor" href="#doc-lsp-compsys-_all_labels">¶</a></h3>
<p>This is a convenient interface to the <code>_next_label</code> function below, implementing the loop shown in the <code>_next_label</code> example. The <em>command</em> and its arguments are called to generate the matches. The options stored in the parameter <em>name</em> will automatically be inserted into the _arg_s passed to the <em>command</em>. Normally, they are put directly after the <em>command</em>, but if one of the _arg_s is a single hyphen, they are inserted directly before that. If the hyphen is the last argument, it will be removed from the argument list before the <em>command</em> is called. This allows <code>_all_labels</code> to be used in almost all cases where the matches can be generated by a single call to the <code>compadd</code> builtin command or by a call to one of the utility functions.</p>
<p>For example:</p>
<p> local expl ... if _requested foo; then ... _all_labels foo expl '...' compadd ... - $matches fi</p>
<p>Will complete the strings from the <code>matches</code> parameter, using <code>compadd</code> with additional options which will take precedence over those generated by <code>_all_labels</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_alternative">
<h3><code>_alternative</code> <a class="doc-anchor" href="#doc-lsp-compsys-_alternative">¶</a></h3>
<p>This function is useful in simple cases where multiple tags are available. Essentially it implements a loop like the one described for the <code>_tags</code> function below.</p>
<p>The tags to use and the action to perform if a tag is requested are described using the _spec_s which are of the form: <code>_tag_</code>:<code>_descr_</code>:"<em>action</em>". The _tag_s are offered using <code>_tags</code> and if the tag is requested, the <em>action</em> is executed with the given description <em>descr</em>. The _action_s are those accepted by the <code>_arguments</code> function (described below), with the following exceptions: startitemize() itemiz(\ The <code></code>->"<em>state</em>" and <code></code>="<em>...</em>" forms are not supported. ) itemiz(\ The <code>tt(((a\:bar b\:baz)</code>"))" form does not need the colon to be escaped, since the _spec_s have no colon-separated fields after the <em>action</em>. ) enditemize()</p>
<p>For example, the <em>action</em> may be a simple function call:</p>
<p> _alternative \ 'users:user:_users' \ 'hosts:host:_hosts'</p>
<p>offers usernames and hostnames as possible matches, generated by the <code>_users</code> and <code>_hosts</code> functions respectively.</p>
<p>Like <code>_arguments</code>, this function uses <code>_all_labels</code> to execute the actions, which will loop over all sets of tags. Special handling is only required if there is an additional valid tag, for example inside a function called from <code>_alternative</code>.</p>
<p>The option <code></code>-O" <em>name</em>" is used in the same way as by the <code>_arguments</code> function. In other words, the elements of the <em>name</em> array will be passed to <code>compadd</code> when executing an action.</p>
<p>Like <code>_tags</code> this function supports the <code>-C</code> option to give a different name for the argument context field.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_approximate">
<h3><code>_approximate</code> <a class="doc-anchor" href="#doc-lsp-compsys-_approximate">¶</a></h3>
<p>This is similar to the basic <code>_complete</code> completer but allows the completions to undergo corrections. The maximum number of errors can be specified by the <code>max-errors</code> style; see <em>Approximate Matching</em> (zshexpn) for how errors are counted. Normally this completer will only be tried after the normal <code>_complete</code> completer:</p>
<p> zstyle ':completion:*' completer _complete _approximate</p>
<p>This will give correcting completion if and only if normal completion yields no possible completions. When corrected completions are found, the completer will normally start menu completion allowing you to cycle through these strings.</p>
<p>This completer uses the tags <code>corrections</code> and <code>original</code> when generating the possible corrections and the original string. The <code>format</code> style for the former may contain the additional sequences "%e" and "%o" which will be replaced by the number of errors accepted to generate the corrections and the original string, respectively.</p>
<p>The completer progressively increases the number of errors allowed up to the limit by the <code>max-errors</code> style, hence if a completion is found with one error, no completions with two errors will be shown, and so on. It modifies the completer name in the context to indicate the number of errors being tried: on the first try the completer field contains "approximate-1", on the second try "approximate-2", and so on.</p>
<p>When <code>_approximate</code> is called from another function, the number of errors to accept may be passed with the <code>-a</code> option. The argument is in the same format as the <code>max-errors</code> style, all in one string.</p>
<p>Note that this completer (and the <code>_correct</code> completer mentioned below) can be quite expensive to call, especially when a large number of errors are allowed. One way to avoid this is to set up the <code>completer</code> style using the <code>-e</code> option to zstyle so that some completers are only used when completion is attempted a second time on the same string, e.g.:</p>
<p>example(zstyle -e ':completion:*' completer ' if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]]; then _last_try="$HISTNO$BUFFER$CURSOR" reply=(_complete _match _prefix) else reply=(_ignored _correct _approximate) fi')</p>
<p>This uses the <code>HISTNO</code> parameter and the <code>BUFFER</code> and <code>CURSOR</code> special parameters that are available inside zle and completion widgets to find out if the command line hasn't changed since the last time completion was tried. Only then are the <code>_ignored</code>, <code>_correct</code> and <code>_approximate</code> completers called.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_arguments">
<h3><code>_arguments</code> <a class="doc-anchor" href="#doc-lsp-compsys-_arguments">¶</a></h3>
<p>This function can be used to give a complete specification for completion for a command whose arguments follow standard UNIX option and argument conventions.</p>
<p><em>Options Overview</em></p>
<p>Options to <code>_arguments</code> itself must be in separate words, i.e. <code>-s -w</code>, not <code>-sw</code>. The options are followed by _spec_s that describe options and arguments of the analyzed command. To avoid ambiguity, all options to <code>_arguments</code> itself may be separated from the <em>spec</em> forms by a single colon.</p>
<p>The <code></code>-"-" form is used to intuit <em>spec</em> forms from the help output of the command being analyzed, and is described in detail below. The <em>opts</em> for the <code></code>-"-" form are otherwise the same options as the first form. Note that "-s" following <code></code>-"-" has a distinct meaning from "-s" preceding <code></code>-"-", and both may appear.</p>
<p>The option switches <code>-s</code>, <code>-S</code>, <code>-A</code>, <code>-w</code>, and <code>-W</code> affect how <code>_arguments" parses the analyzed command line"s options. These switches are useful for commands with standard argument parsing.</code></p>
<p>The options of <code>_arguments</code> have the following meanings:</p>
<p>- <strong><code>-n</code></strong> — With this option, <code>_arguments</code> sets the parameter <code>NORMARG</code> to the position of the first normal argument in the <code>$words</code> array, i.e. the position after the end of the options. If that argument has not been reached, <code>NORMARG</code> is set to <code>-1</code>. The caller should declare "integer NORMARG" if the <code>-n</code> option is passed; otherwise the parameter is not used.</p>
<p>- <strong><code>-s</code></strong> — Enable <em>option stacking</em> for single-letter options, whereby multiple single-letter options may be combined into a single word. For example, the two options "-x" and "-y" may be combined into a single word "-xy". By default, every word corresponds to a single option name ("-xy" is a single option named "xy").</p>
<p>Options beginning with a single hyphen or plus sign are eligible for stacking; words beginning with two hyphens are not.</p>
<p>Note that <code>-s</code> after <code>-</code><code>-</code> has a different meaning, which is documented in the segment entitled "Deriving <em>spec</em> forms from the help output".</p>
<p>- <strong><code>-w</code></strong> — In combination with <code>-s</code>, allow option stacking even if one or more of the options take arguments. For example, if <code>-x</code> takes an argument, with no <code>-s</code>, "-xy" is considered as a single (unhandled) option; with <code>-s</code>, <code>-xy</code> is an option with the argument "y"; with both <code>-s</code> and <code>-w</code>, <code>-xy</code> is the option <code>-x</code> and the option <code>-y</code> with arguments to <code>-x</code> (and to <code>-y</code>, if it takes arguments) still to come in subsequent words.</p>
<p>- <strong><code>-W</code></strong> — This option takes <code>-w</code> a stage further: it is possible to complete single-letter options even after an argument that occurs in the same word. However, it depends on the action performed whether options will really be completed at this point. For more control, use a utility function like <code>_guard</code> as part of the action.</p>
<p>- <strong><code>-C</code></strong> — Modify the <code>curcontext</code> parameter for an action of the form <code></code>->"<em>state</em>". This is discussed in detail below.</p>
<p>- <strong><code>-R</code></strong> — Return status 300 instead of zero when a <code>$state</code> is to be handled, in the <code></code>->"<em>string</em>" syntax.</p>
<p>- <strong><code>-S</code></strong> — Do not complete options after a <code></code>-"-" appearing on the line, and ignore the <code></code>-"-". For example, with <code>-S</code>, in the line</p>
<p> foobar -x -- -y</p>
<p>the "-x" is considered an option, the "-y" is considered an argument, and the <code></code>-"-" is considered to be neither.</p>
<p>- <strong><code>-A</code> <em>pat</em></strong> — Do not complete options after the first non-option argument on the line. <em>pat</em> is a pattern matching all strings which are not to be taken as arguments. For example, to make <code>_arguments</code> stop completing options after the first normal argument, but ignoring all strings starting with a hyphen even if they are not described by one of the _optspec_s, the form is "-A "-*"".</p>
<p>- <strong><code>-O</code> <em>name</em></strong> — Pass the elements of the array <em>name</em> as arguments to functions called to execute _action_s. This is discussed in detail below.</p>
<p>- <strong><code>-M</code> <em>matchspec</em></strong> — Use the match specification <em>matchspec</em> for completing option names and values. The default <em>matchspec</em> allows partial word completion after "_" and "-", such as completing "-f-b" to "-foo-bar". The default <em>matchspec</em> is:</p>
<p> <code>r:|[_-]=* r:|=*</code></p>
<p>- <strong><code>-0</code></strong> — When populating values of the "opt_args" associative array, don't backslash-escape colons and backslashes and use NUL rather than colon for joining multiple values. This option is described in more detail below, under the heading __spec_s: actions_.</p>
<p>__spec_s: overview_</p>
<p>Each of the following forms is a <em>spec</em> describing individual sets of options or arguments on the command line being analyzed.</p>
<p>- <strong><em>n</em><code>:</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><em>n</em><code>::</code><em>message</em><code>:"_action_</code></strong> — This describes the <em>n</em>"th normal argument. The <em>message</em> will be printed above the matches generated and the <em>action</em> indicates what can be completed in this position (see below). If there are two colons before the <em>message</em> the argument is optional. If the <em>message</em> contains only white space, nothing will be printed above the matches unless the action adds an explanation string itself.</p>
<p>- <strong><code>:</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>::</code><em>message</em><code>:</code><em>action</em></strong> — Similar, but describes the <em>next</em> argument, whatever number that happens to be. If all arguments are specified in this form in the correct order the numbers are unnecessary.</p>
<p>- <strong><code>*:</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>*::</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>*:::</code><em>message</em><code>:</code><em>action</em></strong> — This describes how arguments (usually non-option arguments, those not beginning with <code>-</code> or <code>+</code>) are to be completed when neither of the first two forms was provided. Any number of arguments can be completed in this fashion.</p>
<p>With two colons before the <em>message</em>, the <code>words</code> special array and the <code>CURRENT</code> special parameter are modified to refer only to the normal arguments when the <em>action</em> is executed or evaluated. With three colons before the <em>message</em> they are modified to refer only to the normal arguments covered by this description.</p>
<p>- <strong><em>optspec</em></strong></p>
<p>- <strong><em>optspec</em><code>:</code><em>...</em></strong> — This describes an option. The colon indicates handling for one or more arguments to the option; if it is not present, the option is assumed to take no arguments.</p>
<p>The following forms are available for the initial <em>optspec</em>, whether or not the option has arguments.</p>
<p>- <strong><code>*</code><em>optspec</em></strong> — Here <em>optspec</em> is one of the remaining forms below. This indicates the following <em>optspec</em> may be repeated. Otherwise if the corresponding option is already present on the command line to the left of the cursor it will not be offered again.</p>
<p>- <strong><code>-</code><em>optname</em></strong></p>
<p>- <strong><code>+</code><em>optname</em></strong> — In the simplest form the <em>optspec</em> is just the option name beginning with a minus or a plus sign, such as "-foo". The first argument for the option (if any) must follow as a <em>separate</em> word directly after the option.</p>
<p>Either of <code></code>-+"<em>optname</em>" and <code></code>+-"<em>optname</em>" can be used to specify that <code>-</code><em>optname</em> and <code>+</code><em>optname</em> are both valid.</p>
<p>In all the remaining forms, the leading "-" may be replaced by or paired with "+" in this way.</p>
<p>- <strong><code>-</code><em>optname</em><code>-</code></strong> — The first argument of the option must come directly after the option name <em>in the same word</em>. For example, <code></code>-foo-:"<em>...</em>" specifies that the completed option and argument will look like <code></code>-foo"<em>arg</em>".</p>
<p>- <strong><code>-</code><em>optname</em><code>+</code></strong> — The first argument may appear immediately after <em>optname</em> in the same word, or may appear as a separate word after the option. For example, <code></code>-foo+:"<em>...</em>" specifies that the completed option and argument will look like either <code></code>-foo"<em>arg</em>" or <code></code>-foo" <em>arg</em>".</p>
<p>- <strong><code>-</code><em>optname</em><code>=</code></strong> — The argument may appear as the next word, or in same word as the option name provided that it is separated from it by an equals sign, for example <code></code>-foo="<em>arg</em>" or <code></code>-foo" <em>arg</em>".</p>
<p>- <strong><code>-</code><em>optname</em><code>=-</code></strong> — The argument to the option must appear after an equals sign in the same word, and may not be given in the next argument.</p>
<p>- <strong><em>optspec</em><code>[</code><em>explanation</em><code>]</code></strong> — An explanation string may be appended to any of the preceding forms of <em>optspec</em> by enclosing it in brackets, as in "-q[query operation]".</p>
<p>The <code>verbose</code> style is used to decide whether the explanation strings are displayed with the option in a completion listing.</p>
<p>If no bracketed explanation string is given but the <code>auto-description</code> style is set and only one argument is described for this <em>optspec</em>, the value of the style is displayed, with any appearance of the sequence "%d" in it replaced by the <em>message</em> of the first <em>optarg</em> that follows the <em>optspec</em>; see below.</p>
<p>It is possible for options with a literal "+" or "=" to appear, but that character must be quoted, for example "-\+".</p>
<p>Each <em>optarg</em> following an <em>optspec</em> must take one of the following forms:</p>
<p>- <strong><code>:</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>::</code><em>message</em><code>:</code><em>action</em></strong> — An argument to the option; <em>message</em> and <em>action</em> are treated as for ordinary arguments. In the first form, the argument is mandatory, and in the second form it is optional.</p>
<p>This group may be repeated for options which take multiple arguments. In other words, <code>:</code><em>message1</em><code>:</code><em>action1</em><code>:</code><em>message2</em><code>:</code><em>action2</em> specifies that the option takes two arguments.</p>
<p>- <strong><code>:*</code><em>pattern</em><code>:</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>:*</code><em>pattern</em><code>::</code><em>message</em><code>:</code><em>action</em></strong></p>
<p>- <strong><code>:*</code><em>pattern</em><code>:::</code><em>message</em><code>:</code><em>action</em></strong> — This describes multiple arguments. Only the last <em>optarg</em> for an option taking multiple arguments may be given in this form. If the <em>pattern</em> is empty (i.e. <code>:*:</code>), all the remaining words on the line are to be completed as described by the <em>action</em>; otherwise, all the words up to and including a word matching the <em>pattern</em> are to be completed using the <em>action</em>.</p>
<p>Multiple colons are treated as for the <code></code>*:"<em>...</em>" forms for ordinary arguments: when the <em>message</em> is preceded by two colons, the <code>words</code> special array and the <code>CURRENT</code> special parameter are modified during the execution or evaluation of the <em>action</em> to refer only to the words after the option. When preceded by three colons, they are modified to refer only to the words covered by this description.</p>
<p>Any literal colon in an <em>optname</em>, <em>message</em>, or <em>action</em> must be preceded by a backslash, "\:".</p>
<p>Each of the forms above may be preceded by a list in parentheses of option names and argument numbers. If the given option is on the command line, the options and arguments indicated in parentheses will not be offered. For example, "tt((-two -three 1)-one:)<em>...</em>" completes the option "-one"; if this appears on the command line, the options <code>-two</code> and <code>-three</code> and the first ordinary argument will not be completed after it. "tt((-foo):)<em>...</em>" specifies an ordinary argument completion; <code>-foo</code> will not be completed if that argument is already present.</p>
<p>Other items may appear in the list of excluded options to indicate various other items that should not be applied when the current specification is matched: a single star (<code>*</code>) for the rest arguments (i.e. a specification of the form <code></code>*:"<em>...</em>"); a colon (<code>:</code>) for all normal (non-option-) arguments; and a hyphen (<code>-</code>) for all options. For example, if "tt((*))" appears before an option and the option appears on the command line, the list of remaining arguments (those shown in the above table beginning with "*:") will not be completed.</p>
<p>To aid in reuse of specifications, it is possible to precede any of the forms above with "!"; then the form will no longer be completed, although if the option or argument appears on the command line they will be skipped as normal. The main use for this is when the arguments are given by an array, and <code>_arguments</code> is called repeatedly for more specific contexts: on the first call "_arguments $global_options" is used, and on subsequent calls "_arguments !$^global_options".</p>
<p>__spec_s: actions_ COMMENT(If you change this section title, change the references to it in running text.)</p>
<p>In each of the forms above the <em>action</em> determines how completions should be generated. Except for the <code></code>->"<em>string</em>" form below, the <em>action</em> will be executed by calling the <code>_all_labels</code> function to process all tag labels. No special handling of tags is needed unless a function call introduces a new one.</p>
<p>The functions called to execute _action_s will be called with the elements of the array named by the <code></code>-O" <em>name</em>" option as arguments. This can be used, for example, to pass the same set of options for the <code>compadd</code> builtin to all _action_s.</p>
<p>The forms for <em>action</em> are as follows.</p>
<p>def(SP)(0)(@ )\</p>
<p>- <strong><code>SP()</code>(single unquoted space)</strong> — This is useful where an argument is required but it is not possible or desirable to generate matches for it. The <em>message</em> will be displayed but no completions listed. Note that even in this case the colon at the end of the <em>message</em> is needed; it may only be omitted when neither a <em>message</em> nor an <em>action</em> is given.</p>
<p>- <strong><code>()_item1_ _item2_ _..._</code><code></code></strong> — One of a list of possible matches, for example:</p>
<p>example(tt(:foo:(foo bar baz)<code></code>))</p>
<p>- <strong><code>((_item1_\:_desc1_ _..._))</code></strong> — Similar to the above, but with descriptions for each possible match. Note the backslash before the colon. For example,</p>
<p>example(tt(:foo:((a\:bar b\:baz)<code></code>)))</p>
<p>The matches will be listed together with their descriptions if the <code>description</code> style is set with the <code>values</code> tag in the context.</p>
<p>- <strong><code>-></code><em>string</em></strong> — vindex(context, use of) vindex(line, use of) vindex(opt_args, use of) In this form, <code>_arguments</code> processes the arguments and options and then returns control to the calling function with parameters set to indicate the state of processing; the calling function then makes its own arrangements for generating completions. For example, functions that implement a state machine can use this type of action.</p>
<p>Where <code>_arguments</code> encounters <em>action</em> in the <code></code>->"<em>string</em>" format, it will strip all leading and trailing whitespace from <em>string</em> and set the array <code>state</code> to the set of all _string_s for which an action is to be performed. The elements of the array <code>state_descr</code> are assigned the corresponding <em>message</em> field from each <em>optarg</em> containing such an <em>action</em>.</p>
<p>By default and in common with all other well behaved completion functions, _arguments returns status zero if it was able to add matches and non-zero otherwise. However, if the <code>-R</code> option is given, <code>_arguments</code> will instead return a status of 300 to indicate that <code>$state</code> is to be handled.</p>
<p>In addition to <code>$state</code> and <code>$state_descr</code>, <code>_arguments</code> also sets the global parameters "context", "line" and "opt_args" as described below, and does not reset any changes made to the special parameters such as <code>PREFIX</code> and <code>words</code>. This gives the calling function the choice of resetting these parameters or propagating changes in them.</p>
<p>A function calling <code>_arguments</code> with at least one action containing a <code></code>->"<em>string</em>" must therefore declare appropriate local parameters:</p>
<p> local context state state_descr line typeset -A opt_args</p>
<p>to prevent <code>_arguments</code> from altering the global environment.</p>
<p>- <strong><code>{</code><em>eval-string</em><code>}</code></strong> — vindex(expl, use of) A string in braces is evaluated as shell code to generate matches. If the <em>eval-string</em> itself does not begin with an opening parenthesis or brace it is split into separate words before execution.</p>
<p>- <strong><code>= </code><em>action</em></strong> — If the <em>action</em> starts with "= " (an equals sign followed by a space), <code>_arguments</code> will insert the contents of the <em>argument</em> field of the current context as the new first element in the <code>words</code> special array and increment the value of the <code>CURRENT</code> special parameter. This has the effect of inserting a dummy word onto the completion command line while not changing the point at which completion is taking place.</p>
<p>This is most useful with one of the specifiers that restrict the words on the command line on which the <em>action</em> is to operate (the two- and three-colon forms above). One particular use is when an <em>action</em> itself causes <code>_arguments</code> on a restricted range; it is necessary to use this trick to insert an appropriate command name into the range for the second call to <code>_arguments</code> to be able to parse the line.</p>
<p>- <strong>var(<code>SP()</code>word...)</strong></p>
<p>- <strong><em>word...</em></strong> — This covers all forms other than those above. If the <em>action</em> starts with a space, the remaining list of words will be invoked unchanged.</p>
<p>Otherwise it will be invoked with some extra strings placed after the first word; these are to be passed down as options to the <code>compadd</code> builtin. They ensure that the state specified by <code>_arguments</code>, in particular the descriptions of options and arguments, is correctly passed to the completion command. These additional arguments are taken from the array parameter "expl"; this will be set up before executing the <em>action</em> and hence may be referred to inside it, typically in an expansion of the form "$expl[@]" which preserves empty elements of the array.</p>
<p>During the performance of the action the array "line" will be set to the normal arguments from the command line, i.e. the words from the command line after the command name excluding all options and their arguments. Options are stored in the associative array "opt_args" with option names as keys and their arguments as the values. By default, all colons and backslashes in the value are escaped with backslashes, and if an option has multiple arguments (for example, when using an <em>optspec</em> of the form <code></code>*"<em>optspec</em>"), they are joined with (unescaped) colons. However, if the <code>-0</code> option was passed, no backslash escaping is performed, and multiple values are joined with NUL bytes. For example, after "zsh -o foo:foo -o bar:bar -o <TAB>", the contents of "opt_args" would be</p>
<p>example(typeset -A opt_args=( [-o]='foo\:foo:bar\:bar:' ))</p>
<p>by default, and</p>
<p>example(typeset -A opt_args=( [-o]=$'foo:foo\x00bar:bar\x00' ))</p>
<p>if <code>_arguments</code> had been called with the <code>-0</code> option.</p>
<p>The parameter "context" is set when returning to the calling function to perform an action of the form <code></code>->"<em>string</em>". It is set to an array of elements corresponding to the elements of <code>$state</code>. Each element is a suitable name for the argument field of the context: either a string of the form <code></code>option<code>_-opt_"-"_n_" for the _n_"th argument of the option _-opt_, or a string of the form </code>"argument-"<em>n</em>" for the <em>n</em>"th argument. For "rest" arguments, that is those in the list at the end not handled by position, <em>n</em> is the string "rest". For example, when completing the argument of the <code>-o</code> option, the name is "option-o-1", while for the second normal (non-option-) argument it is "argument-2".</p>
<p>Furthermore, during the evaluation of the <em>action</em> the context name in the <code>curcontext</code> parameter is altered to append the same string that is stored in the <code>context</code> parameter.</p>
<p>The option <code>-C</code> tells <code>_arguments</code> to modify the <code>curcontext</code> parameter for an action of the form <code></code>->"<em>state</em>". This is the standard parameter used to keep track of the current context. Here it (and not the <code>context</code> array) should be made local to the calling function to avoid passing back the modified value and should be initialised to the current value at the start of the function:</p>
<p> local curcontext="$curcontext"</p>
<p>This is useful where it is not possible for multiple states to be valid together.</p>
<p><em>Grouping Options</em></p>
<p>Options can be grouped to simplify exclusion lists. A group is introduced with "+" followed by a name for the group in the subsequent word. Whole groups can then be referenced in an exclusion list or a group name can be used to disambiguate between two forms of the same option. For example:</p>
<p>example(_arguments \ '(group2--x)-a' \ + group1 \ -m \ '(group2)-n' \ + group2 \ -x -y)</p>
<p>If the name of a group is specified in the form <code>tt(()_name_</code>")" then only one value from that group will ever be completed; more formally, all specifications are mutually exclusive to all other specifications in that group. This is useful for defining options that are aliases for each other. For example:</p>
<p>example(_arguments \ -a -b \ + '(operation)' \ {-c,--compress}'[compress]' \ {-d,--decompress}'[decompress]' \ {-l,--list}'[list]')</p>
<p>If an option in a group appears on the command line, it is stored in the associative array "opt_args" with '<em>group</em><code>-"_option_" as a key. In the example above, a key "operation--c" is used if the option "-c" is present on the command line.</code></p>
<p><em>Specifying Multiple Sets of Arguments</em></p>
<p>It is possible to specify multiple sets of options and arguments with the sets separated by single hyphens. This differs from groups in that sets are considered to be mutually exclusive of each other.</p>
<p>Specifications before the first set and from any group are common to all sets. For example:</p>
<p>example(_arguments \ -a \ - set1 \ -c \ - set2 \ -d \ ':arg:(x2 y2)')</p>
<p>This defines two sets. When the command line contains the option "-c", the "-d" option and the argument will not be considered possible completions. When it contains "-d" or an argument, the option "-c" will not be considered. However, after "-a" both sets will still be considered valid.</p>
<p>As for groups, the name of a set may appear in exclusion lists, either alone or preceding a normal option or argument specification.</p>
<p>The completion code has to parse the command line separately for each set. This can be slow so sets should only be used when necessary. A useful alternative is often an option specification with rest-arguments (as in "-foo:*:..."); here the option <code>-foo</code> swallows up all remaining arguments as described by the <em>optarg</em> definitions.</p>
<p>_Deriving <em>spec</em> forms from the help output_</p>
<p>The option <code></code>-"-" allows <code>_arguments</code> to work out the names of long options that support the <code></code>-"-help" option which is standard in many GNU commands. The command word is called with the argument <code></code>-"-help" and the output examined for option names. Clearly, it can be dangerous to pass this to commands which may not support this option as the behaviour of the command is unspecified.</p>
<p>In addition to options, <code></code>_arguments -"-" will try to deduce the types of arguments available for options when the form <code></code>-<code></code>-<code>_opt_</code>="<em>val</em>" is valid. It is also possible to provide hints by examining the help text of the command and adding <em>helpspec</em> of the form <code>_pattern_</code>:<code>_message_</code>:"<em>action</em>"; note that other <code>_arguments</code> <em>spec</em> forms are not used. The <em>pattern</em> is matched against the help text for an option, and if it matches the <em>message</em> and <em>action</em> are used as for other argument specifiers. The special case of "*:" means both <em>message</em> and <em>action</em> are empty, which has the effect of causing options having no description in the help output to be ordered in listings ahead of options that have a description.</p>
<p>For example:</p>
<p>example(_arguments -- '*\*:toggle:(yes no)' \ '*=FILE*:file:_files' \ '*=DIR*:directory:_files -/' \ '*=PATH*:directory:_files -/')</p>
<p>Here, "yes" and "no" will be completed as the argument of options whose description ends in a star; file names will be completed for options that contain the substring "=FILE" in the description; and directories will be completed for options whose description contains "=DIR" or "=PATH". The last three are in fact the default and so need not be given explicitly, although it is possible to override the use of these patterns. A typical help text which uses this feature is:</p>
<p> -C, --directory=DIR change to directory DIR</p>
<p>so that the above specifications will cause directories to be completed after <code></code>-"-directory", though not after "-C".</p>
<p>Note also that <code>_arguments</code> tries to find out automatically if the argument for an option is optional. This can be specified explicitly by doubling the colon before the <em>message</em>.</p>
<p>If the <em>pattern</em> ends in "tt((-))", this will be removed from the pattern and the <em>action</em> will be used only directly after the "=", not in the next word. This is the behaviour of a normal specification defined with the form "=-".</p>
<p>By default, the command (with the option "--help") is run after resetting all the locale categories (except for <code>LC_CTYPE</code>) to "C". If the localized help output is known to work, the option "-l" can be specified after the <code></code>_arguments -"-" so that the command is run in the current locale.</p>
<p>The <code></code>_arguments -"-" can be followed by the option <code></code>-i<code> _patterns_' to give patterns for options which are not to be completed. The patterns can be given as the name of an array parameter or as a literal list in parentheses. For example,</code></p>
<p>example(_arguments -- -i \ "(--(en|dis)able-FEATURE*)")</p>
<p>will cause completion to ignore the options <code></code>-"-enable-FEATURE" and <code></code>-"-disable-FEATURE" (this example is useful with GNU <code>configure</code>).</p>
<p>The <code></code>_arguments -"-" form can also be followed by the option <code></code>-s<code> _pair_' to describe option aliases. The _pair_ consists of a list of alternating patterns and corresponding replacements, enclosed in parens and quoted so that it forms a single argument word in the </code>_arguments<code> call.</code></p>
<p>For example, some <code>configure</code>-script help output describes options only as <code></code>-"-enable-foo", but the script also accepts the negated form <code></code>-"-disable-foo". To allow completion of the second form:</p>
<p>example(_arguments -- -s "((#s)--enable- --disable-)")</p>
<p><em>Miscellaneous notes</em></p>
<p>Finally, note that <code>_arguments</code> generally expects to be the primary function handling any completion for which it is used. It may have side effects which change the treatment of any matches added by other functions called after it. To combine <code>_arguments</code> with other functions, those functions should be called either before <code>_arguments</code>, as an <em>action</em> within a <em>spec</em>, or in handlers for <code></code>->"<em>state</em>" actions.</p>
<p>Here is a more general example of the use of <code>_arguments</code>:</p>
<p>example(_arguments '-l+:left border:' \ '-format:paper size:(letter A4)' \ '*-copy:output file:_files::resolution:(300 600)' \ ':postscript file:_files -g \*.\(ps\|eps\)' \ '*:page number:')</p>
<p>This describes three options: "-l", "-format", and "-copy". The first takes one argument described as <code>_left border_' for which no completion will be offered because of the empty action. Its argument may come directly after the "-l" or it may be given as the next word on the line.</code></p>
<p>The "-format" option takes one argument in the next word, described as "<em>paper size</em>" for which only the strings "letter" and "A4" will be completed.</p>
<p>The "-copy" option may appear more than once on the command line and takes two arguments. The first is mandatory and will be completed as a filename. The second is optional (because of the second colon before the description "<em>resolution</em>") and will be completed from the strings "300" and "600".</p>
<p>The last two descriptions say what should be completed as arguments. The first describes the first argument as a "<em>postscript file</em>" and makes files ending in "ps" or "eps" be completed. The last description gives all other arguments the description "<em>page number</em>" but does not offer completions.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_call_program">
<h3><code>_call_program</code> <a class="doc-anchor" href="#doc-lsp-compsys-_call_program">¶</a></h3>
<p>This function provides a mechanism for the user to override the use of an external command. It looks up the <code>command</code> style with the supplied <em>tag</em>. If the style is set, its value is used as the command to execute. The _string_s from the call to <code>_call_program</code>, or from the style if set, are concatenated with spaces between them and the resulting string is evaluated. The return status is the return status of the command called.</p>
<p>By default, the command is run in an environment where all the locale categories (except for <code>LC_CTYPE</code>) are reset to "C" by calling the utility function <code>_comp_locale</code> (see below). If the option "-l" is given, the command is run with the current locale.</p>
<p>If the option "-p" is supplied it indicates that the command output is influenced by the permissions it is run with. If the <code>gain-privileges</code> style is set to true, <code>_call_program</code> will make use of commands such as <code>sudo</code>, if present on the command-line, to match the permissions to whatever the final command is likely to run under. When looking up the <code>gain-privileges</code> and <code>command</code> styles, the command component of the zstyle context will end with a slash ("/") followed by the command that would be used to gain privileges.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_canonical_paths">
<h3><code>_canonical_paths</code> <a class="doc-anchor" href="#doc-lsp-compsys-_canonical_paths">¶</a></h3>
<p>This completion function completes all paths given to it, and also tries to offer completions which point to the same file as one of the paths given (relative path when an absolute path is given, and vice versa; when <code>..</code>'s are present in the word to be completed; and some paths got from symlinks).</p>
<p><code>-A</code>, if specified, takes the paths from the array variable specified. Paths can also be specified on the command line as shown above. <code>-N</code>, if specified, prevents canonicalizing the paths given before using them for completion, in case they are already so. The options <code>-M</code>, <code>-J</code>, <code>-V</code>, <code>-1</code>, <code>-2</code>, <code>-n</code>, <code>-F</code>, <code>-X</code> are passed to <code>compadd</code>.</p>
<p>See <code>_description</code> for a description of <em>tag</em> and <em>descr</em>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_cargo">
<h3><code>_cargo</code> <a class="doc-anchor" href="#doc-lsp-compsys-_cargo">¶</a></h3>
<p>Completion for the Rust <code>cargo</code> command — subcommands, flags, target names, feature names, profile names. Synthesizes from <code>cargo --list</code> and the manifest. Rust-native; no shell-script fallback.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_cat">
<h3><code>_cat</code> <a class="doc-anchor" href="#doc-lsp-compsys-_cat">¶</a></h3>
<p>Completion for <code>cat</code> — file paths only. No subcommands; flags pass through to <code>_files</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_cd">
<h3><code>_cd</code> <a class="doc-anchor" href="#doc-lsp-compsys-_cd">¶</a></h3>
<p>Completion for <code>cd</code> — directory paths from <code>$PWD</code>, <code>$cdpath</code>, and the <code>dirs</code> stack. Honors <code>AUTO_CD</code> and <code>CDABLE_VARS</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_combination">
<h3><code>_combination</code> <a class="doc-anchor" href="#doc-lsp-compsys-_combination">¶</a></h3>
<p>This function is used to complete combinations of values, for example pairs of hostnames and usernames. The <em>style</em> argument gives the style which defines the pairs; it is looked up in a context with the <em>tag</em> specified.</p>
<p>The style name consists of field names separated by hyphens, for example "users-hosts-ports". For each field for a value is already known, a <em>spec</em> of the form <code>_field_</code>="<em>pattern</em>" is given. For example, if the command line so far specifies a user "pws", the argument "users=pws" should appear.</p>
<p>The next argument with no equals sign is taken as the name of the field for which completions should be generated (presumably not one of the _field_s for which the value is known).</p>
<p>The matches generated will be taken from the value of the style. These should contain the possible values for the combinations in the appropriate order (users, hosts, ports in the example above). The values for the different fields are separated by colons. This can be altered with the option <code>-s</code> to <code>_combination</code> which specifies a pattern. Typically this is a character class, as for example "-s "[:@]"" in the case of the <code>users-hosts</code> style. Each <code>_field_</code>="<em>pattern</em>" specification restricts the completions which apply to elements of the style with appropriately matching fields.</p>
<p>If no style with the given name is defined for the given tag, or if none of the strings in style's value match, but a function name of the required field preceded by an underscore is defined, that function will be called to generate the matches. For example, if there is no "users-hosts-ports" or no matching hostname when a host is required, the function "_hosts" will automatically be called.</p>
<p>If the same name is used for more than one field, in both the <code>_field_</code>="<em>pattern</em>" and the argument that gives the name of the field to be completed, the number of the field (starting with one) may be given after the fieldname, separated from it by a colon.</p>
<p>All arguments after the required field name are passed to <code>compadd</code> when generating matches from the style value, or to the functions for the fields if they are called.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_command_names">
<h3><code>_command_names</code> <a class="doc-anchor" href="#doc-lsp-compsys-_command_names">¶</a></h3>
<p>This function completes words that are valid at command position: names of aliases, builtins, hashed commands, functions, and so on. If the <code>-e</code> flag is given, or if the list of precommands contains a non-builtin command (e.g. because <code>_normal -p</code> has been used previously), only hashed commands are completed. The <code>-</code> flag is ignored.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_complete">
<h3><code>_complete</code> <a class="doc-anchor" href="#doc-lsp-compsys-_complete">¶</a></h3>
<p>This completer generates all possible completions in a context-sensitive manner, i.e. using the settings defined with the <code>compdef</code> function explained above and the current settings of all special parameters. This gives the normal completion behaviour.</p>
<p>To complete arguments of commands, <code>_complete</code> uses the utility function <code>_normal</code>, which is in turn responsible for finding the particular function; it is described below. Various contexts of the form <code>-</code><em>context</em><code>-</code> are handled specifically. These are all mentioned above as possible arguments to the <code>#compdef</code> tag.</p>
<p>Before trying to find a function for a specific context, <code>_complete</code> checks if the parameter "compcontext" is set. Setting "compcontext" allows the usual completion dispatching to be overridden which is useful in places such as a function that uses <code>vared</code> for input. If it is set to an array, the elements are taken to be the possible matches which will be completed using the tag "values" and the description "value". If it is set to an associative array, the keys are used as the possible completions and the values (if non-empty) are used as descriptions for the matches. If "compcontext" is set to a string containing colons, it should be of the form <code>_tag_</code>:<code>_descr_</code>:"<em>action</em>". In this case the <em>tag</em> and <em>descr</em> give the tag and description to use and the <em>action</em> indicates what should be completed in one of the forms accepted by the <code>_arguments</code> utility function described below.</p>
<p>Finally, if "compcontext" is set to a string without colons, the value is taken as the name of the context to use and the function defined for that context will be called. For this purpose, there is a special context named <code>-command-line-</code> that completes whole command lines (commands and their arguments). This is not used by the completion system itself but is nonetheless handled when explicitly called.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_completers">
<h3><code>_completers</code> <a class="doc-anchor" href="#doc-lsp-compsys-_completers">¶</a></h3>
<p>This function completes names of completers.</p>
<p>- <strong><code>-p</code></strong> — Include the leading underscore ("_") in the matches.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_correct">
<h3><code>_correct</code> <a class="doc-anchor" href="#doc-lsp-compsys-_correct">¶</a></h3>
<p>Generate corrections, but not completions, for the current word; this is similar to <code>_approximate</code> but will not allow any number of extra characters at the cursor as that completer does. The effect is similar to spell-checking. It is based on <code>_approximate</code>, but the completer field in the context name is <code>correct</code>.</p>
<p>For example, with:</p>
<p> zstyle ':completion:::::' completer \ _complete _correct _approximate zstyle ':completion:*:correct:::' max-errors 2 not-numeric zstyle ':completion:*:approximate:::' max-errors 3 numeric</p>
<p>correction will accept up to two errors. If a numeric argument is given, correction will not be performed, but correcting completion will be, and will accept as many errors as given by the numeric argument. Without a numeric argument, first correction and then correcting completion will be tried, with the first one accepting two errors and the second one accepting three errors.</p>
<p>When <code>_correct</code> is called as a function, the number of errors to accept may be given following the <code>-a</code> option. The argument is in the same form a values to the <code>accept</code> style, all in one string.</p>
<p>This completer function is intended to be used without the <code>_approximate</code> completer or, as in the example, just before it. Using it after the <code>_approximate</code> completer is useless since <code>_approximate</code> will at least generate the corrected strings generated by the <code>_correct</code> completer DASH()- and probably more.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_cp">
<h3><code>_cp</code> <a class="doc-anchor" href="#doc-lsp-compsys-_cp">¶</a></h3>
<p>Completion for <code>cp</code> — flags + file paths. Source paths exclude the destination; destination directory is offered as the final candidate.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_describe">
<h3><code>_describe</code> <a class="doc-anchor" href="#doc-lsp-compsys-_describe">¶</a></h3>
<p>This function associates completions with descriptions. Multiple groups separated by <code>-</code><code>-</code> can be supplied, potentially with different completion options _opt_s.</p>
<p>The <em>descr</em> is taken as a string to display above the matches if the <code>format</code> style for the <code>descriptions</code> tag is set. This is followed by one or two names of arrays followed by options to pass to <code>compadd</code>. The array <em>name1</em> contains the possible completions with their descriptions in the form <code>_completion_</code>:"<em>description</em>". Any literal colons in <em>completion</em> must be quoted with a backslash. If a <em>name2</em> is given, it should have the same number of elements as <em>name1</em>; in this case the corresponding elements are added as possible completions instead of the <em>completion</em> strings from <em>name1</em>. The completion list will retain the descriptions from <em>name1</em>. Finally, a set of completion options can appear.</p>
<p>If the option "-o" appears before the first argument, the matches added will be treated as names of command options (N.B. not shell options), typically following a "-", <code></code>-"-" or "+" on the command line. In this case <code>_describe</code> uses the <code>prefix-hidden</code>, <code>prefix-needed</code> and <code>verbose</code> styles to find out if the strings should be added as completions and if the descriptions should be shown. Without the "-o" option, only the <code>verbose</code> style is used to decide how descriptions are shown. If "-O" is used instead of "-o", command options are completed as above but <code>_describe</code> will not handle the <code>prefix-needed</code> style.</p>
<p>With the <code>-t</code> option a <em>tag</em> can be specified. The default is "values" or, if the <code>-o</code> option is given, "options".</p>
<p>The options <code>-1</code>, <code>-2</code>, <code>-J</code>, <code>-V</code>, <code>-x</code> are passed to <code>_next_label</code>.</p>
<p>If selected by the <code>list-grouped</code> style, strings with the same description will appear together in the list.</p>
<p><code>_describe</code> uses the <code>_all_labels</code> function to generate the matches, so it does not need to appear inside a loop over tag labels.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_description">
<h3><code>_description</code> <a class="doc-anchor" href="#doc-lsp-compsys-_description">¶</a></h3>
<p>This function is not to be confused with the previous one; it is used as a helper function for creating options to <code>compadd</code>. It is buried inside many of the higher level completion functions and so often does not need to be called directly.</p>
<p>The styles listed below are tested in the current context using the given <em>tag</em>. The resulting options for <code>compadd</code> are put into the array named <em>name</em> (this is traditionally "expl", but this convention is not enforced). The description for the corresponding set of matches is passed to the function in <em>descr</em>.</p>
<p>The styles tested are: <code>format</code>, <code>hidden</code>, <code>matcher</code>, <code>ignore-line</code>, <code>ignored-patterns</code>, <code>group-name</code> and <code>sort</code>. The <code>format</code> style is first tested for the given <em>tag</em> and then for the <code>descriptions</code> tag if no value was found, while the remainder are only tested for the tag given as the first argument. The function also calls <code>_setup</code> which tests some more styles.</p>
<p>The string returned by the <code>format</code> style (if any) will be modified so that the sequence "%d" is replaced by the <em>descr</em> given as the third argument without any leading or trailing white space. If, after removing the white space, the <em>descr</em> is the empty string, the format style will not be used and the options put into the <em>name</em> array will not contain an explanation string to be displayed above the matches.</p>
<p>If <code>_description</code> is called with more than three arguments, the additional _spec_s should be of the form <code>_char_</code>:"<em>str</em>". These supply escape sequence replacements for the <code>format</code> style: every appearance of <code></code>%"<em>char</em>" will be replaced by <em>string</em>. If no additional _spec_s are given but the description in <em>descr</em> conforms to a common form then further escape sequences are set for elements of that description. These elements correspond to a default value ("%o"), the units ("%m") range of acceptable values ("%r") and the remaining initial part of the description ("%h"). The form the description takes consists of specifying the units and range in parentheses and the default value in square brackets, for example:</p>
<p>example(_description times expl 'timeout (seconds) (0-60) [20]')</p>
<p>It is possible to use <code>zformat</code> conditional expressions when styling these elements. So, for example, to add "default:" as a tag but only when there is a default value to show, the <code>format</code> style might include "tt(%(o.default: %o.))".</p>
<p>If the <code>-x</code> option is given, the description will be passed to <code>compadd</code> using the <code>-x</code> option instead of the default <code>-X</code>. This means that the description will be displayed even if there are no corresponding matches.</p>
<p>The options placed in the array <em>name</em> take account of the <code>group-name</code> style, so matches are placed in a separate group where necessary. The group normally has its elements sorted (by passing the option <code>-J</code> to <code>compadd</code>), but if an option starting with "-V", "-J", "-1", or "-2" is passed to <code>_description</code>, that option will be included in the array. Hence it is possible for the completion group to be unsorted by giving the option "-V", "-1V", or "-2V".</p>
<p>In most cases, the function will be used like this:</p>
<p> local expl _description files expl file compadd "$expl[@]" - "$files[@]"</p>
<p>Note the use of the parameter <code>expl</code>, the hyphen, and the list of matches. Almost all calls to <code>compadd</code> within the completion system use a similar format; this ensures that user-specified styles are correctly passed down to the builtins which implement the internals of completion.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_dir_list">
<h3><code>_dir_list</code> <a class="doc-anchor" href="#doc-lsp-compsys-_dir_list">¶</a></h3>
<p>Complete a list of directory names separated by colons (the same format as <code>$PATH</code>).</p>
<p>- <strong><code>-s</code> <em>sep</em></strong> — Use <em>sep</em> as separator between items. <em>sep</em> defaults to a colon (":").</p>
<p>- <strong><code>-S</code></strong> — Add <em>sep</em> instead of slash ("/") as an autoremoveable suffix.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_directories">
<h3><code>_directories</code> <a class="doc-anchor" href="#doc-lsp-compsys-_directories">¶</a></h3>
<p>Complete directory names only. Equivalent to <code>_files -/</code>. Honors <code>path-files</code> zstyle and respects <code>GLOB_DOTS</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_dispatch">
<h3><code>_dispatch</code> <a class="doc-anchor" href="#doc-lsp-compsys-_dispatch">¶</a></h3>
<p>This sets the current context to <em>context</em> and looks for completion functions to handle this context by hunting through the list of command names or special contexts (as described above for <code>compdef</code>) given as _string_s. The first completion function to be defined for one of the contexts in the list is used to generate matches. Typically, the last <em>string</em> is <code>-default-</code> to cause the function for default completion to be used as a fallback.</p>
<p>The function sets the parameter <code>$service</code> to the <em>string</em> being tried, and sets the <em>context/command</em> field (the fourth) of the <code>$curcontext</code> parameter to the <em>context</em> given as the first argument.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_docker">
<h3><code>_docker</code> <a class="doc-anchor" href="#doc-lsp-compsys-_docker">¶</a></h3>
<p>Completion for the <code>docker</code> CLI — subcommands, image names, container names/IDs, network names, volume names. Queries the local daemon socket via the <code>docker</code> binary; falls back to static-only when the daemon is unavailable.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_email_addresses">
<h3><code>_email_addresses</code> <a class="doc-anchor" href="#doc-lsp-compsys-_email_addresses">¶</a></h3>
<p>Complete email addresses. Addresses are provided by plugins.</p>
<p>- <strong><code>-c</code></strong> — Complete bare <code>localhost@domain.tld</code> addresses, without a name part or a comment. Without this option, RFC822 <code>_Firstname Lastname_ </code><<code>_address_</code>><code>' strings are completed.</code></p>
<p>- <strong><code>-n</code> <em>plugin</em></strong> — Complete aliases from <em>plugin</em>.</p>
<p>COMMENT(Intentionally leaving <code>-s</code> undocumented: new code should use <code>_sequence</code> instead.)\</p>
<p>The following plugins are available by default: <code>_email-ldap</code> (see the <code>filter</code> style), <code>_email-local</code> (completes <em>user</em><code>@</code><em>hostname</em> Unix addresses), <code>_email-mail</code> (completes aliases from <code>~/.mailrc</code>), <code>_email-mush</code>, <code>_email-mutt</code>, and <code>_email-pine</code>.</p>
<p>Addresses from the <code>_email-</code><em>foo</em> plugin are added under the tag <code></code>email-"<em>foo</em>".</p>
<p><em>Writing plugins</em></p>
<p>Plugins are written as separate functions with names starting with "_email-". They are invoked with the <code>-c</code> option and <code>compadd</code> options. They should either do their own completion or set the <code>$reply</code> array to a list of <code>_alias_</code>:"<em>address</em>" elements and return <code>300</code>. New plugins will be picked up and run automatically.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_expand">
<h3><code>_expand</code> <a class="doc-anchor" href="#doc-lsp-compsys-_expand">¶</a></h3>
<p>This completer function does not really perform completion, but instead checks if the word on the command line is eligible for expansion and, if it is, gives detailed control over how this expansion is done. For this to happen, the completion system needs to be invoked with <code>complete-word</code>, not <code>expand-or-complete</code> (the default binding for <code>TAB"), as otherwise the string will be expanded by the shell"s internal mechanism before the completion system is started. Note also this completer should be called before the </code>_complete<code> completer function.</code></p>
<p>The tags used when generating expansions are <code>all-expansions</code> for the string containing all possible expansions, <code>expansions</code> when adding the possible expansions as single matches and <code>original</code> when adding the original string from the line. The order in which these strings are generated, if at all, can be controlled by the <code>group-order</code> and <code>tag-order</code> styles, as usual.</p>
<p>The format string for <code>all-expansions</code> and for <code>expansions</code> may contain the sequence "%o" which will be replaced by the original string from the line.</p>
<p>The kind of expansion to be tried is controlled by the <code>substitute</code>, <code>glob</code> and <code>subst-globs-only</code> styles.</p>
<p>It is also possible to call <code>_expand</code> as a function, in which case the different modes may be selected with options: <code>-s</code> for <code>substitute</code>, <code>-g</code> for <code>glob</code> and <code>-o</code> for <code>subst-globs-only</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_files">
<h3><code>_files</code> <a class="doc-anchor" href="#doc-lsp-compsys-_files">¶</a></h3>
<p>The function <code>_files</code> is a wrapper around <code>_path_files</code>. It supports all of the same functionality, with some enhancements DASH()- notably, it respects the <code>list-dirs-first</code> style, and it allows users to override the behaviour of the <code>-g</code> and <code>-/</code> options with the <code>file-patterns</code> style. <code>_files</code> should therefore be preferred over <code>_path_files</code> in most cases.</p>
<p>This function accepts the full set of options allowed by <code>_path_files</code>, described below.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_git">
<h3><code>_git</code> <a class="doc-anchor" href="#doc-lsp-compsys-_git">¶</a></h3>
<p>Completion for <code>git</code> — subcommands, branches, tags, refs, remotes, file paths sensitive to <code>git status</code>. The most heavily-used compsys function in practice; Rust-native rewrite is several hundred times faster than the upstream shell implementation.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_grep">
<h3><code>_grep</code> <a class="doc-anchor" href="#doc-lsp-compsys-_grep">¶</a></h3>
<p>Completion for <code>grep</code> (GNU/BSD-flavor-aware) — flags then file paths. First positional argument is the pattern (no completion offered for free-text patterns).</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_history">
<h3><code>_history</code> <a class="doc-anchor" href="#doc-lsp-compsys-_history">¶</a></h3>
<p>Complete words from the shell's command history. This completer can be controlled by the <code>remove-all-dups</code>, and <code>sort</code> styles as for the <code>_history_complete_word</code> bindable command, see <em>Bindable Commands</em> (below) and <em>Completion System Configuration</em> (above).</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_ignored">
<h3><code>_ignored</code> <a class="doc-anchor" href="#doc-lsp-compsys-_ignored">¶</a></h3>
<p>The <code>ignored-patterns</code> style can be set to a list of patterns which are compared against possible completions; matching ones are removed. With this completer those matches can be reinstated, as if no <code>ignored-patterns</code> style were set. The completer actually generates its own list of matches; which completers are invoked is determined in the same way as for the <code>_prefix</code> completer. The <code>single-ignored</code> style is also available as described above.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_kubectl">
<h3><code>_kubectl</code> <a class="doc-anchor" href="#doc-lsp-compsys-_kubectl">¶</a></h3>
<p>Completion for <code>kubectl</code> — subcommands, resource kinds, resource names (queried via <code>kubectl get</code>), context/namespace names from kubeconfig.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_ls">
<h3><code>_ls</code> <a class="doc-anchor" href="#doc-lsp-compsys-_ls">¶</a></h3>
<p>Completion for <code>ls</code> — flags + file paths. Option specs plus file-path completion via <code>_files</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_main_complete">
<h3><code>_main_complete</code> <a class="doc-anchor" href="#doc-lsp-compsys-_main_complete">¶</a></h3>
<p>Top-level entry the compsys dispatcher calls for every completion attempt. Walks the configured completer list (<code>_complete</code> / <code>_approximate</code> / <code>_match</code> / …), invoking each until one returns matches. Sets <code>$compstate[insert]</code> based on the result.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_match">
<h3><code>_match</code> <a class="doc-anchor" href="#doc-lsp-compsys-_match">¶</a></h3>
<p>This completer is intended to be used after the <code>_complete</code> completer. It behaves similarly but the string on the command line may be a pattern to match against trial completions. This gives the effect of the <code>GLOB_COMPLETE</code> option.</p>
<p>Normally completion will be performed by taking the pattern from the line, inserting a "*" at the cursor position and comparing the resulting pattern with the possible completions generated. This can be modified with the <code>match-original</code> style described above.</p>
<p>The generated matches will be offered in a menu completion unless the <code>insert-unambiguous</code> style is set to "true"; see the description above for other options for this style.</p>
<p>Note that matcher specifications defined globally or used by the completion functions (the styles <code>matcher-list</code> and <code>matcher</code>) will not be used.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_menu">
<h3><code>_menu</code> <a class="doc-anchor" href="#doc-lsp-compsys-_menu">¶</a></h3>
<p>This completer was written as simple example function to show how menu completion can be enabled in shell code. However, it has the notable effect of disabling menu selection which can be useful with <code>_generic</code> based widgets. It should be used as the first completer in the list. Note that this is independent of the setting of the <code>MENU_COMPLETE</code> option and does not work with the other menu completion widgets such as <code>reverse-menu-complete</code>, or <code>accept-and-menu-complete</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_message">
<h3><code>_message</code> <a class="doc-anchor" href="#doc-lsp-compsys-_message">¶</a></h3>
<p>The <em>descr</em> is used in the same way as the third argument to the <code>_description</code> function, except that the resulting string will always be shown whether or not matches were generated. This is useful for displaying a help message in places where no completions can be generated.</p>
<p>The <code>format</code> style is examined with the <code>messages</code> tag to find a message; the usual tag, <code>descriptions</code>, is used only if the style is not set with the former.</p>
<p>If the <code>-r</code> option is given, no style is used; the <em>descr</em> is taken literally as the string to display. This is most useful when the <em>descr</em> comes from a pre-processed argument list which already contains an expanded description. Note that this option does not disable the "%"-sequence parsing done by <code>compadd</code>.</p>
<p>The <code>-12VJ</code> options and the <em>group</em> are passed to <code>compadd</code> and hence determine the group the message string is added to.</p>
<p>The second <code>-e</code> form gives a description for completions with the tag <em>tag</em> to be shown even if there are no matches for that tag. This form is called by <code>_arguments</code> in the event that there is no action for an option specification. The tag can be omitted and if so the tag is taken from the parameter <code>$curtag</code>; this is maintained by the completion system and so is usually correct. Note that if there are no matches at the time this function is called, <code>compstate[insert]</code> is cleared, so additional matches generated later are not inserted on the command line.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_multi_parts">
<h3><code>_multi_parts</code> <a class="doc-anchor" href="#doc-lsp-compsys-_multi_parts">¶</a></h3>
<p>The argument <em>sep</em> is a separator character. The <em>array</em> may be either the name of an array parameter or a literal array in the form <code>tt((foo bar)</code>")", a parenthesised list of words separated by whitespace. The possible completions are the strings from the array. However, each chunk delimited by <em>sep</em> will be completed separately. For example, the <code>_tar</code> function uses <code></code>_multi_parts<code> </code>/" <em>patharray</em>" to complete partial file paths from the given array of complete file paths.</p>
<p>The <code>-i</code> option causes <code>_multi_parts</code> to insert a unique match even if that requires multiple separators to be inserted. This is not usually the expected behaviour with filenames, but certain other types of completion, for example those with a fixed set of possibilities, may be more suited to this form.</p>
<p>Like other utility functions, this function accepts the "-V", "-J", "-1", "-2", "-n", "-f", "-X", "-M", "-P", "-S", "-r", "-R", and "-q" options and passes them to the <code>compadd</code> builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_mv">
<h3><code>_mv</code> <a class="doc-anchor" href="#doc-lsp-compsys-_mv">¶</a></h3>
<p>Completion for <code>mv</code> — flags + file/directory paths. Source/destination split identical to <code>_cp</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_next_label">
<h3><code>_next_label</code> <a class="doc-anchor" href="#doc-lsp-compsys-_next_label">¶</a></h3>
<p>This function is used to implement the loop over different tag labels for a particular tag as described above for the <code>tag-order</code> style. On each call it checks to see if there are any more tag labels; if there is it returns status zero, otherwise non-zero. As this function requires a current tag to be set, it must always follow a call to <code>_tags</code> or <code>_requested</code>.</p>
<p>The <code>-x12VJ</code> options and the first three arguments are passed to the <code>_description</code> function. Where appropriate the <em>tag</em> will be replaced by a tag label in this call. Any description given in the <code>tag-order</code> style is preferred to the <em>descr</em> passed to <code>_next_label</code>.</p>
<p>The _option_s given after the <em>descr</em> are set in the parameter given by <em>name</em>, and hence are to be passed to <code>compadd</code> or whatever function is called to add the matches.</p>
<p>Here is a typical use of this function for the tag <code>foo</code>. The call to <code>_requested</code> determines if tag <code>foo</code> is required at all; the loop over <code>_next_label</code> handles any labels defined for the tag in the <code>tag-order</code> style.</p>
<p> local expl ret=1 ... if _requested foo; then ... while _next_label foo expl '...'; do compadd "$expl[@]" ... && ret=0 done ... fi return ret</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_normal">
<h3><code>_normal</code> <a class="doc-anchor" href="#doc-lsp-compsys-_normal">¶</a></h3>
<p>This is the standard function called to handle completion outside any special <code>-</code><em>context</em><code>-</code>. It is called both to complete the command word and also the arguments for a command. In the second case, <code>_normal</code> looks for a special completion for that command, and if there is none it uses the completion for the <code>-default-</code> context.</p>
<p>A second use is to reexamine the command line specified by the <code>$words</code> array and the <code>$CURRENT</code> parameter after those have been modified. For example, the function <code>_precommand</code>, which completes after precommand specifiers such as <code>nohup</code>, removes the first word from the <code>words</code> array, decrements the <code>CURRENT</code> parameter, then calls "_normal -p $service". The effect is that <code></code>nohup" <em>cmd ...</em>" is treated in the same way as "<em>cmd ...</em>".</p>
<p>- <strong><code>-P</code></strong> — Reset the list of precommands. This option should be used if completing a command line which allows internal commands (e.g. builtins and functions) regardless of prior precommands (e.g. "zsh -c").</p>
<p>- <strong><code>-p</code> <em>precommand</em></strong> — Append <em>precommand</em> to the list of precommands. This option should be used in nearly all cases in which <code>-P</code> is not applicable. An advantage of using this option is that it can automatically signal to <code>_command_names</code> that subsequent completion should be limited to hashed commands, which is usually the desired behaviour following commands like <code>chroot</code> and <code>nohup</code>.</p>
<p>If the command name matches one of the patterns given by one of the options <code>-p</code> or <code>-P</code> to <code>compdef</code>, the corresponding completion function is called and then the parameter <code>_compskip</code> is checked. If it is set completion is terminated at that point even if no matches have been found. This is the same effect as in the <code>-first-</code> context.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_numbers">
<h3><code>_numbers</code> <a class="doc-anchor" href="#doc-lsp-compsys-_numbers">¶</a></h3>
<p>This can be used where a number is followed by a suffix to indicate the units. The unit suffixes are completed and can also be included in the description used when completion is invoked for the preceding number.</p>
<p>In addition to common <code>compadd</code> options, <code>_numbers</code> accepts the following options:</p>
<p>- <strong><code>-t</code> <em>tag</em></strong> — Specify a tag to use instead of the default of <code>numbers</code>.</p>
<p>- <strong><code>-u</code> <em>units</em></strong> — Indicate the default units for the number, e.g. <code>bytes</code>.</p>
<p>- <strong><code>-l</code> <em>min</em></strong> — Specify the lowest possible value for the number.</p>
<p>- <strong><code>-m</code> <em>max</em></strong> — Specify the highest possible value for the number.</p>
<p>- <strong><code>-d</code> <em>default</em></strong> — Specify the default value.</p>
<p>- <strong><code>-N</code></strong> — Allow negative numbers. This is implied if the range includes a negative.</p>
<p>- <strong><code>-f</code></strong> — Allow decimal numbers.</p>
<p>Where a particular suffix represents the default units for a number, it should be prefixed with a colon. Additionally, suffixes can be followed by a colon and a description. So for example, the following allows the age of something to be specified, either in seconds or with an optional suffix with a longer unit of time:</p>
<p> _numbers -u seconds age :s:seconds m:minutes h:hours d:days</p>
<p>It is typically helpful for units to be presented in order of magnitude when completed. To facilitate this, the order in which they are given is preserved.</p>
<p>When the <code>format</code> style is looked up with the <code>descriptions</code> tag or the tag specified with <code>-t</code>, the list of suffixes is available as a "%x" escape sequence. This is in addition to the usual sequences documented under the <code>format</code> style. The form this list takes can also be configured. To this end, the <code>format</code> style is first looked up with the tag <code>unit-suffixes</code>. The retrieved format is applied to each suffix in turn and the results are then concatenated to form the completed list. For the <code>unit-suffixes</code> format, "%x" expands to the individual suffix and "%X" to its description. <code>%d</code>' indicates a default suffix and can be used in a condition. The index and reverse index are set in "%i" and "%r" respectively and are useful for text included only with the first and last suffixes in the list. So for example, the following joins the suffixes together as a comma-separated list:</p>
<p>example(zstyle ':completion:*:unit-suffixes' format '%x%(r::,)')</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_path_files">
<h3><code>_path_files</code> <a class="doc-anchor" href="#doc-lsp-compsys-_path_files">¶</a></h3>
<p>This function is used throughout the completion system to complete filenames. It allows completion of partial paths. For example, the string "/u/i/s/sig" may be completed to "/usr/include/sys/signal.h".</p>
<p>The options accepted by both <code>_path_files</code> and <code>_files</code> are:</p>
<p>- <strong><code>-f</code></strong> — Complete all filenames. This is the default.</p>
<p>- <strong><code>-/</code></strong> — Specifies that only directories should be completed.</p>
<p>- <strong><code>-g</code> <em>pattern</em></strong> — Specifies that only files matching the <em>pattern</em> should be completed.</p>
<p>- <strong><code>-W</code> <em>paths</em></strong> — Specifies path prefixes that are to be prepended to the string from the command line to generate the filenames but that should not be inserted as completions nor shown in completion listings. Here, <em>paths</em> may be the name of an array parameter, a literal list of paths enclosed in parentheses or an absolute pathname.</p>
<p>- <strong><code>-F</code> <em>ignored-files</em></strong> — This behaves as for the corresponding option to the <code>compadd</code> builtin. It gives direct control over which filenames should be ignored. If the option is not present, the <code>ignored-patterns</code> style is used.</p>
<p>Both <code>_path_files</code> and <code>_files</code> also accept the following options which are passed to <code>compadd</code>: "-J", "-V", "-1", "-2", "-n", "-X", "-M", "-P", "-S", "-q", "-r", and "-R".</p>
<p>Finally, the <code>_path_files</code> function uses the styles <code>expand</code>, <code>ambiguous</code>, <code>special-dirs</code>, <code>list-suffixes</code> and <code>file-sort</code> described above.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_pick_variant">
<h3><code>_pick_variant</code> <a class="doc-anchor" href="#doc-lsp-compsys-_pick_variant">¶</a></h3>
<p>This function is used to resolve situations where a single command name requires more than one type of handling, either because it has more than one variant or because there is a name clash between two different commands.</p>
<p>The command to run is taken from the first element of the array <code>words</code> unless this is overridden by the option <code>-c</code>. This command is run and its output is compared with a series of patterns. Arguments to be passed to the command can be specified at the end after all the other arguments. The patterns to try in order are given by the arguments <em>label</em><code>=</code><em>pattern</em>; if the output of <code>_command_ _arg_ ...' contains _pattern_, then _label_ is selected as the label for the command variant. If none of the patterns match, the final command label is selected and status 1 is returned.</code></p>
<p>If the <code></code>-b" <em>builtin-label</em>" is given, the command is tested to see if it is provided as a shell builtin, possibly autoloaded; if so, the label <em>builtin-label</em> is selected as the label for the variant.</p>
<p>If the <code></code>-r" <em>name</em>" is given, the <em>label</em> picked is stored in the parameter named <em>name</em>.</p>
<p>The results are also cached in the <code>_cmd_variant</code> associative array indexed by the name of the command run.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_prefix">
<h3><code>_prefix</code> <a class="doc-anchor" href="#doc-lsp-compsys-_prefix">¶</a></h3>
<p>This completer can be used to try completion with the suffix (everything after the cursor) ignored. In other words, the suffix will not be considered to be part of the word to complete. The effect is similar to the <code>expand-or-complete-prefix</code> command.</p>
<p>The <code>completer</code> style is used to decide which other completers are to be called to generate matches. If this style is unset, the list of completers set for the current context is used DASH()- except, of course, the <code>_prefix</code> completer itself. Furthermore, if this completer appears more than once in the list of completers only those completers not already tried by the last invocation of <code>_prefix</code> will be called.</p>
<p>For example, consider this global <code>completer</code> style:</p>
<p> zstyle ':completion:*' completer \ _complete _prefix _correct _prefix:foo</p>
<p>Here, the <code>_prefix</code> completer tries normal completion but ignoring the suffix. If that doesn't generate any matches, and neither does the call to the <code>_correct</code> completer after it, <code>_prefix</code> will be called a second time and, now only trying correction with the suffix ignored. On the second invocation the completer part of the context appears as "foo".</p>
<p>To use <code>_prefix</code> as the last resort and try only normal completion when it is invoked:</p>
<p> zstyle ':completion:*' completer _complete ... _prefix zstyle ':completion::prefix:*' completer _complete</p>
<p>The <code>add-space</code> style is also respected. If it is set to "true" then <code>_prefix</code> will insert a space between the matches generated (if any) and the suffix.</p>
<p>Note that this completer is only useful if the <code>COMPLETE_IN_WORD</code> option is set; otherwise, the cursor will be moved to the end of the current word before the completion code is called and hence there will be no suffix.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_requested">
<h3><code>_requested</code> <a class="doc-anchor" href="#doc-lsp-compsys-_requested">¶</a></h3>
<p>This function is called to decide whether a tag already registered by a call to <code>_tags</code> (see below) has been requested by the user and hence completion should be performed for it. It returns status zero if the tag is requested and non-zero otherwise. The function is typically used as part of a loop over different tags as follows:</p>
<p> _tags foo bar baz while _tags; do if _requested foo; then ... # perform completion for foo fi ... # test the tags bar and baz in the same way ... # exit loop if matches were generated done</p>
<p>Note that the test for whether matches were generated is not performed until the end of the <code>_tags</code> loop. This is so that the user can set the <code>tag-order</code> style to specify a set of tags to be completed at the same time.</p>
<p>If <em>name</em> and <em>descr</em> are given, <code>_requested</code> calls the <code>_description</code> function with these arguments together with the options passed to <code>_requested</code>.</p>
<p>If <em>command</em> is given, the <code>_all_labels</code> function will be called immediately with the same arguments. In simple cases this makes it possible to perform the test for the tag and the matching in one go. For example:</p>
<p>example(local expl ret=1 _tags foo bar baz while _tags; do _requested foo expl 'description' \ compadd foobar foobaz && ret=0 ... (( ret )) || break done)</p>
<p>If the <em>command</em> is not <code>compadd</code>, it must nevertheless be prepared to handle the same options.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_rm">
<h3><code>_rm</code> <a class="doc-anchor" href="#doc-lsp-compsys-_rm">¶</a></h3>
<p>Completion for <code>rm</code> — flags + file paths. <code>-r</code> enables directory completion; without it, directories are filtered out.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_sep_parts">
<h3><code>_sep_parts</code> <a class="doc-anchor" href="#doc-lsp-compsys-_sep_parts">¶</a></h3>
<p>This function is passed alternating arrays and separators as arguments. The arrays specify completions for parts of strings to be separated by the separators. The arrays may be the names of array parameters or a quoted list of words in parentheses. For example, with the array "tt(hosts=(ftp news))" the call "tt(_sep_parts "(foo bar)' @ hosts)' will complete the string "f" to "foo" and the string "b@n" to "bar@news".</p>
<p>This function accepts the <code>compadd</code> options "-V", "-J", "-1", "-2", "-n", "-X", "-M", "-P", "-S", "-r", "-R", and "-q" and passes them on to the <code>compadd</code> builtin used to add the matches.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_sequence">
<h3><code>_sequence</code> <a class="doc-anchor" href="#doc-lsp-compsys-_sequence">¶</a></h3>
<p>This function is a wrapper to other functions for completing items in a separated list. The same function is used to complete each item in the list. The separator is specified with the <code>-s</code> option. If <code>-s</code> is omitted it will use ",". Duplicate values are not matched unless <code>-d</code> is specified. If there is a fixed or maximum number of items in the list, this can be specified with the <code>-n</code> option.</p>
<p>Common <code>compadd</code> options are passed on to the function. It is possible to use <code>compadd</code> directly with <code>_sequence</code>, though <code>_values</code> may be more appropriate in this situation.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_tags">
<h3><code>_tags</code> <a class="doc-anchor" href="#doc-lsp-compsys-_tags">¶</a></h3>
<p>If called with arguments, these are taken to be the names of tags valid for completions in the current context. These tags are stored internally and sorted by using the <code>tag-order</code> style.</p>
<p>Next, <code>_tags</code> is called repeatedly without arguments from the same completion function. This successively selects the first, second, etc. set of tags requested by the user. The return status is zero if at least one of the tags is requested and non-zero otherwise. To test if a particular tag is to be tried, the <code>_requested</code> function should be called (see above).</p>
<p>If <code></code>-C" <em>name</em>" is given, <em>name</em> is temporarily stored in the <em>argument</em> field (the fifth) of the context in the <code>curcontext</code> parameter during the call to <code>_tags</code>; the field is restored on exit. This allows <code>_tags</code> to use a more specific context without having to change and reset the <code>curcontext</code> parameter (which has the same effect).</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_terraform">
<h3><code>_terraform</code> <a class="doc-anchor" href="#doc-lsp-compsys-_terraform">¶</a></h3>
<p>Completion for <code>terraform</code> — subcommands, workspace names, state-file paths, providers, modules, variable names from the loaded HCL.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_tilde_files">
<h3><code>_tilde_files</code> <a class="doc-anchor" href="#doc-lsp-compsys-_tilde_files">¶</a></h3>
<p>Like <code>_files</code>, but resolve leading tildes according to the rules of filename expansion, so the suggested completions don't start with a "~" even if the filename on the command-line does.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_values">
<h3><code>_values</code> <a class="doc-anchor" href="#doc-lsp-compsys-_values">¶</a></h3>
<p>This is used to complete arbitrary keywords (values) and their arguments, or lists of such combinations.</p>
<p>If the first argument is the option <code></code>-O" <em>name</em>", it will be used in the same way as by the <code>_arguments</code> function. In other words, the elements of the <em>name</em> array will be passed to <code>compadd</code> when executing an action.</p>
<p>If the first argument (or the first argument after <code></code>-O" <em>name</em>") is "-s", the next argument is used as the character that separates multiple values. This character is automatically added after each value in an auto-removable fashion (see below); all values completed by "_values -s" appear in the same word on the command line, unlike completion using <code>_arguments</code>. If this option is not present, only a single value will be completed per word.</p>
<p>Normally, <code>_values</code> will only use the current word to determine which values are already present on the command line and hence are not to be completed again. If the <code>-w</code> option is given, other arguments are examined as well.</p>
<p>The first non-option argument, <em>desc</em>, is used as a string to print as a description before listing the values.</p>
<p>All other arguments describe the possible values and their arguments in the same format used for the description of options by the <code>_arguments</code> function (see above). The only differences are that no minus or plus sign is required at the beginning, values can have only one argument, and the forms of action beginning with an equal sign are not supported.</p>
<p>The character separating a value from its argument can be set using the option <code>-S</code> (like <code>-s</code>, followed by the character to use as the separator in the next argument). By default the equals sign will be used as the separator between values and arguments.</p>
<p>Example:</p>
<p>example(_values -s , 'description' \ '*foo[bar]' \ '(two)*one[number]:first count:' \ 'two[another number]::second count:(1 2 3)')</p>
<p>This describes three possible values: "foo", "one", and "two". The first is described as "bar", takes no argument and may appear more than once. The second is described as "number", may appear more than once, and takes one mandatory argument described as "first count"; no action is specified, so it will not be completed. The "tt((two))" at the beginning says that if the value "one" is on the line, the value "two" will no longer be considered a possible completion. Finally, the last value ("two") is described as "another number" and takes an optional argument described as "second count" for which the completions (to appear after an "=") are "1", "2", and "3". The <code>_values</code> function will complete lists of these values separated by commas.</p>
<p>Like <code>_arguments</code>, this function temporarily adds another context name component to the arguments element (the fifth) of the current context while executing the <em>action</em>. Here this name is just the name of the value for which the argument is completed.</p>
<p>The style <code>verbose</code> is used to decide if the descriptions for the values (but not those for the arguments) should be printed.</p>
<p>The associative array <code>val_args</code> is used to report values and their arguments; this works similarly to the <code>opt_args</code> associative array used by <code>_arguments</code>. Hence the function calling <code>_values</code> should declare the local parameters <code>state</code>, <code>state_descr</code>, <code>line</code>, <code>context</code> and <code>val_args</code>:</p>
<p> local context state state_descr line typeset -A val_args</p>
<p>when using an action of the form <code></code>->"<em>string</em>". With this function the <code>context</code> parameter will be set to the name of the value whose argument is to be completed. Note that for <code>_values</code>, the <code>state</code> and <code>state_descr</code> are scalars rather than arrays. Only a single matching state is returned.</p>
<p>Note also that <code>_values</code> normally adds the character used as the separator between values as an auto-removable suffix (similar to a "/" after a directory). However, this is not possible for a <code></code>->"<em>string</em>" action as the matches for the argument are generated by the calling function. To get the usual behaviour, the calling function can add the separator <em>x</em> as a suffix by passing the options <code></code>-qS" <em>x</em>" either directly or indirectly to <code>compadd</code>.</p>
<p>The option <code>-C</code> is treated in the same way as it is by <code>_arguments</code>. In that case the parameter <code>curcontext</code> should be made local instead of <code>context</code> (as described above).</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_wanted">
<h3><code>_wanted</code> <a class="doc-anchor" href="#doc-lsp-compsys-_wanted">¶</a></h3>
<p>In many contexts, completion can only generate one particular set of matches, usually corresponding to a single tag. However, it is still necessary to decide whether the user requires matches of this type. This function is useful in such a case.</p>
<p>The arguments to <code>_wanted</code> are the same as those to <code>_requested</code>, i.e. arguments to be passed to <code>_description</code>. However, in this case the <em>command</em> is not optional; all the processing of tags, including the loop over both tags and tag labels and the generation of matches, is carried out automatically by <code>_wanted</code>.</p>
<p>Hence to offer only one tag and immediately add the corresponding matches with the given description:</p>
<p> local expl _wanted tag expl 'description' \ compadd -- <em>match1</em> <em>match2</em>...</p>
<p>Note that, as for <code>_requested</code>, the <em>command</em> must be able to accept options to be passed down to <code>compadd</code>.</p>
<p>Like <code>_tags</code> this function supports the <code>-C</code> option to give a different name for the argument context field. The <code>-x</code> option has the same meaning as for <code>_description</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-compsys-_widgets">
<h3><code>_widgets</code> <a class="doc-anchor" href="#doc-lsp-compsys-_widgets">¶</a></h3>
<p>This function completes names of zle widgets (see <em>Zle Widgets</em> (zshzle)). The <em>pattern</em>, if present, is matched against values of the <code>$widgets</code> special parameter, documented in <em>The zsh/zleparameter Module</em> (zshmodules).</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-extensions">
<h2>Extension Builtin Index</h2>
<p class="chapter-meta">123 entries · zshrs-only builtins with NO upstream zsh counterpart. Split across in-process builtins (coreutils drop-ins, <code>async</code>/<code>await</code>/<code>barrier</code>, <code>doctor</code>, <code>intercept</code>, contrib autoloads) and daemon-backed <code>z*</code> builtins (<code>zd</code>, <code>zcache</code>, <code>zls</code>, <code>zlock</code>, <code>zpublish</code>, …) that proxy to the local <code>zshrs-daemon</code> for cross-shell state.</p>
<article class="doc-entry" id="doc-lsp-extension-ai">
<h3><code>ai</code> <a class="doc-anchor" href="#doc-lsp-extension-ai">¶</a></h3>
<p>ai [-m MODEL] [-s SYSTEM] [-P PROVIDER] [-t MAX_TOKENS] [-T TEMP] [-o TIMEOUT] [-n] [-k] [-b] [-v VAR | -a ARRAY] [--] PROMPT... ai -c | -K | -H | -G | -S key=value | -M pattern=response</p>
<p>Call a language model. The response streams to stdout as it arrives; -b buffers it instead, and -v/-a assign it to a shell scalar/array with no fork and no command substitution.</p>
<p>The prompt is read from stdin when no prompt words are given, or when the only word is <code>-</code>. Providers: anthropic (default), openai, local (any OpenAI-compatible server), ollama, gemini. Defaults come from the [ai] table in ~/.zshrs/zshrs.toml; -S changes one for the rest of the session. Exit 1 on a failed call, 2 on bad flags.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-arch">
<h3><code>arch</code> <a class="doc-anchor" href="#doc-lsp-extension-arch">¶</a></h3>
<p>arch — print machine architecture name. Coreutils arch(1) (a synonym for <code>uname -m</code> on most systems). Useful in shell scripts that need a quick <code>[[ $(arch) == arm64 ]]</code> check.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-async">
<h3><code>async</code> <a class="doc-anchor" href="#doc-lsp-extension-async">¶</a></h3>
<p>async { cmd } — run command on worker pool, return job ID immediately. Output captured in background, retrieve with <code>await $id</code>.</p>
<p>Usage: id=$(async 'sleep 2; echo done') ... do other work ... result=$(await $id)</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-await">
<h3><code>await</code> <a class="doc-anchor" href="#doc-lsp-extension-await">¶</a></h3>
<p>await $id — block until async job completes, print its stdout, return its status.</p>
<p>Usage: id=$(async 'expensive_command') await $id # blocks until done, prints output echo $? # exit status of the async command</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-barrier">
<h3><code>barrier</code> <a class="doc-anchor" href="#doc-lsp-extension-barrier">¶</a></h3>
<p>barrier cmd1 ::: cmd2 ::: cmd3 — run commands in parallel, wait for ALL to complete. Returns the worst (highest) exit status.</p>
<p>Usage: barrier 'make -C proj1' ::: 'make -C proj2' ::: 'make -C proj3' barrier 'npm test' ::: 'cargo test' ::: 'pytest'</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-base64">
<h3><code>base64</code> <a class="doc-anchor" href="#doc-lsp-extension-base64">¶</a></h3>
<p>base64 [-d] [FILE] — encode/decode base64. coreutils base64(1) without --wrap (defaults to 76-char wrap on encode; 0 disables).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-basename">
<h3><code>basename</code> <a class="doc-anchor" href="#doc-lsp-extension-basename">¶</a></h3>
<p>Strip leading directories and an optional suffix. <code>basename /a/b.txt .txt</code> → <code>b</code>. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-caller">
<h3><code>caller</code> <a class="doc-anchor" href="#doc-lsp-extension-caller">¶</a></h3>
<p>caller - display call stack (bash) caller [N] — bash builtin returning the location of the current frame N. With no arg or N=0: 'LINE FUNC' (or just 'LINE main' at top level). With N>0: 'LINE FUNC FILE' for frame N. Reads from the existing $funcstack array we now maintain (vm_helper:7828-7835).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-cat">
<h3><code>cat</code> <a class="doc-anchor" href="#doc-lsp-extension-cat">¶</a></h3>
<p>Concatenate files to stdout. <code>-n</code> numbers lines, <code>-A</code> shows tabs/EOLs. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-cdreplay">
<h3><code>cdreplay</code> <a class="doc-anchor" href="#doc-lsp-extension-cdreplay">¶</a></h3>
<p>cdreplay - replay deferred compdef calls (zinit turbo mode) Usage: cdreplay [-q]</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-cksum">
<h3><code>cksum</code> <a class="doc-anchor" href="#doc-lsp-extension-cksum">¶</a></h3>
<p>cksum [FILE...] — POSIX CRC-32 + byte-count + filename. Output: <code><crc> <bytes> <name></code>. With no files or <code>-</code> reads stdin (filename column omitted in that case, per coreutils). Polynomial: 0x04C11DB7, init 0, length appended (POSIX).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-comm">
<h3><code>comm</code> <a class="doc-anchor" href="#doc-lsp-extension-comm">¶</a></h3>
<p>comm [-123] FILE1 FILE2 — line-by-line comparison of two sorted files. Coreutils comm(1) / POSIX. Three columns: (1) unique to FILE1, (2) unique to FILE2, (3) common. Flags <code>-1</code>/<code>-2</code>/<code>-3</code> suppress the respective column. Either file may be <code>-</code> for stdin. Files MUST be sorted in the same collation; comm performs a streaming merge-compare and is undefined-behavior on unsorted input (matches coreutils).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-compdef">
<h3><code>compdef</code> <a class="doc-anchor" href="#doc-lsp-extension-compdef">¶</a></h3>
<p>compdef - register completion functions for commands Usage: compdef _git git compdef _docker docker docker-compose compdef -d git # delete</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-compgen">
<h3><code>compgen</code> <a class="doc-anchor" href="#doc-lsp-extension-compgen">¶</a></h3>
<p>Generate completion candidates</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-compinit">
<h3><code>compinit</code> <a class="doc-anchor" href="#doc-lsp-extension-compinit">¶</a></h3>
<p>Initialize the completion system. Walks <code>$fpath</code> in parallel via rayon, populates the rkyv-mmap'd autoload/completion shards, marks every <code>_*</code> as autoloaded. Default mode skips <code>.zcompdump</code> entirely.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-complete">
<h3><code>complete</code> <a class="doc-anchor" href="#doc-lsp-extension-complete">¶</a></h3>
<p>Define completion spec for a command</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-cut">
<h3><code>cut</code> <a class="doc-anchor" href="#doc-lsp-extension-cut">¶</a></h3>
<p>Extract fields or character ranges. <code>-d':' -f1,3</code> / <code>-c5-10</code>. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-date">
<h3><code>date</code> <a class="doc-anchor" href="#doc-lsp-extension-date">¶</a></h3>
<p>Print or set the system date. <code>+%FORMAT</code> strftime; <code>-d 'rel'</code> parse relative; <code>-u</code> UTC. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-dbview">
<h3><code>dbview</code> <a class="doc-anchor" href="#doc-lsp-extension-dbview">¶</a></h3>
<p>dbview — browse zshrs SQLite cache tables without SQL.</p>
<p>Usage: dbview — list all tables and row counts dbview autoloads — dump autoloads table (name, source, body len, ast len) dbview autoloads _git — show single row by name dbview comps [pattern] — live _comps table (command → completer); --count for the total dbview history — recent history entries dbview history <pattern> — search history dbview plugins — plugin cache entries dbview scripts [pattern] — compiled sourced scripts (scripts.rkyv) dbview executables — PATH executables cache dbview <table> --count — just the count</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-dircolors">
<h3><code>dircolors</code> <a class="doc-anchor" href="#doc-lsp-extension-dircolors">¶</a></h3>
<p>dircolors [-bcp] [FILE] — emit shell commands to set LS_COLORS. Coreutils dircolors(1). Without args, emits the default ls color database. -b for Bourne (export VAR=val), -c for csh (setenv VAR val), -p prints the database. We hard-code coreutils' compiled-in default since shipping the full /etc/DIR_COLORS database file isn't feasible here.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-dirname">
<h3><code>dirname</code> <a class="doc-anchor" href="#doc-lsp-extension-dirname">¶</a></h3>
<p>Strip the last path component. <code>dirname /a/b/c</code> → <code>/a/b</code>. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-doctor">
<h3><code>doctor</code> <a class="doc-anchor" href="#doc-lsp-extension-doctor">¶</a></h3>
<p>doctor [--json] - diagnostic report of shell health, caches, and performance</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-env">
<h3><code>env</code> <a class="doc-anchor" href="#doc-lsp-extension-env">¶</a></h3>
<p>env [-i] [NAME=VALUE]... [COMMAND [ARG]...] — print env or run COMMAND with modified environment.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-expand">
<h3><code>expand</code> <a class="doc-anchor" href="#doc-lsp-extension-expand">¶</a></h3>
<p>expand [-i] [-t TAB] [FILE...] — convert tabs to spaces. coreutils expand(1); <code>-i</code> converts only leading tabs.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-expr">
<h3><code>expr</code> <a class="doc-anchor" href="#doc-lsp-extension-expr">¶</a></h3>
<p>expr ARG... — evaluate expression. POSIX expr(1). Subset port: integer arithmetic (+ - * / %), string match ': REGEX', length STRING, substr STRING POS LEN, index STRING CHARS. Recognizes the closing arg list directly (single-pass shunting-yard would be heavier than needed for the common scripts).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-factor">
<h3><code>factor</code> <a class="doc-anchor" href="#doc-lsp-extension-factor">¶</a></h3>
<p>factor N... — print prime factorization of each integer arg. Coreutils factor(1). Format: <code>N: p1 p2 p3 ...</code>. Reads stdin if no args. Negative numbers and zero are rejected.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-find">
<h3><code>find</code> <a class="doc-anchor" href="#doc-lsp-extension-find">¶</a></h3>
<p>Walk the filesystem and print / act on matches. Supports <code>-name</code>/<code>-type</code>/<code>-mtime</code>/<code>-exec</code>. coreutils drop-in (subset).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-fold">
<h3><code>fold</code> <a class="doc-anchor" href="#doc-lsp-extension-fold">¶</a></h3>
<p>fold [-w WIDTH] [-s] [-b] [FILE...] — wrap input lines. coreutils fold(1).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-groups">
<h3><code>groups</code> <a class="doc-anchor" href="#doc-lsp-extension-groups">¶</a></h3>
<p>groups [USER...] — print group memberships. Coreutils groups(1) / POSIX. With no args, prints groups for the effective user; with args, prints "USER : group1 group2 ..." per user.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-head">
<h3><code>head</code> <a class="doc-anchor" href="#doc-lsp-extension-head">¶</a></h3>
<p>Print the first N lines (<code>-n N</code>) or bytes (<code>-c N</code>) of each file. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-help">
<h3><code>help</code> <a class="doc-anchor" href="#doc-lsp-extension-help">¶</a></h3>
<p>help - display help for builtins (bash)</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-hostname">
<h3><code>hostname</code> <a class="doc-anchor" href="#doc-lsp-extension-hostname">¶</a></h3>
<p>Print the system hostname. <code>-s</code> short, <code>-f</code> FQDN.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-id">
<h3><code>id</code> <a class="doc-anchor" href="#doc-lsp-extension-id">¶</a></h3>
<p>Print user / group IDs. <code>-u</code> user only, <code>-g</code> group only, <code>-n</code> names. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-intercept">
<h3><code>intercept</code> <a class="doc-anchor" href="#doc-lsp-extension-intercept">¶</a></h3>
<p>intercept builtin — register AOP advice on commands.</p>
<p>Usage: intercept before <pattern> { code } intercept after <pattern> { code } intercept around <pattern> { code } intercept list — show all intercepts intercept remove <id> — remove by ID intercept clear — remove all</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-intercept_proceed">
<h3><code>intercept_proceed</code> <a class="doc-anchor" href="#doc-lsp-extension-intercept_proceed">¶</a></h3>
<p>intercept_proceed — called from around advice to execute the original command.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-link">
<h3><code>link</code> <a class="doc-anchor" href="#doc-lsp-extension-link">¶</a></h3>
<p>link FILE1 FILE2 — call link(2) directly to create a hard link from FILE1 to FILE2. POSIX link(1) / coreutils link(1). Unlike <code>ln</code>, link takes EXACTLY two args and rejects flags (POSIX requirement).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-logname">
<h3><code>logname</code> <a class="doc-anchor" href="#doc-lsp-extension-logname">¶</a></h3>
<p>logname — print login name. Coreutils logname(1) / POSIX. Calls getlogin(3) which reads from utmp. Falls back to \$LOGNAME if getlogin fails.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-mkfifo">
<h3><code>mkfifo</code> <a class="doc-anchor" href="#doc-lsp-extension-mkfifo">¶</a></h3>
<p>mkfifo [-m MODE] FILE... — create named pipes (FIFOs). Coreutils mkfifo(1) / POSIX. -m sets the mode (default 0666 minus umask). Each FIFO is created independently; failures are reported per-file and the others continue.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-mktemp">
<h3><code>mktemp</code> <a class="doc-anchor" href="#doc-lsp-extension-mktemp">¶</a></h3>
<p>Create a temp file or directory with a unique name. <code>-d</code> directory, <code>-p DIR</code> parent. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-nice">
<h3><code>nice</code> <a class="doc-anchor" href="#doc-lsp-extension-nice">¶</a></h3>
<p>nice [-n N] [-N N] [COMMAND...] — adjust niceness of the shell process (when no COMMAND given) or report current niceness. Coreutils nice(1) / POSIX nice(1). Without args, print the current niceness (like \<code>nice\</code> with no args). With just -n N, set the niceness for the SHELL ITSELF — not for a subsequently-exec'd command. Setting niceness for a child command requires fork-exec which the in-process model can't do without breaking subsequent commands; for that case callers should use /usr/bin/nice via PATH (zshrs's command dispatch will fall through to the external).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-nl">
<h3><code>nl</code> <a class="doc-anchor" href="#doc-lsp-extension-nl">¶</a></h3>
<p>nl [-b STYLE] [FILE...] — number lines.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-nproc">
<h3><code>nproc</code> <a class="doc-anchor" href="#doc-lsp-extension-nproc">¶</a></h3>
<p>nproc — print number of online CPUs. coreutils nproc(1). --all uses CPU count from sysconf(_SC_NPROCESSORS_CONF); default uses _SC_NPROCESSORS_ONLN (the schedulable subset).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-pany">
<h3><code>pany</code> <a class="doc-anchor" href="#doc-lsp-extension-pany">¶</a></h3>
<p>pany 'cmd {}' arg1 arg2 ... — parallel any. Status 0 as soon as <code>cmd</code> succeeds for some argument, else 1; prints nothing. Remaining arguments are skipped once one passes.</p>
<p>Usage: pany 'grep -q TODO {}' *.rs && echo has-todos</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-par_lines">
<h3><code>par_lines</code> <a class="doc-anchor" href="#doc-lsp-extension-par_lines">¶</a></h3>
<p>par_lines 'cmd {}' FILE — run <code>cmd</code> once per line of FILE, <code>{}</code> replaced by the line. FILE is memory-mapped and split into line-aligned ranges that run in parallel (one shell process per range); output is in file order.</p>
<p>Usage: par_lines 'echo got {}' access.log</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-par_walk">
<h3><code>par_walk</code> <a class="doc-anchor" href="#doc-lsp-extension-par_walk">¶</a></h3>
<p>par_walk 'cmd {}' PATH... — run <code>cmd</code> once per file and directory under each PATH (the PATHs included), <code>{}</code> replaced by the path. The tree is walked in parallel with names sorted within a directory; output is in walk order.</p>
<p>Usage: par_walk 'test -f {} && wc -l {}' src</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-paste">
<h3><code>paste</code> <a class="doc-anchor" href="#doc-lsp-extension-paste">¶</a></h3>
<p>paste [-d LIST] [FILE...] — merge lines of files. coreutils paste(1). Default delim is TAB; -d cycles through the supplied delimiter chars.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-peach">
<h3><code>peach</code> <a class="doc-anchor" href="#doc-lsp-extension-peach">¶</a></h3>
<p>peach 'cmd {}' arg1 arg2 ... — parallel for-each, no output ordering. Like pmap but doesn't collect output — fire-and-forget, print as completed.</p>
<p>Usage: peach 'convert {} {}.png' *.svg peach 'rsync -a {} remote:{}' dir1 dir2 dir3</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-pfirst">
<h3><code>pfirst</code> <a class="doc-anchor" href="#doc-lsp-extension-pfirst">¶</a></h3>
<p>pfirst 'cmd {}' arg1 arg2 ... — print the FIRST argument (lowest position) for which <code>cmd</code> succeeds; status 1 and no output when none does. Arguments past the best match found so far are not tested.</p>
<p>Usage: pfirst 'test -x {}/zsh' /usr/bin /opt/homebrew/bin</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-pgrep">
<h3><code>pgrep</code> <a class="doc-anchor" href="#doc-lsp-extension-pgrep">¶</a></h3>
<p>pgrep 'pattern' arg1 arg2 ... — parallel grep/filter across worker pool. Runs the pattern command for each argument, prints args where command succeeds.</p>
<p>Usage: pgrep 'test -f {}' /path/a /path/b /path/c pgrep 'grep -q TODO {}' *.rs</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-pmap">
<h3><code>pmap</code> <a class="doc-anchor" href="#doc-lsp-extension-pmap">¶</a></h3>
<p>pmap 'cmd {}' arg1 arg2 arg3 — parallel map across worker pool. Runs <code>cmd</code> for each argument, replacing <code>{}</code> with the argument. Output is collected in order. Returns 0 if all succeed.</p>
<p>Usage: pmap 'gzip {}' *.log pmap 'echo {}' a b c d ls *.rs | pmap 'wc -l {}'</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-pmap_chunked">
<h3><code>pmap_chunked</code> <a class="doc-anchor" href="#doc-lsp-extension-pmap_chunked">¶</a></h3>
<p>pmap_chunked N 'cmd {}' arg1 arg2 ... — like pmap, but arguments go to the pool in chunks of N and each chunk runs in ONE shell process, paying process startup once per N items. Output is in argument order.</p>
<p>Usage: pmap_chunked 50 'gzip {}' *.log</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-printenv">
<h3><code>printenv</code> <a class="doc-anchor" href="#doc-lsp-extension-printenv">¶</a></h3>
<p>printenv [VAR...] — print env. coreutils printenv(1). No args: print all env vars in environ order. Args: print VAR's value per arg, exit 1 if any unset.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-profile">
<h3><code>profile</code> <a class="doc-anchor" href="#doc-lsp-extension-profile">¶</a></h3>
<p>profile — in-process command profiling with nanosecond accuracy.</p>
<p>Unlike <code>time</code> (which measures one command) or <code>zprof</code> (which only profiles function calls), <code>profile</code> traces every execute_command, expansion, glob, and builtin dispatch inside the block.</p>
<p>Usage: profile { commands } — profile a block profile -s 'script' — profile a script string profile -f func — profile a function call profile --clear — clear accumulated profile data profile --dump — show accumulated profile data</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-provenance">
<h3><code>provenance</code> <a class="doc-anchor" href="#doc-lsp-extension-provenance">¶</a></h3>
<p>provenance — value lineage over bytecode execution.</p>
<p>Usage: provenance — list every tracked parameter and function provenance NAME — print NAME's lineage provenance -m NAME... — start tracking NAME provenance -u NAME... — stop tracking NAME, drop its lineage provenance -j NAME — print NAME's lineage as JSON provenance -f ... — act on shell functions instead of parameters provenance -a — track everything from here on provenance -ua — stop tracking everything (keeps what is recorded) provenance -c — clear every lineage and disarm</p>
<p>Flags bundle: <code>-mf NAME</code> arms a function, <code>-jf NAME</code> prints one as JSON.</p>
<p>The engine records nothing until the first <code>-m</code> or <code>-a</code> (or <code>[provenance] track_all</code> at startup), and refuses to arm at all when <code>[provenance] enabled = false</code> in <code>~/.zshrs/zshrs.toml</code> or <code>ZSHRS_PROVENANCE=0</code> is set.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-psort">
<h3><code>psort</code> <a class="doc-anchor" href="#doc-lsp-extension-psort">¶</a></h3>
<p>psort [-n] [-r] [ITEM...] — parallel stable sort of the operands, or of stdin lines when none are given. -n compares numerically, -r reverses.</p>
<p>Usage: psort -nr 10 9 100</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-puniq">
<h3><code>puniq</code> <a class="doc-anchor" href="#doc-lsp-extension-puniq">¶</a></h3>
<p>puniq [ITEM...] — distinct operands (or stdin lines) in first-occurrence order, hash-partitioned across the worker pool.</p>
<p>Usage: cat big.log | puniq</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-realpath">
<h3><code>realpath</code> <a class="doc-anchor" href="#doc-lsp-extension-realpath">¶</a></h3>
<p>Resolve symlinks and <code>.</code> / <code>..</code> to a canonical absolute path. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-rev">
<h3><code>rev</code> <a class="doc-anchor" href="#doc-lsp-extension-rev">¶</a></h3>
<p>Reverse each input line character-by-character. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-run_tests">
<h3><code>run_tests</code> <a class="doc-anchor" href="#doc-lsp-extension-run_tests">¶</a></h3>
<p>Alias for <code>ztest_run</code> — print the per-block test summary and roll the per-block counters into the run-wide totals. Returns 0 on all-pass, 1 if any assertion failed.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-seq">
<h3><code>seq</code> <a class="doc-anchor" href="#doc-lsp-extension-seq">¶</a></h3>
<p>Print a sequence of numbers. <code>seq 1 10</code> / <code>seq 1 2 10</code> / <code>seq -w 1 10</code>. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-sha256sum">
<h3><code>sha256sum</code> <a class="doc-anchor" href="#doc-lsp-extension-sha256sum">¶</a></h3>
<p>sha256sum [FILE...] — write SHA-256 of each file (or stdin when no FILE / '-'). coreutils-style 'HEX PATH' output.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-shuf">
<h3><code>shuf</code> <a class="doc-anchor" href="#doc-lsp-extension-shuf">¶</a></h3>
<p>shuf [-n N] [-i LO-HI] [-e [STR...]] [FILE] — random permutation. coreutils shuf(1).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-sleep">
<h3><code>sleep</code> <a class="doc-anchor" href="#doc-lsp-extension-sleep">¶</a></h3>
<p>Pause for the given duration. <code>sleep 1</code>, <code>sleep 0.5</code>, <code>sleep 1m</code>. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-sort">
<h3><code>sort</code> <a class="doc-anchor" href="#doc-lsp-extension-sort">¶</a></h3>
<p>Sort lines. <code>-n</code> numeric, <code>-r</code> reverse, <code>-k N</code> by field, <code>-u</code> unique. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-sum">
<h3><code>sum</code> <a class="doc-anchor" href="#doc-lsp-extension-sum">¶</a></h3>
<p>sum [-rs] [FILE...] — BSD or SysV checksum. <code>-r</code>: BSD 16-bit rotating checksum (default per POSIX). <code>-s</code>: SysV checksum (sum-of-bytes mod 65535, then folded). Output: <code><sum> <512-byte-blocks> [name]</code> (BSD) or <code><sum> <kbytes> [name]</code> (SysV).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tac">
<h3><code>tac</code> <a class="doc-anchor" href="#doc-lsp-extension-tac">¶</a></h3>
<p>tac [-b] [-r] [-s SEP] [FILE...] — concatenate files, reverse record order, one file at a time. coreutils tac(1): records end with SEP (default newline); <code>-b</code> attaches SEP to the start of the following record instead; <code>-r</code> treats SEP as a regular expression.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tail">
<h3><code>tail</code> <a class="doc-anchor" href="#doc-lsp-extension-tail">¶</a></h3>
<p>Print the last N lines (<code>-n N</code>) or follow appends (<code>-f</code>). coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tee">
<h3><code>tee</code> <a class="doc-anchor" href="#doc-lsp-extension-tee">¶</a></h3>
<p>Copy stdin to stdout AND to each named file. <code>-a</code> append. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-touch">
<h3><code>touch</code> <a class="doc-anchor" href="#doc-lsp-extension-touch">¶</a></h3>
<p>Create a file or update its mtime. <code>-d STR</code> set time, <code>-r REF</code> copy from REF. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tput">
<h3><code>tput</code> <a class="doc-anchor" href="#doc-lsp-extension-tput">¶</a></h3>
<p>tput [-T TERM] [-x] [-S] CAPNAME [PARAMS...] — terminfo capability query/emit. The capability is looked up in the terminfo entry for <code>-T TERM</code> (default <code>$TERM</code>) by terminfo name, then by termcap code: numbers print, booleans set the exit status (0 true, 1 false), strings are expanded with the parameters and written raw. <code>cols</code> and <code>lines</code> report the live terminal size; <code>init</code> / <code>reset</code> emit the <code>is1..is3</code> / <code>rs1..rs3</code> sequences; <code>clear</code> also emits <code>E3</code> (scrollback) unless <code>-x</code> is given. Unknown capability exits 4, unknown terminal 3, no terminal 2.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tr">
<h3><code>tr</code> <a class="doc-anchor" href="#doc-lsp-extension-tr">¶</a></h3>
<p>Translate / squeeze / delete characters. <code>tr a-z A-Z</code> uppercases. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tsort">
<h3><code>tsort</code> <a class="doc-anchor" href="#doc-lsp-extension-tsort">¶</a></h3>
<p>tsort [FILE] — topological sort. Coreutils tsort(1) / POSIX. Input is whitespace-separated pairs <code>A B</code> meaning "A precedes B"; tsort prints a partial order (Kahn's algorithm). Cycles are reported on stderr (one cycle node per line) and the program continues with that node treated as a leaf. Reads stdin when no file is given or <code>-</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-tty">
<h3><code>tty</code> <a class="doc-anchor" href="#doc-lsp-extension-tty">¶</a></h3>
<p>tty — print the controlling-terminal device path. coreutils tty(1). -s suppresses output (just sets the exit code).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-uname">
<h3><code>uname</code> <a class="doc-anchor" href="#doc-lsp-extension-uname">¶</a></h3>
<p>Print system info. <code>-a</code> all, <code>-s</code> kernel, <code>-m</code> machine, <code>-r</code> release. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-unexpand">
<h3><code>unexpand</code> <a class="doc-anchor" href="#doc-lsp-extension-unexpand">¶</a></h3>
<p>unexpand [-a] [-t TAB] [FILE...] — convert spaces to tabs. coreutils unexpand(1). Default tabstop 8; -a converts every run of spaces (not just leading); without -a only leading runs collapse.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-uniq">
<h3><code>uniq</code> <a class="doc-anchor" href="#doc-lsp-extension-uniq">¶</a></h3>
<p>Filter adjacent matching lines. <code>-c</code> prefix count, <code>-d</code> only duplicates. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-unlink">
<h3><code>unlink</code> <a class="doc-anchor" href="#doc-lsp-extension-unlink">¶</a></h3>
<p>unlink FILE — call unlink(2) directly to remove a single file. POSIX unlink(1) / coreutils unlink(1). Strict: takes exactly ONE arg, no flags, no recursion. Cannot remove directories (errors if FILE is a directory).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-users">
<h3><code>users</code> <a class="doc-anchor" href="#doc-lsp-extension-users">¶</a></h3>
<p>users — print logged-in usernames. Coreutils users(1) / POSIX. Walks utmpx via getutxent(3) and lists every USER_PROCESS entry (sorted); falls back to the effective user when utmpx has no entries.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-wc">
<h3><code>wc</code> <a class="doc-anchor" href="#doc-lsp-extension-wc">¶</a></h3>
<p>Count newlines, words, bytes. <code>-l</code> lines, <code>-w</code> words, <code>-c</code> bytes. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-whoami">
<h3><code>whoami</code> <a class="doc-anchor" href="#doc-lsp-extension-whoami">¶</a></h3>
<p>Print the effective user name. coreutils drop-in.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-yes">
<h3><code>yes</code> <a class="doc-anchor" href="#doc-lsp-extension-yes">¶</a></h3>
<p>yes [STRING] — print STRING (or 'y') forever. coreutils yes(1). Honors SIGPIPE: when stdout is piped and the consumer closes, the write fails and we exit 0 silently.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zask">
<h3><code>zask</code> <a class="doc-anchor" href="#doc-lsp-extension-zask">¶</a></h3>
<p>Ask another shell for input through the daemon and manage the requests. <code>zask --target shell:N picker|input|dialog|menu [opts]</code>, <code>zask progress</code>, <code>zask pending</code>, <code>zask take</code>, <code>zask dismiss ID | --all</code>, <code>zask inbox-clear</code>, <code>zask response ID DATA</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_contains">
<h3><code>zassert_contains</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_contains">¶</a></h3>
<p><code>zassert_contains HAYSTACK NEEDLE [MSG]</code> — pass when NEEDLE is a substring of HAYSTACK. Bumps the per-block <code>ztest_pass_count</code> on success, <code>ztest_fail_count</code> on failure; the ✓/✗ glyph + label print on stderr.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_dies">
<h3><code>zassert_dies</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_dies">¶</a></h3>
<p><code>zassert_dies "CMD" [MSG]</code> — shell-native variant of strykelang's <code>assert_dies</code> (which takes a code ref). Runs CMD in a scratch <code>ShellExecutor</code> (inheriting the host's <code>zsh_compat</code> / <code>bash_compat</code> / <code>posix_mode</code>); passes iff the command exits non-zero or errors. Use to assert that a misuse correctly fails.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_eq">
<h3><code>zassert_eq</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_eq">¶</a></h3>
<p><code>zassert_eq A B [MSG]</code> — string equality. Like every <code>zassert_*</code> builtin, returns 0 on pass / 1 on fail and bumps the per-block counters that <code>ztest_run</code> reads.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_err">
<h3><code>zassert_err</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_err">¶</a></h3>
<p><code>zassert_err V [MSG]</code> — pass when V is shell-falsy (empty *or* literal "0"). Convenient for asserting on <code>$?</code> after a command, or on a string that should be empty.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_false">
<h3><code>zassert_false</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_false">¶</a></h3>
<p><code>zassert_false V [MSG]</code> — alias of <code>zassert_err</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_ge">
<h3><code>zassert_ge</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_ge">¶</a></h3>
<p><code>zassert_ge A B [MSG]</code> — pass iff numeric A ≥ B. Inputs are <code>trim().parse::<f64>()</code>'d; non-numeric inputs default to 0.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_gt">
<h3><code>zassert_gt</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_gt">¶</a></h3>
<p><code>zassert_gt A B [MSG]</code> — pass iff numeric A > B.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_le">
<h3><code>zassert_le</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_le">¶</a></h3>
<p><code>zassert_le A B [MSG]</code> — pass iff numeric A ≤ B.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_lt">
<h3><code>zassert_lt</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_lt">¶</a></h3>
<p><code>zassert_lt A B [MSG]</code> — pass iff numeric A < B.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_match">
<h3><code>zassert_match</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_match">¶</a></h3>
<p><code>zassert_match PATTERN STRING [MSG]</code> — regex match. PATTERN is compiled with the <code>regex</code> crate (Rust regex syntax, not POSIX BRE/ERE — so <code>\d</code>/<code>\w</code>/<code>\s</code> work, no backreferences). Fails (rather than panics) on a bad pattern.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_ne">
<h3><code>zassert_ne</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_ne">¶</a></h3>
<p><code>zassert_ne A B [MSG]</code> — string inequality.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_near">
<h3><code>zassert_near</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_near">¶</a></h3>
<p><code>zassert_near A B [EPS [MSG]]</code> — floating-point approximate equality: pass iff <code>|A − B| ≤ EPS</code>. EPS defaults to <code>1e-9</code>. Right for asserting on math results without burning on the last few ULPs.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_ok">
<h3><code>zassert_ok</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_ok">¶</a></h3>
<p><code>zassert_ok V [MSG]</code> — pass when V is shell-truthy (non-empty *and* not literal "0"). Use <code>zassert_eq $? 0 …</code> for command-success assertions; reserve <code>zassert_ok</code> for assertions on populated strings or non-zero counts.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zassert_true">
<h3><code>zassert_true</code> <a class="doc-anchor" href="#doc-lsp-extension-zassert_true">¶</a></h3>
<p><code>zassert_true V [MSG]</code> — alias of <code>zassert_ok</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zbanner">
<h3><code>zbanner</code> <a class="doc-anchor" href="#doc-lsp-extension-zbanner">¶</a></h3>
<p>zbanner — the ZSHRS logo, a boxed summary (version, builtin and extension totals), and a live line: the daemon socket and whether it answers, then this shell's functions, aliases, parameters and jobs. <code>zshrs --banner</code> prints the same from outside a shell, without the shell counts. Ported from ztmux's <code>banner</code> verb.</p>
<p>Usage: zbanner</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zbuild">
<h3><code>zbuild</code> <a class="doc-anchor" href="#doc-lsp-extension-zbuild">¶</a></h3>
<p>zbuild --in PATHS... --out OUT — bake one or more shell scripts into a copy of the running zshrs binary in input order, producing a self-contained AOT executable.</p>
<p> zbuild --in *.zsh --out app # glob expansion zbuild --in lib1.zsh lib2.zsh main.zsh --out app ./app # runs all three # sequentially under # one ShellExecutor</p>
<p>zsh has no project concept, so there's no manifest, no entry point convention, no library directory walker. Order is exactly the order of paths given to <code>--in</code> (which honors shell glob expansion — \<code>*.zsh\</code> expands sorted by default).</p>
<p><code>--in</code> accepts ONE OR MORE paths until the next flag-style token (anything starting with <code>-</code>). This makes glob-driven invocations like <code>--in *.zsh</code> work naturally — every path the glob expanded to lands as another input file.</p>
<p>Flags: --in PATHS... / -i PATHS... script sources (1+, required) --out PATH / -o PATH output binary (required) --native / -n AOT-compile to native machine code (Cranelift object linked standalone) --help / -h print usage</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zcache">
<h3><code>zcache</code> <a class="doc-anchor" href="#doc-lsp-extension-zcache">¶</a></h3>
<p>Inspect and manage the zshrs caches: daemon shards, the catalog and the caches the shell writes itself. <code>zcache info</code>, <code>zcache clean [all|shards|shard NAME|index|shell|log|catalog|stats|zwc|zcompdump|legacy] [--dry-run]</code>, <code>zcache verify</code>, <code>zcache view TARGET</code>, <code>zcache export</code>, <code>zcache import</code>, <code>zcache daemon status|stop|restart</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zcmddashresult">
<h3><code>zcmd-result</code> <a class="doc-anchor" href="#doc-lsp-extension-zcmddashresult">¶</a></h3>
<p>Responder side of <code>zsend --wait</code>: report the exit status and output of a command a <code>cmd:execute</code> event delivered. <code>zcmd-result --id DELIVERY_ID [--exit-code N] [--stdout TEXT] [--stderr TEXT]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zcomplete">
<h3><code>zcomplete</code> <a class="doc-anchor" href="#doc-lsp-extension-zcomplete">¶</a></h3>
<p>Ask the daemon's <code>complete</code> op for candidates (commands, handlers, history) matching a command-line prefix and print the JSON reply. <code>zcomplete PREFIX [--limit N]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zd">
<h3><code>zd</code> <a class="doc-anchor" href="#doc-lsp-extension-zd">¶</a></h3>
<p><code>zd</code> — in-process builtin form of the standalone <code>zd</code> binary. Same arg surface (see <code>daemon::zd_dispatch::USAGE</code>); transport is the local Unix socket via the existing <code>Client</code>. <strong>No fork</strong>: zshrs calls dispatch() directly and gets the result back. ~5-15× faster than fork+exec'ing the binary for short ops.</p>
<p><code>--url</code> / <code>--token</code> global flags are accepted (and ignored) for command-line shape compatibility with the binary form. The builtin always uses the local socket — there's no point talking to the daemon over HTTP from inside the same machine when a Unix socket is right there.</p>
<p>SSE ops (<code>zd events</code>, <code>zd watch</code>) return an error pointing at the binary form — long-lived stream pumps don't fit the request- response shape of a builtin.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zhistory">
<h3><code>zhistory</code> <a class="doc-anchor" href="#doc-lsp-extension-zhistory">¶</a></h3>
<p>Read and write the daemon's cross-shell history store (history.db). <code>zhistory append LINE [--exit-code N] [--cwd DIR]</code>, <code>zhistory query [--filter PAT] [--mode match|fts|like|prefix|exact] [--cwd DIR] [--limit N]</code>, <code>zhistory count</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zid">
<h3><code>zid</code> <a class="doc-anchor" href="#doc-lsp-extension-zid">¶</a></h3>
<p>Print the client id the daemon assigned to this connection.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zjob">
<h3><code>zjob</code> <a class="doc-anchor" href="#doc-lsp-extension-zjob">¶</a></h3>
<p>Run and manage jobs owned by the daemon, so they outlive the shell. <code>zjob submit CMD [ARGS] [--cwd DIR] [--tag T]</code>, <code>zjob list</code>, <code>zjob status ID</code>, <code>zjob output ID [--follow]</code>, <code>zjob attach ID</code>, <code>zjob kill ID [--signal NAME]</code>, <code>zjob cancel ID</code>, <code>zjob wait ID</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zlock">
<h3><code>zlock</code> <a class="doc-anchor" href="#doc-lsp-extension-zlock">¶</a></h3>
<p>Named cross-process locks held by the daemon; a lock is released when its holder dies. <code>zlock try NAME</code>, <code>zlock acquire NAME [--timeout S]</code>, <code>zlock release NAME TOKEN</code>, <code>zlock list</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zlog">
<h3><code>zlog</code> <a class="doc-anchor" href="#doc-lsp-extension-zlog">¶</a></h3>
<p>Inspect and manage the zshrs log files under ~/.zshrs. <code>zlog</code> (newest log path), <code>zlog tail [-n N]</code>, <code>zlog grep REGEX</code>, <code>zlog clear</code>, <code>zlog stats</code>, <code>zlog level DIRECTIVE</code>, <code>zlog rotate</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zls">
<h3><code>zls</code> <a class="doc-anchor" href="#doc-lsp-extension-zls">¶</a></h3>
<p>List the shells connected to the daemon: id, pid, tty, uptime, tags and cwd. <code>zls --tag NAME</code> lists only the shells carrying that tag.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-znotify">
<h3><code>znotify</code> <a class="doc-anchor" href="#doc-lsp-extension-znotify">¶</a></h3>
<p>Show a notification in other shells through the daemon. <code>znotify SHELL_ID|--all|--tag NAME|--user USER MESSAGE</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zping">
<h3><code>zping</code> <a class="doc-anchor" href="#doc-lsp-extension-zping">¶</a></h3>
<p>Round-trip probe against the daemon: prints its uptime and the round-trip time. <code>zping --all</code> also lists every registered shell.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zpublish">
<h3><code>zpublish</code> <a class="doc-anchor" href="#doc-lsp-extension-zpublish">¶</a></h3>
<p>Publish an event on the daemon's pub/sub bus from this shell's scope. <code>zpublish TOPIC [DATA | --json JSON]</code>; subscribers receive it via <code>zsubscribe</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsend">
<h3><code>zsend</code> <a class="doc-anchor" href="#doc-lsp-extension-zsend">¶</a></h3>
<p>Send a command line to other shells through the daemon. <code>zsend [--json] [--wait] [--timeout S] SHELL_ID|--all|--tag NAME|--user USER CMD...</code>; <code>--wait</code> relays the target's output and exit status.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsleep">
<h3><code>zsleep</code> <a class="doc-anchor" href="#doc-lsp-extension-zsleep">¶</a></h3>
<p>zsleep SECONDS — sleep for SECONDS, which may be fractional (<code>zsleep 0.25</code>). Exactly one argument, no options. A negative, zero or non-finite value returns 0 at once; a non-number is an error.</p>
<p>Usage: zsleep 1.5</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsource">
<h3><code>zsource</code> <a class="doc-anchor" href="#doc-lsp-extension-zsource">¶</a></h3>
<p>Ask the daemon's compiled-file registry whether a sourced file's cached body is a hit, stale or a miss. <code>zsource PATH</code>, <code>zsource --stat PATH</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsubscribe">
<h3><code>zsubscribe</code> <a class="doc-anchor" href="#doc-lsp-extension-zsubscribe">¶</a></h3>
<p>Subscribe to pub/sub events and stream them to stdout. <code>zsubscribe [--json] [--count N] SCOPE.TOPIC</code> (e.g. <code>shell:42.commands</code>, <code>*.chpwd</code>), <code>zsubscribe --list</code>, <code>--pause</code>/<code>--resume [--id N | --all]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsuggest">
<h3><code>zsuggest</code> <a class="doc-anchor" href="#doc-lsp-extension-zsuggest">¶</a></h3>
<p>Ask the daemon for a suggestion completing a command-line prefix. <code>zsuggest PREFIX [--cwd DIR]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zsync">
<h3><code>zsync</code> <a class="doc-anchor" href="#doc-lsp-extension-zsync">¶</a></h3>
<p>Move canonical subsystem state (aliases, functions, options, ...) between this shell and the daemon. <code>zsync up SUBSYSTEM KEY VALUE</code>, <code>zsync up --all</code>, <code>zsync pull SUBSYSTEM</code>, <code>zsync diff SUBSYSTEM --overlay JSON</code>, <code>zsync watch SUBSYSTEM...</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-ztag">
<h3><code>ztag</code> <a class="doc-anchor" href="#doc-lsp-extension-ztag">¶</a></h3>
<p>Add tags to this shell's daemon session and print its tag list. Other shells target tagged shells with <code>zls --tag</code>, <code>zsend --tag</code>, <code>znotify --tag</code> and <code>tag:NAME.*</code> subscriptions. <code>ztag prod-deploy</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-ztest_run">
<h3><code>ztest_run</code> <a class="doc-anchor" href="#doc-lsp-extension-ztest_run">¶</a></h3>
<p>Print the per-block test summary (green ✓ All N passed / red ✗ M of N failed) and roll the per-block <code>ztest_pass_count</code> / <code>ztest_fail_count</code> / <code>ztest_skip_count</code> into the run-wide <code>_total</code> counters, then zero the per-block counters so a second test block in the same file starts fresh. A sticky <code>ztest_run_failed</code> flag latches when any block reports failures — the <code>--ztest</code> worker reads it to exit non-zero even if the script ends with <code>exit 0</code>. Alias: <code>run_tests</code>. Returns 0 on all-pass, 1 if any assertion failed.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-ztest_skip">
<h3><code>ztest_skip</code> <a class="doc-anchor" href="#doc-lsp-extension-ztest_skip">¶</a></h3>
<p><code>ztest_skip MSG</code> — bump the per-block skip counter and emit a yellow ↷ marker on stderr. Typical use: gate an assertion behind a compat condition using shell short-circuit (<code>(( cond )) || { ztest_skip "needs X"; continue; }</code>).</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zunsubscribe">
<h3><code>zunsubscribe</code> <a class="doc-anchor" href="#doc-lsp-extension-zunsubscribe">¶</a></h3>
<p>Cancel a <code>zsubscribe</code> subscription. <code>zunsubscribe SCOPE.TOPIC</code> or <code>zunsubscribe --id SUBSCRIPTION_ID</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zuntag">
<h3><code>zuntag</code> <a class="doc-anchor" href="#doc-lsp-extension-zuntag">¶</a></h3>
<p>Remove tags from this shell's daemon session, or every tag with <code>--all</code>, and print the remaining list. Inverse of <code>ztag</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-extension-zwhere">
<h3><code>zwhere</code> <a class="doc-anchor" href="#doc-lsp-extension-zwhere">¶</a></h3>
<p><code>zwhere</code> — query the daemon's federated definitions catalog from inside zshrs. Thin client over the <code>definitions_query</code> op (same thing <code>zd defs query</code> calls). Always available in default zshrs; not feature-gated on <code>recorder</code> because this is a read-only path, not the AOP write path.</p>
<p>Usage: zwhere KIND NAME # rows for <code>KIND NAME</code> across all shells zwhere KIND --prefix STR # all KIND rows whose name starts with STR zwhere --kinds # list every populated kind zwhere --shell-id ID … # restrict to one shell_id zwhere --limit N … # cap (default 1000 for tty output)</p>
<p>Output format: one row per DEFINITION, oldest first — <code>kind\tname\tvalue\tshell_id\tfile:line\tstate\tvia</code>. <code>state</code> is <code>shadowed</code> for a definition a later one replaced and <code>active</code> for the one in force; <code>via</code> is the function call chain it ran under (<code>outer > inner</code>). When a function shadowing the builtin (zinit's <code>alias</code> wrapper) ran it, <code>file:line</code> is where that function was called. With no daemon running, <code>zwhere</code> reads the newest recorder shard directly. Wide-column layout via padding is left to the caller piping through <code>column -t</code>; <code>zwhere</code> stays narrow so scripts can <code>awk</code> cleanly.</p>
</article>
</section>
<!-- ════════════════════════════════════════════════════════════════════ -->
<section class="tutorial-section" id="ch-lsp-operators">
<h2>Operator / Punctuation Index</h2>
<p class="chapter-meta">69 entries · pipelines (<code>|</code>, <code>|&</code>), list ops (<code>&&</code>, <code>||</code>, <code>;</code>, <code>&</code>, <code>;;</code>), redirects (<code>></code>, <code>>></code>, <code><<</code>, <code><<<</code>, <code>&></code>, …), conditional/arithmetic openers (<code>[[</code>, <code>]]</code>, <code>((</code>, <code>))</code>), substitution forms (<code>$(</code>, <code>${</code>, <code>$((</code>, <code><(</code>, <code>>(</code>), test ops (<code>-e</code>, <code>-eq</code>, <code>=~</code>, …), pattern chars (<code>*</code>, <code>?</code>, <code>**</code>, <code>~</code>), brace expansion (<code>{a,b,c}</code>, <code>{1..10}</code>), and assignment (<code>=</code>, <code>+=</code>). Sourced from <code>man zshmisc</code> section prose — these have no per-name yodl <code>item</code> blocks so they're hand-curated.</p>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>|</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Pipeline. <code>cmd1 | cmd2</code> connects <code>cmd1</code>'s stdout to <code>cmd2</code>'s stdin. Each stage runs in a separate process; exit status is the last stage's (unless <code>PIPE_FAIL</code> is set, in which case the first non-zero in the chain wins).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>|&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Pipeline merging stderr. <code>cmd1 |& cmd2</code> = <code>cmd1 2>&1 | cmd2</code>. Both stdout AND stderr of <code>cmd1</code> are piped to <code>cmd2</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>&&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Logical AND list operator. <code>cmd1 && cmd2</code> runs <code>cmd2</code> only if <code>cmd1</code> succeeded (exit status 0). Short-circuits.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>||</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Logical OR list operator. <code>cmd1 || cmd2</code> runs <code>cmd2</code> only if <code>cmd1</code> failed (non-zero exit). Short-circuits.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>;</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Sequential list separator. <code>cmd1; cmd2</code> runs <code>cmd2</code> after <code>cmd1</code> finishes, regardless of its exit status.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Background list operator. <code>cmd &</code> runs <code>cmd</code> asynchronously in the background; the shell does not wait. Sets <code>$!</code> to the job's PID.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>;;</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Case-branch terminator. Ends a <code>case</code> arm: <code>case x in pat) cmds ;; esac</code>. Stops case dispatch after this arm.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>;;&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Case-branch fall-through-and-test-next. Continues to the next <code>case</code> arm and tests its pattern.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>;|</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Case-branch unconditional fall-through. Continues to the next <code>case</code> arm and runs it without testing its pattern.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-bang">
<h3><code>!</code> <a class="doc-anchor" href="#doc-lsp-operator-bang">¶</a></h3>
<p>Pipeline negation (also a reserved word). <code>! cmd</code> inverts <code>cmd</code>'s exit status — zero becomes 1, non-zero becomes 0. Distinct from <code>!</code> history expansion (lexer-stage).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>></code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Stdout redirect. <code>cmd > file</code> writes <code>cmd</code>'s stdout to <code>file</code> (overwrite). With <code>NO_CLOBBER</code>, refuses to overwrite an existing file — use <code>>|</code> or <code>>!</code> to force.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>>></code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Stdout append. <code>cmd >> file</code> appends <code>cmd</code>'s stdout to <code>file</code> (creates if missing).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code><</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Stdin redirect. <code>cmd < file</code> makes <code>file</code> the source of <code>cmd</code>'s stdin.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code><<</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Heredoc start. <code>cmd <<MARKER</code> reads the following lines as <code>cmd</code>'s stdin until a line containing only <code>MARKER</code>. Variants: <code><<-</code> strips leading tabs; <code><<'MARKER'</code> disables expansion in the body.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dash">
<h3><code><<-</code> <a class="doc-anchor" href="#doc-lsp-operator-dash">¶</a></h3>
<p>Heredoc with tab-stripping. Like <code><<</code> but every leading tab on body lines (and the terminator) is removed — lets you indent the heredoc for readability.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code><<<</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Here-string. <code>cmd <<< 'text'</code> makes the literal string <code>text</code> the source of <code>cmd</code>'s stdin. Adds a trailing newline.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>&></code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Redirect stdout + stderr together. <code>cmd &> file</code> = <code>cmd > file 2>&1</code>. Shorthand for the common combined redirect.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>&>></code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Append stdout + stderr together. <code>cmd &>> file</code> = <code>cmd >> file 2>&1</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>>&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Redirect a file descriptor. <code>2>&1</code> sends stderr to wherever stdout currently points. <code>>& file</code> is also accepted as <code>&> file</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code><&</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Duplicate an input file descriptor. <code>cmd <&3</code> reads from fd 3. <code><& -</code> closes stdin.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code><></code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Read+write redirect. <code>cmd <> file</code> opens <code>file</code> for both reading and writing on stdin.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>>|</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Force-overwrite redirect. Equivalent to <code>></code> but ignores <code>NO_CLOBBER</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-bang">
<h3><code>>!</code> <a class="doc-anchor" href="#doc-lsp-operator-bang">¶</a></h3>
<p>Same as <code>>|</code> — force-overwrite, bypass <code>NO_CLOBBER</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lbracketlbracket">
<h3><code>[[</code> <a class="doc-anchor" href="#doc-lsp-operator-lbracketlbracket">¶</a></h3>
<p>Open zsh conditional expression. <code>[[ EXPR ]]</code> evaluates a boolean. No word splitting / glob inside; supports <code>&&</code>, <code>||</code>, <code>!</code>, <code>==</code>, <code>!=</code>, <code>=~</code>, <code>-e</code>, <code>-f</code>, <code>-d</code>, <code>-z</code>, <code>-n</code>, etc. Prefer this over <code>[ ]</code> in zsh.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-rbracketrbracket">
<h3><code>]]</code> <a class="doc-anchor" href="#doc-lsp-operator-rbracketrbracket">¶</a></h3>
<p>Close zsh conditional expression. Pairs with <code>[[</code>. Must be a separate word — <code>[[ -n $x]]</code> is a syntax error; use <code>[[ -n $x ]]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lbracket">
<h3><code>[</code> <a class="doc-anchor" href="#doc-lsp-operator-lbracket">¶</a></h3>
<p>POSIX <code>test</code> command (also spelled <code>test</code>). Same conditional semantics as POSIX <code>test</code>. Prefer <code>[[ … ]]</code> in zsh — it's safer (no word splitting) and supports more operators.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-rbracket">
<h3><code>]</code> <a class="doc-anchor" href="#doc-lsp-operator-rbracket">¶</a></h3>
<p>Close POSIX <code>test</code>. Pairs with <code>[</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lparenlparen">
<h3><code>((</code> <a class="doc-anchor" href="#doc-lsp-operator-lparenlparen">¶</a></h3>
<p>Open arithmetic command. <code>(( EXPR ))</code> evaluates <code>EXPR</code> as C-style integer arithmetic; exit 0 if the result is non-zero, 1 otherwise. Inside, <code>$</code> on var names is optional: <code>(( i++ ))</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-rparenrparen">
<h3><code>))</code> <a class="doc-anchor" href="#doc-lsp-operator-rparenrparen">¶</a></h3>
<p>Close arithmetic command. Pairs with <code>((</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dollarlparen">
<h3><code>$(</code> <a class="doc-anchor" href="#doc-lsp-operator-dollarlparen">¶</a></h3>
<p>Command substitution open. <code>$(cmd)</code> runs <code>cmd</code> and substitutes its trimmed-trailing-newline stdout. Nestable: <code>$(echo $(date))</code>. Preferred over backticks.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dollarlbrace">
<h3><code>${</code> <a class="doc-anchor" href="#doc-lsp-operator-dollarlbrace">¶</a></h3>
<p>Parameter expansion open. <code>${VAR}</code> is the value of <code>VAR</code>. Rich modifier set: <code>${VAR:-default}</code>, <code>${VAR:=assign}</code>, <code>${VAR:+alt}</code>, <code>${#VAR}</code> length, <code>${VAR/p/r}</code> replace, <code>${VAR%suffix}</code> / <code>${VAR#prefix}</code> strip, <code>${(flags)VAR}</code> zsh flags.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dollarlparenlparen">
<h3><code>$((</code> <a class="doc-anchor" href="#doc-lsp-operator-dollarlparenlparen">¶</a></h3>
<p>Arithmetic expansion open. <code>$(( EXPR ))</code> evaluates <code>EXPR</code> as integer arithmetic and substitutes the result as a string. Distinct from <code>(( … ))</code> which is a command, not an expansion.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lparen">
<h3><code><(</code> <a class="doc-anchor" href="#doc-lsp-operator-lparen">¶</a></h3>
<p>Process substitution (input). <code>cmd <(producer)</code> exposes <code>producer</code>'s stdout as a filename (<code>/dev/fd/N</code>) to <code>cmd</code>. Lets commands that take filenames consume pipe output.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lparen">
<h3><code>>(</code> <a class="doc-anchor" href="#doc-lsp-operator-lparen">¶</a></h3>
<p>Process substitution (output). <code>cmd >(consumer)</code> exposes a filename to <code>cmd</code>; anything <code>cmd</code> writes there flows to <code>consumer</code>'s stdin.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>`</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Backtick command substitution. <code></code>cmd<code></code> runs <code>cmd</code> and substitutes its stdout. Legacy form — prefer <code>$(cmd)</code> for nestability and quoting clarity.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashe">
<h3><code>-e</code> <a class="doc-anchor" href="#doc-lsp-operator-dashe">¶</a></h3>
<p>File-exists test. <code>[[ -e PATH ]]</code> is true if <code>PATH</code> exists (any type — file / dir / link / socket / ...).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashf">
<h3><code>-f</code> <a class="doc-anchor" href="#doc-lsp-operator-dashf">¶</a></h3>
<p>Regular-file test. <code>[[ -f PATH ]]</code> is true if <code>PATH</code> exists AND is a regular file (not a directory / symlink / device).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashd">
<h3><code>-d</code> <a class="doc-anchor" href="#doc-lsp-operator-dashd">¶</a></h3>
<p>Directory test. <code>[[ -d PATH ]]</code> is true if <code>PATH</code> exists AND is a directory.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashr">
<h3><code>-r</code> <a class="doc-anchor" href="#doc-lsp-operator-dashr">¶</a></h3>
<p>Readable test. <code>[[ -r PATH ]]</code> is true if <code>PATH</code> exists AND is readable by the current process.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashw">
<h3><code>-w</code> <a class="doc-anchor" href="#doc-lsp-operator-dashw">¶</a></h3>
<p>Writable test. <code>[[ -w PATH ]]</code> is true if <code>PATH</code> exists AND is writable by the current process.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashx">
<h3><code>-x</code> <a class="doc-anchor" href="#doc-lsp-operator-dashx">¶</a></h3>
<p>Executable test. <code>[[ -x PATH ]]</code> is true if <code>PATH</code> exists AND has execute permission (or for directories, search permission).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashs">
<h3><code>-s</code> <a class="doc-anchor" href="#doc-lsp-operator-dashs">¶</a></h3>
<p>Non-empty test. <code>[[ -s PATH ]]</code> is true if <code>PATH</code> exists AND has size > 0.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashL">
<h3><code>-L</code> <a class="doc-anchor" href="#doc-lsp-operator-dashL">¶</a></h3>
<p>Symlink test. <code>[[ -L PATH ]]</code> is true if <code>PATH</code> is a symbolic link (does NOT dereference).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashh">
<h3><code>-h</code> <a class="doc-anchor" href="#doc-lsp-operator-dashh">¶</a></h3>
<p>Same as <code>-L</code> — symlink test.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashz">
<h3><code>-z</code> <a class="doc-anchor" href="#doc-lsp-operator-dashz">¶</a></h3>
<p>Empty-string test. <code>[[ -z $s ]]</code> is true if <code>$s</code> is the empty string.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashn">
<h3><code>-n</code> <a class="doc-anchor" href="#doc-lsp-operator-dashn">¶</a></h3>
<p>Non-empty-string test. <code>[[ -n $s ]]</code> is true if <code>$s</code> has length > 0. Equivalent to <code>[[ $s ]]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dasheq">
<h3><code>-eq</code> <a class="doc-anchor" href="#doc-lsp-operator-dasheq">¶</a></h3>
<p>Numeric equality. <code>[[ a -eq b ]]</code> is true if integers <code>a</code> and <code>b</code> are equal. For strings use <code>==</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashne">
<h3><code>-ne</code> <a class="doc-anchor" href="#doc-lsp-operator-dashne">¶</a></h3>
<p>Numeric inequality. <code>[[ a -ne b ]]</code> is true if integers <code>a</code> and <code>b</code> differ.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashlt">
<h3><code>-lt</code> <a class="doc-anchor" href="#doc-lsp-operator-dashlt">¶</a></h3>
<p>Numeric less-than. <code>[[ a -lt b ]]</code> is true if integer <code>a</code> < <code>b</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashle">
<h3><code>-le</code> <a class="doc-anchor" href="#doc-lsp-operator-dashle">¶</a></h3>
<p>Numeric less-or-equal. <code>[[ a -le b ]]</code> is true if integer <code>a</code> ≤ <code>b</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashgt">
<h3><code>-gt</code> <a class="doc-anchor" href="#doc-lsp-operator-dashgt">¶</a></h3>
<p>Numeric greater-than. <code>[[ a -gt b ]]</code> is true if integer <code>a</code> > <code>b</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashge">
<h3><code>-ge</code> <a class="doc-anchor" href="#doc-lsp-operator-dashge">¶</a></h3>
<p>Numeric greater-or-equal. <code>[[ a -ge b ]]</code> is true if integer <code>a</code> ≥ <code>b</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashot">
<h3><code>-ot</code> <a class="doc-anchor" href="#doc-lsp-operator-dashot">¶</a></h3>
<p>Older-than test. <code>[[ A -ot B ]]</code> is true if file <code>A</code> has an older mtime than <code>B</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashnt">
<h3><code>-nt</code> <a class="doc-anchor" href="#doc-lsp-operator-dashnt">¶</a></h3>
<p>Newer-than test. <code>[[ A -nt B ]]</code> is true if file <code>A</code> has a newer mtime than <code>B</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-dashef">
<h3><code>-ef</code> <a class="doc-anchor" href="#doc-lsp-operator-dashef">¶</a></h3>
<p>Same-file test. <code>[[ A -ef B ]]</code> is true if <code>A</code> and <code>B</code> are the same inode (hard-linked / same path).</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-eqeq">
<h3><code>==</code> <a class="doc-anchor" href="#doc-lsp-operator-eqeq">¶</a></h3>
<p>Pattern-match equality (inside <code>[[ … ]]</code>). <code>[[ $s == pat* ]]</code> matches <code>$s</code> against the glob pattern <code>pat*</code>. RHS is a pattern unless quoted. For literal equality, quote: <code>[[ $s == "literal" ]]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-bangeq">
<h3><code>!=</code> <a class="doc-anchor" href="#doc-lsp-operator-bangeq">¶</a></h3>
<p>Pattern-mismatch (inside <code>[[ … ]]</code>). Inverse of <code>==</code>. Quote the RHS for literal comparison.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-eq">
<h3><code>=~</code> <a class="doc-anchor" href="#doc-lsp-operator-eq">¶</a></h3>
<p>Regex match (inside <code>[[ … ]]</code>). <code>[[ $s =~ pat ]]</code> matches <code>$s</code> against the regex <code>pat</code>. Capture groups land in <code>$match</code> / <code>$MATCH</code> / <code>$BASH_REMATCH</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-star">
<h3><code>*</code> <a class="doc-anchor" href="#doc-lsp-operator-star">¶</a></h3>
<p>Glob: match zero or more characters of any name (excluding leading <code>.</code> unless <code>GLOB_DOTS</code> is set). Also a multiplication operator inside <code>(( … ))</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-qmark">
<h3><code>?</code> <a class="doc-anchor" href="#doc-lsp-operator-qmark">¶</a></h3>
<p>Glob: match exactly one character. Also the last-exit-status variable when used as <code>$?</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-starstar">
<h3><code>**</code> <a class="doc-anchor" href="#doc-lsp-operator-starstar">¶</a></h3>
<p>Recursive glob (zsh extended). <code>**/*.rs</code> matches <code>*.rs</code> at any depth under the current directory. Requires <code>EXTENDED_GLOB</code> for additional pattern operators.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>~</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Pattern exclude (with <code>EXTENDED_GLOB</code>). <code>*~README</code> matches everything except <code>README</code>. Also tilde expansion: <code>~</code> = <code>$HOME</code>, <code>~user</code> = user's home, <code>~+</code> = <code>$PWD</code>, <code>~-</code> = <code>$OLDPWD</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-unnamed">
<h3><code>^</code> <a class="doc-anchor" href="#doc-lsp-operator-unnamed">¶</a></h3>
<p>Pattern negate first-match (with <code>EXTENDED_GLOB</code>). <code>^*.rs</code> matches everything that's NOT <code>*.rs</code>. Inside <code>[…]</code> ranges, negates: <code>[^abc]</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lbracea-b-crbrace">
<h3><code>{a,b,c}</code> <a class="doc-anchor" href="#doc-lsp-operator-lbracea-b-crbrace">¶</a></h3>
<p>Brace expansion (literal list). Expands to multiple words: <code>cp file.{txt,bak}</code> becomes <code>cp file.txt file.bak</code>. No whitespace before commas.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-lbrace1dotdot10rbrace">
<h3><code>{1..10}</code> <a class="doc-anchor" href="#doc-lsp-operator-lbrace1dotdot10rbrace">¶</a></h3>
<p>Brace range expansion. <code>{1..10}</code> expands to <code>1 2 3 4 5 6 7 8 9 10</code>. Supports step: <code>{1..10..2}</code> → <code>1 3 5 7 9</code>. Letters work too: <code>{a..z}</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-eq">
<h3><code>=</code> <a class="doc-anchor" href="#doc-lsp-operator-eq">¶</a></h3>
<p>Assignment. <code>VAR=value</code>. NO whitespace around <code>=</code>. With <code>local</code> / <code>typeset</code>: <code>local VAR=value</code> declares + assigns.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-pluseq">
<h3><code>+=</code> <a class="doc-anchor" href="#doc-lsp-operator-pluseq">¶</a></h3>
<p>Append assignment. <code>VAR+=more</code> appends to a scalar; for arrays <code>arr+=(x y)</code> appends elements. Numeric for <code>integer</code>: <code>(( count += 1 ))</code>.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-coloneq">
<h3><code>:=</code> <a class="doc-anchor" href="#doc-lsp-operator-coloneq">¶</a></h3>
<p>Conditional-assign default (inside <code>${…}</code>). <code>${VAR:=fallback}</code> assigns <code>fallback</code> to <code>VAR</code> (and substitutes it) if <code>VAR</code> is unset or empty.</p>
</article>
<article class="doc-entry" id="doc-lsp-operator-qmarkeq">
<h3><code>?=</code> <a class="doc-anchor" href="#doc-lsp-operator-qmarkeq">¶</a></h3>
<p>Error-if-unset (inside <code>${…}</code>). <code>${VAR:?msg}</code> substitutes <code>$VAR</code> if set, else prints <code>msg</code> to stderr and exits.</p>
</article>
</section>
<!-- BEGIN CANONICAL-GRAMMAR -->
<!-- generated by scripts/gen_grammar_docs.py -->
<style>
.cg-section { margin: 1.4rem 0; }
.cg-section h3 { font-family: 'Orbitron', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cyan); margin: 1.1rem 0 0.4rem; border-bottom: 1px dashed var(--border); padding-bottom: 0.25rem; }
.cg-section .cg-meta { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; margin: 0 0 0.6rem; }
.cg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 4px 10px; margin: 0.4rem 0 1rem; }
.cg-grid code { font-family: 'Share Tech Mono', ui-monospace, monospace; font-size: 11.5px; color: var(--accent-light); background: var(--bg); padding: 1px 5px; border-left: 2px solid var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-grid code:hover { background: var(--bg-hover); color: var(--text); }
.cg-table { width: 100%; border-collapse: collapse; margin: 0.4rem 0 1rem; font-size: 12px; }
.cg-table th { background: var(--bg-secondary); color: var(--cyan); font-family: 'Orbitron', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; text-align: left; padding: 6px 10px; border: 1px solid var(--border); }
.cg-table td { padding: 5px 10px; border: 1px solid var(--border); color: var(--text-dim); vertical-align: top; }
.cg-table td:first-child { white-space: nowrap; font-family: 'Share Tech Mono', monospace; color: var(--accent-light); font-weight: 600; }
.cg-table td code { color: var(--accent-light); background: var(--bg); padding: 1px 4px; font-size: 11px; }
.cg-table tr:hover td { background: var(--bg-hover); }
.cg-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.8rem; margin: 1rem 0; text-align: center; }
.cg-counts .cg-val { font-family: 'Orbitron', sans-serif; font-size: 24px; font-weight: 900; color: var(--cyan); }
.cg-counts .cg-lab { font-size: 9.5px; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 0.2rem; }
</style>
<div class="cg-counts">
<div><div class="cg-val">50</div><div class="cg-lab">Keywords</div></div>
<div><div class="cg-val">157</div><div class="cg-lab">Builtins</div></div>
<div><div class="cg-val">196</div><div class="cg-lab">Options</div></div>
<div><div class="cg-val">88</div><div class="cg-lab">Special vars</div></div>
<div><div class="cg-val">38</div><div class="cg-lab">Param flags</div></div>
<div><div class="cg-val">44</div><div class="cg-lab">Glob quals</div></div>
<div><div class="cg-val">55</div><div class="cg-lab">Operators</div></div>
<div><div class="cg-val">10</div><div class="cg-lab">History exp.</div></div>
<div><div class="cg-val">16</div><div class="cg-lab">Modifiers</div></div>
</div>
<div class="cg-section">
<h3>Reserved keywords (50)</h3>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Control flow (20)</h4>
<div class="cg-grid">
<code>[[</code>
<code>]]</code>
<code>always</code>
<code>case</code>
<code>do</code>
<code>done</code>
<code>elif</code>
<code>else</code>
<code>end</code>
<code>esac</code>
<code>fi</code>
<code>for</code>
<code>foreach</code>
<code>if</code>
<code>in</code>
<code>repeat</code>
<code>select</code>
<code>then</code>
<code>until</code>
<code>while</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Declaration (10)</h4>
<div class="cg-grid">
<code>declare</code>
<code>export</code>
<code>float</code>
<code>integer</code>
<code>let</code>
<code>local</code>
<code>readonly</code>
<code>set</code>
<code>shift</code>
<code>typeset</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Function (1)</h4>
<div class="cg-grid">
<code>function</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Grouping (2)</h4>
<div class="cg-grid">
<code>{</code>
<code>}</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">I/O / source (5)</h4>
<div class="cg-grid">
<code>.</code>
<code>eval</code>
<code>exec</code>
<code>source</code>
<code>trap</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Loop control (5)</h4>
<div class="cg-grid">
<code>break</code>
<code>continue</code>
<code>exit</code>
<code>logout</code>
<code>return</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Modifier (precommand) (6)</h4>
<div class="cg-grid">
<code>builtin</code>
<code>command</code>
<code>coproc</code>
<code>nocorrect</code>
<code>noglob</code>
<code>time</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">Operator-like (1)</h4>
<div class="cg-grid">
<code>!</code>
</div>
</div>
<div class="cg-section">
<h3>Builtins (157)</h3>
<p class="cg-meta">Every command implemented inside the shell — no fork/exec required.</p>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">POSIX / zsh core (74)</h4>
<div class="cg-grid">
<code>.</code>
<code>:</code>
<code>[</code>
<code>alias</code>
<code>autoload</code>
<code>bg</code>
<code>break</code>
<code>bye</code>
<code>cd</code>
<code>chdir</code>
<code>continue</code>
<code>declare</code>
<code>dirs</code>
<code>disable</code>
<code>disown</code>
<code>echo</code>
<code>emulate</code>
<code>enable</code>
<code>eval</code>
<code>exit</code>
<code>export</code>
<code>false</code>
<code>fc</code>
<code>fg</code>
<code>float</code>
<code>functions</code>
<code>getln</code>
<code>getopts</code>
<code>hash</code>
<code>hashinfo</code>
<code>history</code>
<code>integer</code>
<code>jobs</code>
<code>kill</code>
<code>let</code>
<code>local</code>
<code>logout</code>
<code>mem</code>
<code>patdebug</code>
<code>popd</code>
<code>print</code>
<code>printf</code>
<code>pushd</code>
<code>pushln</code>
<code>pwd</code>
<code>r</code>
<code>read</code>
<code>readonly</code>
<code>rehash</code>
<code>return</code>
<code>set</code>
<code>setopt</code>
<code>shift</code>
<code>source</code>
<code>suspend</code>
<code>test</code>
<code>times</code>
<code>trap</code>
<code>true</code>
<code>ttyctl</code>
<code>type</code>
<code>typeset</code>
<code>umask</code>
<code>unalias</code>
<code>unfunction</code>
<code>unhash</code>
<code>unset</code>
<code>unsetopt</code>
<code>wait</code>
<code>whence</code>
<code>where</code>
<code>which</code>
<code>zcompile</code>
<code>zmodload</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">zsh modules (59)</h4>
<div class="cg-grid">
<code>cap</code>
<code>chgrp</code>
<code>chmod</code>
<code>chown</code>
<code>clone</code>
<code>echotc</code>
<code>echoti</code>
<code>example</code>
<code>getcap</code>
<code>ln</code>
<code>local</code>
<code>log</code>
<code>mkdir</code>
<code>mv</code>
<code>nameref</code>
<code>pcre_compile</code>
<code>pcre_match</code>
<code>pcre_study</code>
<code>private</code>
<code>rm</code>
<code>rmdir</code>
<code>setcap</code>
<code>stat</code>
<code>strftime</code>
<code>sync</code>
<code>syserror</code>
<code>sysopen</code>
<code>sysread</code>
<code>sysseek</code>
<code>syswrite</code>
<code>zcurses</code>
<code>zdelattr</code>
<code>zf_chgrp</code>
<code>zf_chmod</code>
<code>zf_chown</code>
<code>zf_ln</code>
<code>zf_mkdir</code>
<code>zf_mv</code>
<code>zf_rm</code>
<code>zf_rmdir</code>
<code>zf_sync</code>
<code>zformat</code>
<code>zftp</code>
<code>zgdbmpath</code>
<code>zgetattr</code>
<code>zlistattr</code>
<code>zparseopts</code>
<code>zprof</code>
<code>zpty</code>
<code>zregexparse</code>
<code>zselect</code>
<code>zsetattr</code>
<code>zsocket</code>
<code>zstat</code>
<code>zstyle</code>
<code>zsystem</code>
<code>ztcp</code>
<code>ztie</code>
<code>zuntie</code>
</div>
<h4 style="margin:0.7rem 0 0.3rem;color:var(--accent);font-size:11px;letter-spacing:1px;text-transform:uppercase;">zshrs extensions (24)</h4>
<div class="cg-grid">
<code>zask</code>
<code>zcache</code>
<code>zcompdump</code>
<code>zcomplete</code>
<code>zd</code>
<code>zhistory</code>
<code>zid</code>
<code>zjob</code>
<code>zlock</code>
<code>zlog</code>
<code>zls</code>
<code>znotify</code>
<code>zping</code>
<code>zpublish</code>
<code>zsend</code>
<code>zsource</code>
<code>zsubscribe</code>
<code>zsuggest</code>
<code>zsync</code>
<code>ztag</code>
<code>zunsubscribe</code>
<code>zuntag</code>
<code>zwc</code>
<code>zwhere</code>
</div>
</div>
<div class="cg-section">
<h3>setopt options (196)</h3>
<p class="cg-meta">All upstream zsh options recognized by name; use <code>setopt</code> / <code>unsetopt</code> to toggle, or <code>NO_</code> prefix (e.g. <code>NO_GLOB</code>).</p>
<div class="cg-grid">
<code>ALIASES</code>
<code>ALIASFUNCDEF</code>
<code>ALLEXPORT</code>
<code>ALWAYSLASTPROMPT</code>
<code>ALWAYSTOEND</code>
<code>APPENDCREATE</code>
<code>APPENDHISTORY</code>
<code>AUTOCD</code>
<code>AUTOCONTINUE</code>
<code>AUTOLIST</code>
<code>AUTOMENU</code>
<code>AUTONAMEDIRS</code>
<code>AUTOPARAMKEYS</code>
<code>AUTOPARAMSLASH</code>
<code>AUTOPUSHD</code>
<code>AUTOREMOVESLASH</code>
<code>AUTORESUME</code>
<code>BADPATTERN</code>
<code>BANGHIST</code>
<code>BAREGLOBQUAL</code>
<code>BASHAUTOLIST</code>
<code>BASHREMATCH</code>
<code>BEEP</code>
<code>BGNICE</code>
<code>BRACECCL</code>
<code>BRACEEXPAND</code>
<code>BSDECHO</code>
<code>CASEGLOB</code>
<code>CASEMATCH</code>
<code>CASEPATHS</code>
<code>CBASES</code>
<code>CDABLEVARS</code>
<code>CDSILENT</code>
<code>CHASEDOTS</code>
<code>CHASELINKS</code>
<code>CHECKJOBS</code>
<code>CHECKRUNNINGJOBS</code>
<code>CLOBBER</code>
<code>CLOBBEREMPTY</code>
<code>COMBININGCHARS</code>
<code>COMPLETEALIASES</code>
<code>COMPLETEINWORD</code>
<code>CONTINUEONERROR</code>
<code>CORRECT</code>
<code>CORRECTALL</code>
<code>CPRECEDENCES</code>
<code>CSHJUNKIEHISTORY</code>
<code>CSHJUNKIELOOPS</code>
<code>CSHJUNKIEQUOTES</code>
<code>CSHNULLCMD</code>
<code>CSHNULLGLOB</code>
<code>DEBUGBEFORECMD</code>
<code>DOTGLOB</code>
<code>DVORAK</code>
<code>EMACS</code>
<code>EQUALS</code>
<code>ERREXIT</code>
<code>ERRRETURN</code>
<code>EVALLINENO</code>
<code>EXEC</code>
<code>EXTENDEDGLOB</code>
<code>EXTENDEDHISTORY</code>
<code>FLOWCONTROL</code>
<code>FORCEFLOAT</code>
<code>FUNCTIONARGZERO</code>
<code>GLOB</code>
<code>GLOBALEXPORT</code>
<code>GLOBALRCS</code>
<code>GLOBASSIGN</code>
<code>GLOBCOMPLETE</code>
<code>GLOBDOTS</code>
<code>GLOBSTARSHORT</code>
<code>GLOBSUBST</code>
<code>HASHALL</code>
<code>HASHCMDS</code>
<code>HASHDIRS</code>
<code>HASHEXECUTABLESONLY</code>
<code>HASHLISTALL</code>
<code>HISTALLOWCLOBBER</code>
<code>HISTAPPEND</code>
<code>HISTBEEP</code>
<code>HISTEXPAND</code>
<code>HISTEXPIREDUPSFIRST</code>
<code>HISTFCNTLLOCK</code>
<code>HISTFINDNODUPS</code>
<code>HISTIGNOREALLDUPS</code>
<code>HISTIGNOREDUPS</code>
<code>HISTIGNORESPACE</code>
<code>HISTLEXWORDS</code>
<code>HISTNOFUNCTIONS</code>
<code>HISTNOSTORE</code>
<code>HISTREDUCEBLANKS</code>
<code>HISTSAVEBYCOPY</code>
<code>HISTSAVENODUPS</code>
<code>HISTSUBSTPATTERN</code>
<code>HISTVERIFY</code>
<code>HUP</code>
<code>IGNOREBRACES</code>
<code>IGNORECLOSEBRACES</code>
<code>IGNOREEOF</code>
<code>INCAPPENDHISTORY</code>
<code>INCAPPENDHISTORYTIME</code>
<code>INTERACTIVE</code>
<code>INTERACTIVECOMMENTS</code>
<code>KSHARRAYS</code>
<code>KSHAUTOLOAD</code>
<code>KSHGLOB</code>
<code>KSHOPTIONPRINT</code>
<code>KSHTYPESET</code>
<code>KSHZEROSUBSCRIPT</code>
<code>LISTAMBIGUOUS</code>
<code>LISTBEEP</code>
<code>LISTPACKED</code>
<code>LISTROWSFIRST</code>
<code>LISTTYPES</code>
<code>LOCALLOOPS</code>
<code>LOCALOPTIONS</code>
<code>LOCALPATTERNS</code>
<code>LOCALTRAPS</code>
<code>LOG</code>
<code>LOGIN</code>
<code>LONGLISTJOBS</code>
<code>MAGICEQUALSUBST</code>
<code>MAILWARN</code>
<code>MAILWARNING</code>
<code>MARKDIRS</code>
<code>MENUCOMPLETE</code>
<code>MONITOR</code>
<code>MULTIBYTE</code>
<code>MULTIFUNCDEF</code>
<code>MULTIOS</code>
<code>NOMATCH</code>
<code>NOTIFY</code>
<code>NULLGLOB</code>
<code>NUMERICGLOBSORT</code>
<code>OCTALZEROES</code>
<code>ONECMD</code>
<code>OVERSTRIKE</code>
<code>PATHDIRS</code>
<code>PATHSCRIPT</code>
<code>PHYSICAL</code>
<code>PIPEFAIL</code>
<code>POSIXALIASES</code>
<code>POSIXARGZERO</code>
<code>POSIXBUILTINS</code>
<code>POSIXCD</code>
<code>POSIXIDENTIFIERS</code>
<code>POSIXJOBS</code>
<code>POSIXSTRINGS</code>
<code>POSIXTRAPS</code>
<code>PRINTEIGHTBIT</code>
<code>PRINTEXITVALUE</code>
<code>PRIVILEGED</code>
<code>PROMPTBANG</code>
<code>PROMPTCR</code>
<code>PROMPTPERCENT</code>
<code>PROMPTSP</code>
<code>PROMPTSUBST</code>
<code>PROMPTVARS</code>
<code>PUSHDIGNOREDUPS</code>
<code>PUSHDMINUS</code>
<code>PUSHDSILENT</code>
<code>PUSHDTOHOME</code>
<code>RCEXPANDPARAM</code>
<code>RCQUOTES</code>
<code>RCS</code>
<code>RECEXACT</code>
<code>REMATCHPCRE</code>
<code>RMSTARSILENT</code>
<code>RMSTARWAIT</code>
<code>SHAREHISTORY</code>
<code>SHFILEEXPANSION</code>
<code>SHGLOB</code>
<code>SHINSTDIN</code>
<code>SHNULLCMD</code>
<code>SHOPTIONLETTERS</code>
<code>SHORTLOOPS</code>
<code>SHORTREPEAT</code>
<code>SHWORDSPLIT</code>
<code>SINGLECOMMAND</code>
<code>SINGLELINEZLE</code>
<code>SOURCETRACE</code>
<code>STDIN</code>
<code>SUNKEYBOARDHACK</code>
<code>TRACKALL</code>
<code>TRANSIENTRPROMPT</code>
<code>TRAPSASYNC</code>
<code>TYPESETSILENT</code>
<code>TYPESETTOUNSET</code>
<code>UNSET</code>
<code>VERBOSE</code>
<code>VI</code>
<code>WARNCREATEGLOBAL</code>
<code>WARNNESTEDVAR</code>
<code>XTRACE</code>
<code>ZLE</code>
</div>
</div>
<div class="cg-section">
<h3>Special variables (88)</h3>
<p class="cg-meta">Includes scalar (<code>$?</code>, <code>$RANDOM</code>) and array forms (<code>$path</code>, <code>$pipestatus</code>); upper-case and lower-case names are linked pairs where applicable.</p>
<div class="cg-grid">
<code>$!</code>
<code>$#</code>
<code>$$</code>
<code>$*</code>
<code>$-</code>
<code>$0</code>
<code>$?</code>
<code>$@</code>
<code>$ARGC</code>
<code>$CDPATH</code>
<code>$COLUMNS</code>
<code>$EGID</code>
<code>$ERRNO</code>
<code>$EUID</code>
<code>$FIGNORE</code>
<code>$FPATH</code>
<code>$FUNCNEST</code>
<code>$GID</code>
<code>$HISTCHARS</code>
<code>$HISTCMD</code>
<code>$HISTSIZE</code>
<code>$HOME</code>
<code>$IFS</code>
<code>$KEYBOARD_HACK</code>
<code>$LANG</code>
<code>$LC_ALL</code>
<code>$LC_COLLATE</code>
<code>$LC_CTYPE</code>
<code>$LC_MESSAGES</code>
<code>$LC_NUMERIC</code>
<code>$LC_TIME</code>
<code>$LINENO</code>
<code>$LINES</code>
<code>$MAILPATH</code>
<code>$MANPATH</code>
<code>$MODULE_PATH</code>
<code>$NULLCMD</code>
<code>$OPTARG</code>
<code>$OPTIND</code>
<code>$PATH</code>
<code>$POSTEDIT</code>
<code>$PPID</code>
<code>$PROMPT</code>
<code>$PROMPT2</code>
<code>$PROMPT3</code>
<code>$PROMPT4</code>
<code>$PS1</code>
<code>$PS2</code>
<code>$PS3</code>
<code>$PS4</code>
<code>$PSVAR</code>
<code>$RANDOM</code>
<code>$READNULLCMD</code>
<code>$RPROMPT</code>
<code>$RPROMPT2</code>
<code>$RPS1</code>
<code>$RPS2</code>
<code>$SAVEHIST</code>
<code>$SECONDS</code>
<code>$SHLVL</code>
<code>$SPROMPT</code>
<code>$TERM</code>
<code>$TERMINFO</code>
<code>$TERMINFO_DIRS</code>
<code>$TRY_BLOCK_ERROR</code>
<code>$TRY_BLOCK_INTERRUPT</code>
<code>$TTYIDLE</code>
<code>$UID</code>
<code>$USERNAME</code>
<code>$WORDCHARS</code>
<code>$ZLE_RPROMPT_INDENT</code>
<code>$ZSH_EVAL_CONTEXT</code>
<code>$ZSH_SUBSHELL</code>
<code>$_</code>
<code>$argv</code>
<code>$cdpath</code>
<code>$fignore</code>
<code>$fpath</code>
<code>$histchars</code>
<code>$mailpath</code>
<code>$manpath</code>
<code>$module_path</code>
<code>$path</code>
<code>$pipestatus</code>
<code>$prompt</code>
<code>$psvar</code>
<code>$status</code>
<code>$zsh_eval_context</code>
</div>
</div>
<div class="cg-section">
<h3>Parameter expansion flags (38)</h3>
<p class="cg-meta">Single-letter modifiers inside <code>${(X)var}</code>. Composable: <code>${(jL)arr}</code> = join lowercase.</p>
<table class="cg-table">
<thead><tr><th>Flag</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>${(@)var}</code></td><td>array-context retain $@ semantics; quoting-preserving even in scalar context</td></tr>
<tr><td><code>${(A)var}</code></td><td>create as an array</td></tr>
<tr><td><code>${(a)var}</code></td><td>sort by array index</td></tr>
<tr><td><code>${(c)var}</code></td><td>count words in a parameter (e.g., scalar split count)</td></tr>
<tr><td><code>${(C)var}</code></td><td>capitalize words</td></tr>
<tr><td><code>${(D)var}</code></td><td>treat as DIRECTORY name (apply directory substitution like ~/...)</td></tr>
<tr><td><code>${(e)var}</code></td><td>perform parameter expansion / arithmetic / etc. on the result</td></tr>
<tr><td><code>${(f)var}</code></td><td>split result at newlines</td></tr>
<tr><td><code>${(F)var}</code></td><td>join array elements with newlines</td></tr>
<tr><td><code>${(g)var}</code></td><td>process escape sequences like print does (g:o: process octals, g:c: process \c)</td></tr>
<tr><td><code>${(i)var}</code></td><td>case-insensitive sort</td></tr>
<tr><td><code>${(j)var}</code></td><td>join array with separator: ${(j:sep:)arr}</td></tr>
<tr><td><code>${(k)var}</code></td><td>for assoc arrays: keys ${(k)hash}</td></tr>
<tr><td><code>${(K)var}</code></td><td>subscript flags: use keys</td></tr>
<tr><td><code>${(L)var}</code></td><td>lowercase</td></tr>
<tr><td><code>${(M)var}</code></td><td>match: use longest match (also for case-insensitivity in sort)</td></tr>
<tr><td><code>${(n)var}</code></td><td>numeric sort</td></tr>
<tr><td><code>${(o)var}</code></td><td>sort ascending</td></tr>
<tr><td><code>${(O)var}</code></td><td>sort descending</td></tr>
<tr><td><code>${(p)var}</code></td><td>interpret embedded escape sequences in j/s separator</td></tr>
<tr><td><code>${(P)var}</code></td><td>treat value as parameter name → indirect (P)</td></tr>
<tr><td><code>${(q)var}</code></td><td>quote the result (q-/q+/qq/qqq variants for shell-quote levels)</td></tr>
<tr><td><code>${(Q)var}</code></td><td>remove quoting</td></tr>
<tr><td><code>${(r)var}</code></td><td>right-justify within field width: ${(r:N::pad:)var}</td></tr>
<tr><td><code>${(l)var}</code></td><td>left-justify within field width: ${(l:N::pad:)var}</td></tr>
<tr><td><code>${(s)var}</code></td><td>split at separator: ${(s:sep:)var}</td></tr>
<tr><td><code>${(S)var}</code></td><td>subscript: search subscript ranges</td></tr>
<tr><td><code>${(t)var}</code></td><td>test parameter type</td></tr>
<tr><td><code>${(u)var}</code></td><td>unique (dedupe array)</td></tr>
<tr><td><code>${(U)var}</code></td><td>uppercase</td></tr>
<tr><td><code>${(v)var}</code></td><td>for assoc arrays: values ${(v)hash}</td></tr>
<tr><td><code>${(V)var}</code></td><td>make invisible / control chars visible</td></tr>
<tr><td><code>${(w)var}</code></td><td>split into words</td></tr>
<tr><td><code>${(W)var}</code></td><td>split into words (alternate)</td></tr>
<tr><td><code>${(z)var}</code></td><td>split as the shell would (z-tokens)</td></tr>
<tr><td><code>${(#)var}</code></td><td>expand result as arithmetic; numeric value</td></tr>
<tr><td><code>${(%)var}</code></td><td>expand prompt percent escapes in result</td></tr>
<tr><td><code>${(~)var}</code></td><td>treat values as patterns (e.g., for /pat/repl)</td></tr>
</tbody>
</table>
</div>
<div class="cg-section">
<h3>Glob qualifiers (44)</h3>
<p class="cg-meta">Modifiers inside <code>*(X)</code>. Composable; use <code>^</code> to negate the group, <code>,</code> to OR-combine groups.</p>
<table class="cg-table">
<thead><tr><th>Qual</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>*(/)</code></td><td>directories only</td></tr>
<tr><td><code>*(.)</code></td><td>regular files only</td></tr>
<tr><td><code>*(@)</code></td><td>symbolic links only</td></tr>
<tr><td><code>*(=)</code></td><td>sockets only</td></tr>
<tr><td><code>*(p)</code></td><td>named pipes (FIFOs) only</td></tr>
<tr><td><code>*(*)</code></td><td>executable plain files only</td></tr>
<tr><td><code>*(%)</code></td><td>device special files only</td></tr>
<tr><td><code>*(%b)</code></td><td>block special files</td></tr>
<tr><td><code>*(%c)</code></td><td>character special files</td></tr>
<tr><td><code>*(r)</code></td><td>owner-readable</td></tr>
<tr><td><code>*(w)</code></td><td>owner-writable</td></tr>
<tr><td><code>*(x)</code></td><td>owner-executable</td></tr>
<tr><td><code>*(A)</code></td><td>group-readable</td></tr>
<tr><td><code>*(I)</code></td><td>group-writable</td></tr>
<tr><td><code>*(E)</code></td><td>group-executable</td></tr>
<tr><td><code>*(R)</code></td><td>world-readable</td></tr>
<tr><td><code>*(W)</code></td><td>world-writable</td></tr>
<tr><td><code>*(X)</code></td><td>world-executable</td></tr>
<tr><td><code>*(s)</code></td><td>setuid (S_ISUID)</td></tr>
<tr><td><code>*(S)</code></td><td>setgid (S_ISGID)</td></tr>
<tr><td><code>*(t)</code></td><td>sticky bit</td></tr>
<tr><td><code>*(d N)</code></td><td>device number N</td></tr>
<tr><td><code>*(l[+-=]N)</code></td><td>exactly / less-than / greater-than N hard links</td></tr>
<tr><td><code>*(U)</code></td><td>owned by EUID</td></tr>
<tr><td><code>*(G)</code></td><td>owned by EGID</td></tr>
<tr><td><code>*(u N)</code></td><td>owned by uid N</td></tr>
<tr><td><code>*(g N)</code></td><td>group gid N</td></tr>
<tr><td><code>*(f spec)</code></td><td>permission mask: f:o+w: e.g.</td></tr>
<tr><td><code>*(L [+-=] N)</code></td><td>size: blocks / k / m / p suffix (Lk / Lm / Lp)</td></tr>
<tr><td><code>*(a [Mwhms] [+-=] N)</code></td><td>access time</td></tr>
<tr><td><code>*(m [Mwhms] [+-=] N)</code></td><td>modify time</td></tr>
<tr><td><code>*(c [Mwhms] [+-=] N)</code></td><td>ctime</td></tr>
<tr><td><code>*(o [name|size|links|mtime|atime|ctime])</code></td><td>sort ascending</td></tr>
<tr><td><code>*(O [name|size|links|mtime|atime|ctime])</code></td><td>sort descending</td></tr>
<tr><td><code>*([N,M])</code></td><td>select range of matches</td></tr>
<tr><td><code>*(e:str:)</code></td><td>external test: each match passed to expression</td></tr>
<tr><td><code>*(+func)</code></td><td>external test: each match passed to function</td></tr>
<tr><td><code>*(N)</code></td><td>nullglob: silently drop unmatched pattern</td></tr>
<tr><td><code>*(D)</code></td><td>include dotfiles</td></tr>
<tr><td><code>*(Y N)</code></td><td>limit to N results</td></tr>
<tr><td><code>*(M)</code></td><td>include directory names as if trailing slash</td></tr>
<tr><td><code>*(:mod)</code></td><td>apply history modifier (e.g., :t :h :r :e)</td></tr>
<tr><td><code>*(^)</code></td><td>negate the qualifier list</td></tr>
<tr><td><code>*(,)</code></td><td>OR-combine qualifier groups</td></tr>
</tbody>
</table>
</div>
<div class="cg-section">
<h3>Operators / redirections / substitution forms (55)</h3>
<p class="cg-meta">Lexer-recognized tokens. Grouped by <code>kind</code>: pipeline / list / case / redirect / procsub / subst / arith / cond / assign / compare / glob / tilde / brace / expansion / string / extension.</p>
<table class="cg-table">
<thead><tr><th>Symbol</th><th>Kind</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>|</code></td><td>pipeline</td><td>Pipeline. stdout of LHS → stdin of RHS.</td></tr>
<tr><td><code>|&</code></td><td>pipeline</td><td>Pipeline with stderr merged (= |2>&1).</td></tr>
<tr><td><code>&&</code></td><td>list</td><td>Logical AND: run RHS only if LHS exit==0.</td></tr>
<tr><td><code>||</code></td><td>list</td><td>Logical OR: run RHS only if LHS exit!=0.</td></tr>
<tr><td><code>;</code></td><td>list</td><td>Sequence: run RHS after LHS regardless of status.</td></tr>
<tr><td><code>&</code></td><td>list</td><td>Background: run LHS async; sets $!.</td></tr>
<tr><td><code>;;</code></td><td>case</td><td>End case arm.</td></tr>
<tr><td><code>;;&</code></td><td>case</td><td>Fall through and test next case pattern.</td></tr>
<tr><td><code>;|</code></td><td>case</td><td>Fall through without test.</td></tr>
<tr><td><code>!</code></td><td>neg</td><td>Negate exit status (reserved word).</td></tr>
<tr><td><code>></code></td><td>redirect</td><td>Stdout redirect (overwrite).</td></tr>
<tr><td><code>>></code></td><td>redirect</td><td>Stdout append.</td></tr>
<tr><td><code><</code></td><td>redirect</td><td>Stdin redirect.</td></tr>
<tr><td><code><<</code></td><td>redirect</td><td>Heredoc; body terminated by marker.</td></tr>
<tr><td><code><<-</code></td><td>redirect</td><td>Heredoc, strip leading tabs from body.</td></tr>
<tr><td><code><<<</code></td><td>redirect</td><td>Here-string; literal text as stdin.</td></tr>
<tr><td><code>>|</code></td><td>redirect</td><td>Stdout force-overwrite (bypass NO_CLOBBER).</td></tr>
<tr><td><code>>!</code></td><td>redirect</td><td>Same as >|; force-overwrite.</td></tr>
<tr><td><code>&></code></td><td>redirect</td><td>Redirect both stdout and stderr (bash-compat).</td></tr>
<tr><td><code>&>></code></td><td>redirect</td><td>Append both stdout and stderr.</td></tr>
<tr><td><code>2>&1</code></td><td>redirect</td><td>Duplicate fd2 to fd1 (stderr → stdout).</td></tr>
<tr><td><code>>&-</code></td><td>redirect</td><td>Close fd.</td></tr>
<tr><td><code><></code></td><td>redirect</td><td>Open for read+write.</td></tr>
<tr><td><code><(</code></td><td>procsub</td><td>Process substitution: <(cmd) is a path readable from cmd's stdout.</td></tr>
<tr><td><code>>(</code></td><td>procsub</td><td>Process substitution: >(cmd) is a path writable into cmd's stdin.</td></tr>
<tr><td><code>=(</code></td><td>procsub</td><td>Zsh-only =(cmd): tempfile capture.</td></tr>
<tr><td><code>$(</code></td><td>subst</td><td>Command substitution: $(cmd) captures cmd's stdout.</td></tr>
<tr><td><code>${</code></td><td>subst</td><td>Parameter expansion: ${var}.</td></tr>
<tr><td><code>$((</code></td><td>subst</td><td>Arithmetic expansion: $((expr)).</td></tr>
<tr><td><code>((</code></td><td>arith</td><td>Arithmetic command. ((expr)) exits 0 iff expr != 0.</td></tr>
<tr><td><code>))</code></td><td>arith</td><td>Close arithmetic command.</td></tr>
<tr><td><code>[[</code></td><td>cond</td><td>Open conditional command: [[ expr ]].</td></tr>
<tr><td><code>]]</code></td><td>cond</td><td>Close conditional command.</td></tr>
<tr><td><code>=</code></td><td>assign</td><td>Assignment. Also: equality in [[ ]].</td></tr>
<tr><td><code>+=</code></td><td>assign</td><td>Append assignment (scalar concat / array push).</td></tr>
<tr><td><code>-=</code></td><td>assign</td><td>Numeric subtract-assign (in (( ))). </td></tr>
<tr><td><code>:=</code></td><td>assign</td><td>${var:=default}: assign default if unset/empty.</td></tr>
<tr><td><code>?=</code></td><td>assign</td><td>(arith) ternary.</td></tr>
<tr><td><code>==</code></td><td>compare</td><td>Equality in (( )) / [[ ]].</td></tr>
<tr><td><code>!=</code></td><td>compare</td><td>Inequality.</td></tr>
<tr><td><code>=~</code></td><td>compare</td><td>Regex match in [[ ]] (POSIX ERE / PCRE depending on opts).</td></tr>
<tr><td><code>*</code></td><td>glob</td><td>Glob: match any sequence (including empty).</td></tr>
<tr><td><code>**</code></td><td>glob</td><td>Recursive glob (matches dir/subdir/.../ levels).</td></tr>
<tr><td><code>?</code></td><td>glob</td><td>Glob: match one character.</td></tr>
<tr><td><code>~</code></td><td>tilde</td><td>Tilde expansion: ~ → $HOME, ~user, ~+ / ~- / ~N for dirstack.</td></tr>
<tr><td><code>{a,b,c}</code></td><td>brace</td><td>Brace expansion: comma-separated list.</td></tr>
<tr><td><code>{1..10}</code></td><td>brace</td><td>Brace expansion: numeric range.</td></tr>
<tr><td><code>{a..z}</code></td><td>brace</td><td>Brace expansion: character range.</td></tr>
<tr><td><code>${~var}</code></td><td>expansion</td><td>Treat result of var as pattern.</td></tr>
<tr><td><code>${^var}</code></td><td>expansion</td><td>Array element rcexpansion.</td></tr>
<tr><td><code>${=var}</code></td><td>expansion</td><td>Word-split on IFS.</td></tr>
<tr><td><code>$'…'</code></td><td>string</td><td>ANSI-C quoted string: \n \t \xNN etc.</td></tr>
<tr><td><code>$"…"</code></td><td>string</td><td>Locale-translated string.</td></tr>
<tr><td><code>`…`</code></td><td>subst</td><td>Backtick command substitution (legacy form of $()).</td></tr>
<tr><td><code>@{}</code></td><td>extension</td><td>Zshrs @-prefix: dispatch to stryke embedded scripting.</td></tr>
</tbody>
</table>
</div>
<div class="cg-section">
<h3>History expansions (10)</h3>
<p class="cg-meta">Recall previous commands / words. Lexer-stage expansion before parsing.</p>
<table class="cg-table">
<thead><tr><th>Form</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>!!</code></td><td>previous command</td></tr>
<tr><td><code>!N</code></td><td>command N in history</td></tr>
<tr><td><code>!-N</code></td><td>command N back</td></tr>
<tr><td><code>!?str</code></td><td>most recent containing str</td></tr>
<tr><td><code>!str</code></td><td>most recent starting with str</td></tr>
<tr><td><code>!$</code></td><td>last word of previous command</td></tr>
<tr><td><code>!^</code></td><td>first arg of previous command</td></tr>
<tr><td><code>!*</code></td><td>all args of previous command</td></tr>
<tr><td><code>!:N</code></td><td>Nth word of previous command</td></tr>
<tr><td><code>^old^new</code></td><td>quick substitute in previous command</td></tr>
</tbody>
</table>
</div>
<div class="cg-section">
<h3>Word modifiers (16)</h3>
<p class="cg-meta">Trailing <code>:X</code> modifiers applied to history words, filename expansions, and parameter results.</p>
<table class="cg-table">
<thead><tr><th>Modifier</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>:h</code></td><td>head: dirname of path</td></tr>
<tr><td><code>:t</code></td><td>tail: basename of path</td></tr>
<tr><td><code>:r</code></td><td>root: strip extension</td></tr>
<tr><td><code>:e</code></td><td>extension: keep only extension</td></tr>
<tr><td><code>:l</code></td><td>lowercase</td></tr>
<tr><td><code>:u</code></td><td>uppercase</td></tr>
<tr><td><code>:q</code></td><td>quote for shell re-input</td></tr>
<tr><td><code>:Q</code></td><td>remove quoting</td></tr>
<tr><td><code>:s/old/new/</code></td><td>substitute first match</td></tr>
<tr><td><code>:gs/old/new/</code></td><td>global substitute</td></tr>
<tr><td><code>:a</code></td><td>absolutize (resolve relative path)</td></tr>
<tr><td><code>:A</code></td><td>absolutize and resolve symlinks</td></tr>
<tr><td><code>:P</code></td><td>physical resolved path</td></tr>
<tr><td><code>:x</code></td><td>split into words on whitespace</td></tr>
<tr><td><code>:w</code></td><td>select words</td></tr>
<tr><td><code>:F</code></td><td>follow symlinks (in conjunction with above)</td></tr>
</tbody>
</table>
</div>
<!-- END CANONICAL-GRAMMAR -->
<p style="font-size: 11px; color: var(--text-muted); text-align: center; margin: 3rem 0 1rem; font-family: 'Share Tech Mono', monospace;">
// zshrs v0.13.52 · 14 chapters
</p>
</main>
</div>
<script src="hud-theme.js"></script>
</body>
</html>