# basic types:
echo 'single quoted string'
echo "double quoted string"
echo $'string with esc\apes\x0din it'
echo $"string meant to be translated"


# comments:
# this is a comment
#this too
echo this is#nt a comment
dcop kate EditInterface#1 #this is
grep -e "^default/linux/amd64/" |\ #this is not a comment but #this is
mkdir this\ isnt\ #a\ comment
mkdir this\ isnt\\\;#a\ comment
mkdir this\\ #is a comment

# brace expansion
mv my_file.{JPG,jpg}
echo f.{01..100..3} f.{#..Z} f.{\{..\}} f.{$i..$j..$p}
echo f.{01..100} f.{a..Z} f.{'a'..$Z}
# no brace expansion
echo f.{..100} f.{a..Z..}


# special characters are escaped:
echo \(output\) \&\| \> \< \" \' \*


# variable substitution:
echo $filename.ext
echo $filename_ext
echo ${filename}_ext
echo text${array[$subscript]}.text
echo text${array["string"]}.text
echo short are $_, $$, $?, ${@}, etc.
echo ${variable/a/d}
echo ${1:-default}
echo ${10} $10a
echo $! $=!


# expression subst:
echo <beginfold id='1'>$((</beginfold id='1'> cd << ed + 1 <endfold id='1'>))</endfold id='1'>


# command subst:
echo <beginfold id='2'>$(</beginfold id='2'>ls -l<endfold id='2'>)</endfold id='2'>
echo `cat myfile`


# file subst:
echo <beginfold id='2'>$(</beginfold id='2'><$filename<endfold id='2'>)</endfold id='2'>
echo <beginfold id='2'>$(</beginfold id='2'></path/to/myfile<endfold id='2'>)</endfold id='2'>

# process subst:
sort <(show_labels) | sed 's/a/bg' > my_file.txt 2>&1


# All substitutions also work in strings:
echo "subst ${in}side string"  'not $inside this ofcourse'
echo "The result is <beginfold id='1'>$((</beginfold id='1'> $a + $b <endfold id='1'>))</endfold id='1'>. Thanks!"
echo "Your homedir contains `ls $HOME |wc -l` files."


# Escapes in strings:
p="String \` with \$ escapes \" ";


# keywords are black, builtins dark purple and common commands lighter purple
set
exit
login


# Other colorings:
error() <beginfold id='3'>{</beginfold id='3'>
	cat /usr/bin/lesspipe.sh
	runscript >& redir.bak
	exec 3>&4
<endfold id='3'>}</endfold id='3'>


# do - done make code blocks
while <beginfold id='1'>[</beginfold id='1'> $p -lt $q <endfold id='1'>]</endfold id='1'>
<beginfold id='4'>do</beginfold id='4'>
	chown 0644 $file.$p
<endfold id='4'>done</endfold id='4'>


# braces as well
run_prog | sort -u |
<beginfold id='3'>{</beginfold id='3'>
	echo Header
	while read a b d
	<beginfold id='4'>do</beginfold id='4'>
		echo $a/$b/$c
	<endfold id='4'>done</endfold id='4'>
	echo Footer
<endfold id='3'>}</endfold id='3'>


# Any constructions can be nested:
echo "A long string with <beginfold id='2'>$(</beginfold id='2'>
	<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> $count -gt 100 <endfold id='1'>]</endfold id='1'> ; then
		echo "much"
	else
		echo "not much"
	<endfold id='5'>fi</endfold id='5'> <endfold id='2'>)</endfold id='2'> substitutions." ;


# Even the case construct is correctly folded:
test -f blaat &&
<beginfold id='2'>(</beginfold id='2'>	do_something
	<beginfold id='6'>case</beginfold id='6'> $p in
		*bak<beginfold id='7'>)</beginfold id='7'>
			do_bak $p
			<endfold id='7'>;;</endfold id='7'>
		*<beginfold id='7'>)</beginfold id='7'>
			dont_bak $p
			<endfold id='7'>;;</endfold id='7'>
	<endfold id='6'>esac</endfold id='6'>
<endfold id='2'>)</endfold id='2'> # despite the extra parentheses in the case construction.


# more control flow
while :;
  break
  continue
  return
<endfold id='4'>done</endfold id='4'>


# variable assignments:
DIR=/dev
p=`ls`
LC_ALL="nl" dcop 'kate*'
_VAR=val
ARR=(this is an array)
ARR2=([this]=too [and]="this too")
usage="$0 -- version $VERSION
Multiple lines of output
can be possible."
ANSWER=yes	# here 'yes' isn't highlighed as command


# Some commands expect variable names, these are colored correctly:
export PATH=/my/bin:$PATH BLAAT
export A B D
local p=3  x  y='\'
read x y z <<< $hallo
unset B
declare -a VAR1 VAR2 && exit
declare less a && b
declare a=(1 2)
getopts :h:l::d arg
read #comment
let a=4+4 3+a b=c+3 d+3 d*4 # * is a glob

# options are recoqnized:
zip -f=file.zip
./configure  --destdir=/usr
make  destdir=/usr/


# [[ and [ correctly need spaces to be regarded as structure,
# otherwise they are patterns (currently treated as normal text)
<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> "$p" == "" <endfold id='1'>]</endfold id='1'> ; then
	ls /usr/bin/[a-z]*
elif <beginfold id='1'>[[</beginfold id='1'> $p == 0 <endfold id='1'>]]</endfold id='1'> ; then
	ls /usr/share/$p
<endfold id='5'>fi</endfold id='5'>

# Fixed:
ls a[ab]*		# dont try to interprete as assignment with subscript (fixed)
a[ab]
a[ab]=sa


# Here documents are difficult to catch:
cat > myfile << __EOF__
You're right, this is definitely no bash code
But ls more $parameters should be expanded.
__EOF__


# quoted:
cat << "EOF" | egrep "this" >&4   # the rest of the line is still considered bash source
You're right, this is definitely no bash code
But ls more $parameters should be expanded. :->
EOF

cat <<bla || exit
bla bla
bla


# indented:
<beginfold id='5'>if</beginfold id='5'> true
then
	cat <<- EOF
		Indented text with a $dollar or \$two
	EOF
elif <beginfold id='1'>[</beginfold id='1'> -d $file <endfold id='1'>]</endfold id='1'>; then
	cat <<- "EOF"
		Indented text without a $dollar
	EOF
<endfold id='5'>fi</endfold id='5'>

<beginfold id='5'>if</beginfold id='5'> ! <beginfold id='3'>{</beginfold id='3'> cmd1 && cmd2 ; <endfold id='3'>}</endfold id='3'>; then echo ok ; <endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> ! <beginfold id='3'>{</beginfold id='3'>cmd1 && cmd2<endfold id='3'>}</endfold id='3'>; then echo ok ; <endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> ! cmd1 arg; then echo ok ; <endfold id='5'>fi</endfold id='5'>

<beginfold id='6'>case</beginfold id='6'> 1 in
2<beginfold id='7'>)</beginfold id='7'> echo xxx;
<endfold id='7'>;;</endfold id='7'>
?<beginfold id='7'>)</beginfold id='7'> foo || yyy ; foo abc || echo abc <endfold id='7'>;;</endfold id='7'>
1<beginfold id='7'>)</beginfold id='7'> echo yyy;
<endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>

ls #should be outside of case 1 folding block

for i in `ls tests/auto/output/*.html`; <beginfold id='4'>do</beginfold id='4'>
    refFile=`echo $i | sed -e s,build,src, | sed -e s,output,reference, | sed -e s,.html,.ref.html,`
    cp -v $i $refFile
<endfold id='4'>done</endfold id='4'>

## >Settings >Configure Kate >Fonts & Colors >Highlitghing Text Styles >Scripts/Bash >Option >Change colors to some distinct color
## 1- In following line the -ucode should not be colored as option

pacman -Syu --needed intel-ucode grub
pacman -syu --needed intel-ucode grub

<beginfold id='1'>[[</beginfold id='1'> $line_name =~ \{([0-9]{1,})\}\{([0-9]{1,})\}(.*) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> $name =~ (.*)_(S[0-9]{2})(E[0-9]{2,3}[a-z]{0,1})_(.*) <endfold id='1'>]]</endfold id='1'>
rm /data/{hello1,hello2}/input/{bye1,$bye2}/si{a,${b},c{k,p{e,a}}}/*.non
rm /data/{aa,{e,i}t{b,c} # Not closed
rm /data/{aa,{e,i}t{b,c}}
rm /data/{aa,{i}}
rm /data{aa{bb{cc{dd}}}}
rm /data{aaa`aaa}aa`aaa}a

# TODO `

# commands
abc
cp
:
.
:#nokeyword
path/cmd
ec\
ho
2
'a'c
$ab
${ab}c
\ a
!a
'a'[
\ [
!a[
a{}d
a{bc}d
a{b,c}d
a'b'c
a$bc
a${bc}d
a\ b
a!b

# commands + params
shortopt -ol -f/fd/fd -hfd/fds - -ol'a'b -f'a'/fd/fd -h'a'fd/fds
longopt --long-a --long-b=value --file=* --file=file* --file=dir/file
longopt --long-a'a'b --long'a'-b=value --fi'a'le=*
noopt 3 3d -f -- -f --xx dir/file
opt param#nocomment ab'a'cd ~a .a #comments
path path/file dir/ / // 3/f a@/ 'a'/b d/'a'b a\ d/f f/f\
ile
path ~ ~/ ~a/ . .. ./a ../a
path /path/* /path/f* /path/f@ /path/f@(|) {a/b} a{b}/c a/b{c} a/{b} a/{b}c
glob ? * ?f *f f* f? **/ ~/* ~* /path/f* 'a'* 'a'f/?
# ksh pattern is in conflict with extended pattern
extglob @ @(*) @(f*|f??(f)) f!(+(?(@(*(f)f)f)f)f)f @'a'@(|) a@(?)
echo *.*~(lex|parse).[ch](^D^l1)
echo /tmp/foo*(u0^@:t) *(W,X) *(%W)
subs f! f!! f!s 'a'!s \( $v {a,b} {a} {a}/d {a\,} {a,} {a,\},b} ds/{a,b}sa/s

ls !?main
ls <beginfold id='2'>$(</beginfold id='2'>echo NF<endfold id='2'>)</endfold id='2'>(:a)
ls ${(s.:.)PATH} | grep '^...s'
ls (#i)*.pmm
ls (#ia1)README
ls (*/)#bar
ls (../)#junk2/down.txt(:a)
ls (^(backup*|cache*|list*|tmp)/)##*(.)
ls (_|)fred.php
ls (dev*|fred*|joe*)/index*
ls (x*~x[3-5])
ls (xx|yy)
ls *(*@)
ls *(+nt)
ls *(.)^php~*.c~*.txt
ls *(.L-20)
ls *(.L0)
ls *(.Om[1,5])
ls *(.^m0)
ls *(.e#age 2017-10-01:00:00:00 2017-10-08:23:59:59#) /tmp
ls *(.e-age 2018/09/01 2018/01/01-)
ls *(.f644)
ls *(.g:root:)
ls *(.m-1)
ls *(.mM+6)
ls *(.mh+3)
ls *(.mh-3)
ls *(.mh3)
ls *(.mw+2)
ls *(.om[0,5]e-age 2017/09/01 2017/10/01-)
ls *(.om[2,$]) old/
ls *(.rwg:nobody:u:root:)
ls *(.u:apache:)
ls *(/)
ls *(/^F)
ls *(L0f.go-w.)
ls *(Lk+100)
ls *(Lm+2)
ls *(R)
ls *([1,10])
ls *(^/,f44?,f.gu+w.,oL+rand,oe:"$cmd -x":P:echo::h)
ls *(m4)
ls *(mh0)
ls *(mw3)
ls *(${globqualifiers}N)
ls *(\^'/')
ls **.php
ls **/*(#ia2)readme
ls **/*(-@)
ls **/*(.)
ls **/*(.:g-w:)
ls **/*(.Lm+10)
ls **/*(D/e:'[[ -e $REPLY/index.php && -e $REPLY/index.html ]]':)
ls **/*(u0WLk+10m0)
ls **/*.(js|php|css)~(djr|libs|dompdf)/*~*/junk/*
ls **/*.(js|php|css)~(libs|locallibs|test|dompdf)/*
ls **/*.(php|inc)
ls **/*.(php|inc)~(libs|locallibs)/*(.OL[1,5])
ls **/*.txt(D.om[1,5])
ls **/*~*(${~${(j/|/)fignore}})(.^*)
ls **/*~*vssver.scc(.om[1,20])
ls **/*~pdf/*(.m0om[1,10])
ls **/^(vssver.scc|*.ini)(.om[1,20])
ls **/^vssver.scc(.om[1,20])
ls **/index.php~dev*(/*)##
ls **/main.{php,js,css}
ls *.(jpg|gif|png)(.)
ls *.*(e-age 2018/06/01 now-)
ls *.*(mM4)
ls *.*~(lex|parse).[ch](^D^l1)
ls *.*~[a-m]*(u:nobody:g:apache:.xX)
ls *.c(#q:s/#%(#b)s(*).c/'S${match[1]}.C'/)
ls *.c(:r)
ls *.c~lex.c
ls *.h~(fred|foo).h
ls *.{aux,dvi,log,toc}
ls *.{jpg,gif}(.N)
ls *[^2].php~*template*
ls *y(2|).cfm
ls *y2#.cfm
ls *~*.*(.)
ls ./*(Om[1,-11])
ls ./**/*(/od) 2> /dev/null
ls ./**/*.(php|inc|js)
ls ./**/*.{inc,php}
ls ./*.back(#qN)
ls ./{html,live}/**/*.(php|inc|js)~(**/wiki|**/dompdf)/*
ls /path/**/*(.a+10e{'stat -sA u +uidr $REPLY; f[$u]="$f[$u]$REPLY"'})
ls <-> <-6> <4-> <4-5> 0<-> {1..5} {2,3} {00..03} (4|5) [3-4]  [3-47-8] 0? ?2 *2
ls =some_file
ls DATA_[0-9](#c,4).csv
ls DATA_[0-9](#c3).csv
ls DATA_[0-9](#c4,).csv
ls DATA_[0-9](#c4,7).csv
ls PHP*/**/*.php
ls [01]<->201[45]/Daily\ report*.csv(e#age 2014/10/22 now#)
ls ^*.(css|php)(.)
ls ^?*.*
ls ^?*.*(D)
ls ^?*.[^.]*(D)
ls a(#c3).txt
ls file<20->
ls foot(fall)#.pl
ls fred<76-88>.pl
ls fred<76->.pl
ls fred^erick*
ls fred{09..13}.pl
ls fred{joe,sid}.pl
ls x*~(x3|x5)
ls x*~^x[3,5]
ls x*~x[3,5]
ls x^[3,5]
ls y2#.cfm y{2,}.cfm y(2|).cfm {y2,y}.cfm (y|y2).cfm y*.cfm
ls {^dev*,}/index.php(.N)
ls {_,}fred.php
ls {p..q}<5->{1..4}.(#I)php(.N)
ls ~1/*(.om[1])
ls **/*.php~*junk*/*  #find all calls to mail, ignoring junk directories
ls **/(*.cfm~(ctpigeonbot|env).cfm)
ls **/*.{js,php,css}~(libs|temp|tmp|test)/*
ls */*.php~libs/*~temp/*~test/*
ls **/(*.cfm~(ctpigeonbot|env).cfm)~*((#s)|/)junk*/*(.)
ls **/*.(js|php|css)~(libs|temp|test)/*
ls **/*.(js|php|css)~libs/*~temp/*~test/*
ls report/**/*.{inc,php}  # searching for a php variable
ls *.log(Ne-age 2006/10/04:10:15 2006/10/04:12:45-)
ls <beginfold id='2'>$(</beginfold id='2'>echo /c/aax/*(.om[1])<endfold id='2'>)</endfold id='2'>(+cyg) &
ls *~vssver.scc(.om[1])
ls /c/aax/*(.om[1]+cyg)
ls ${(ps:\0:)"<beginfold id='2'>$(</beginfold id='2'>grep -lZ foobar ./*.txt(.)<endfold id='2'>)</endfold id='2'>"}
ls [[[[]]x*

2 - f -f
!a -f
'a' -f
$a -f
! cmd

# coproc command (#460301)
coproc ls thisfiledoesntexist 2>&1
coproc <beginfold id='3'>{</beginfold id='3'> ls thisfiledoesntexist; read; <endfold id='3'>}</endfold id='3'> 2>&1

# redirections (prefix)
<<<s cat
<<<'s' cat
<<<'s's cat
<<<s's's cat
<<<s${s}s cat
<<< s${s}s cat
>&2 cat
<f cat
2>3 cat
2>&3 cat
2>& 3 cat
2>f cat
&>f cat
2>>(xless) cat
2<<(xless) cat
2>>(xless)cat
2<<(xless)cat

# redirections
cat f>2
cat d/f>2
cat d/f >2
cat d/f >& 2
cat >2 d/f
cat > 2
cat <(echo) <(echo a) <(echo a/f) <(echo ) <(echo a ) <(echo a/f )
cat 2>>(xless)
cat 2<<(xless)
cat 2>&1 &>f &>>f 2<&1- 2<>f 2<<heredoc
bla bla
heredoc
<<-'h' cat
bla
h
<<"'" cat
bla
'
r=<beginfold id='2'>$(</beginfold id='2'>xxx $@ 2>&1<endfold id='2'>)</endfold id='2'>

# branches
cat a|cat
cat a&cat
cat a||cat
cat a&&cat
cat a;cat
cat a | cat
cat a & cat
cat a || cat
cat a && cat
cat a ; cat
cat a'a';cat

# substitutions
echo '' 'a' '\' "" "a" "\\" "$a" "a""a"'a''a' a'b'c a"b"c a$'\n'c
echo a!bc a{a}b a{b,c}d a{b,{d,e}}d a\ b
echo a$bc a$b/c a${b}c a<beginfold id='1'>$((</beginfold id='1'>b-3<endfold id='1'>))</endfold id='1'>c a<beginfold id='2'>$(</beginfold id='2'>b<endfold id='2'>)</endfold id='2'>c a<beginfold id='2'>$(</beginfold id='2'>a b c<endfold id='2'>)</endfold id='2'>c
echo ${a[*]} ${a[@]} ${a[${b}]} ${a:-x$z} ${a/g} ${a//f/f} ${a//f*/f*}
echo ${!} ${!a} ${#a[1]} ${a:1:$b} <beginfold id='1'>$((</beginfold id='1'>++i,i--<endfold id='1'>))</endfold id='1'>
echo ${a:^v} ${=a:/#%a#?*/bla} ${x#??(#i)} ${das:-{}<a.zsh}
echo ${(f)"<beginfold id='2'>$(</beginfold id='2'><$1<endfold id='2'>)</endfold id='2'>"} ${${(Az)l}[$2]} ${(f)"<beginfold id='2'>$(</beginfold id='2'>eval ${(q)@[2,$]}<endfold id='2'>)</endfold id='2'>"}
echo ${(@)foo} ${(@)foo[1,2]} ${${(A)name}[1]} ${(AA)=name=...} ${(Q)${(z)foo}}
echo ${(ps.$sep.)val} ${(ps.${sep}.)val} ${(s.$sep.)val} ${(s.)(.)val}
echo ${(pr:2+3::_::$d:)var} ${(r:2+3::_::$d:)var}
echo ${${:-=cat}:h}
$foo:h34:a:gs/dfs/fds/:s/fds/d'd'f xyz $foo: $foo:O $foo:A
3=$foo:QQQ xyz $a[3,$]:h3:t1:e
echo ${${~foo}//\*/*.c}
echo !$ !!:$ !* !!:* !-2:2 !:-3 !:2* !:2- !:2-3 !^ !:1 !!:1
echo "$bg[blue]$fg[yellow]highlight a message"
echo "$bg[red]$fg[black]${(l:42::-:)}"
echo "${${(@)foo[2,4]}[2]}"
echo "${(j::)${(@Oa)${(s::):-hello}}}"
echo "${(j::)${(@Oa)${(s::):-hello}}}"
echo "<a href='$url'>$anchortext</a>"
echo <beginfold id='1'>$((</beginfold id='1'> sin(1/4.0)**2 + cos(1/4.0)**2 - 1 <endfold id='1'>))</endfold id='1'>
echo $a[${RANDOM}%1000] $a[${RANDOM}%11+10]
echo $convtable[158]
echo ${array[0]: -7 : +  22  }  ${array[1]: num  }
echo ${parameter##word} ${parameter%%word}
echo $f ' # $fred'
echo $f:e $f:h $f:h:h $f:r $f:t $f:t:r $file:r
echo ${(C)foo:gs/-/ /:r} ${(M)0%%<->} ${(j/x/s/x/)foo} ${(l:$COLUMNS::-:)}
echo ${(l:3::0:)${RANDOM}} ${(s/x/)foo%%1*} ${0##*[!0-9]}
echo ${a:2:2} ${a:2} ${a[1,3]} ${d/#?/} ${d/%?/} ${d[1,-2]} ${d[2,$]}
echo ${d[2,-1]} ${file##*/} ${file%.*} ${texfilepath%/*.*} *(f:u+rx,o-x:)
echo *(f:u+rx:) **/*(@-^./=%p) **/*(@-^./=%p) convert_csv.php(:a)
cd <beginfold id='2'>$(</beginfold id='2'>locate -l1 -r "/zoo.txt$"<endfold id='2'>)</endfold id='2'>(:h) # cd to directory of first occurence of a file zoo.txt
cd ${<beginfold id='2'>$(</beginfold id='2'>!!<endfold id='2'>)</endfold id='2'>[3]:h}  # cd to 3rd in list
cd ${<beginfold id='2'>$(</beginfold id='2'>locate zoo.txt<endfold id='2'>)</endfold id='2'>[1]:h}
cd ${drive}/inetpub/wwwdev/www.some.co.uk/
cd **/*.php(.om[1]:h) # cd to directory of newest php file
cd -
cd /tmp/test/;touch {1..5} {6,7,8,12} {00..03}
cd ~www/admin
chmod g+w **/*
chmod someuser /**/*(D^u:${(j.:u:.)${(f)"<beginfold id='2'>$(</beginfold id='2'></etc/passwd<endfold id='2'>)</endfold id='2'>"}%%:*}:)
cp *.mp3(mh-4) /tmp # copy files less than 4 hours old
cp -a file1 file   # -a transfer  permissions etc of file1 to file2preserve
file **/*(D@) | fgrep broken
file **/*(D@) | fgrep broken
file=${1/#\//C:\/} # substitute / with c:/ Beginning of string
file=${1/%\//C:\/} # substitute / with c:/ End of string
file=${1/\//C:\/} # substitute / with c:/ ANYWHERE in string
filelst+=($x)
filelst[<beginfold id='1'>$((</beginfold id='1'>$#filelst+1<endfold id='1'>))</endfold id='1'>]=$x
files=(${(f)"<beginfold id='2'>$(</beginfold id='2'>egrepcmd1l<endfold id='2'>)</endfold id='2'>"} )
files=(${(f)"<beginfold id='2'>$(</beginfold id='2'>ls *$**<endfold id='2'>)</endfold id='2'>"}(.N)) # ")`
files=(**/*(ND.L0m+0m-2))
mkdir $f:h;touch $f
mv Licence\ to\ Print\ Money.pdf !#^:gs/\\ //
path=(${path:#$path_to_remove})
path=(${path:|excl})
pattern=${(b)str}
pattern=${(q)str}
print "$aa[one\"two\"three\"quotes]"
print "$bg[cyan]$fg[blue]Welcome to man zsh-lovers" >> $TTY
print <beginfold id='1'>$((</beginfold id='1'> [#8] x = 32, y = 32 <endfold id='1'>))</endfold id='1'>
print <beginfold id='1'>$((</beginfold id='1'>${${(z)${(f)"<beginfold id='2'>$(</beginfold id='2'>dirs -v<endfold id='2'>)</endfold id='2'>"}[-1]}[1]} + 1<endfold id='1'>))</endfold id='1'> # or
print <beginfold id='2'>$(</beginfold id='2'>history -n -1|sed 's/.* //'<endfold id='2'>)</endfold id='2'>
print $aa[(e)*]
print $ass_array[one]
print $x $y
print ${#path[1]}       # length of first element in path array
print ${#path}          # length of "path" array
print ${<beginfold id='2'>$(</beginfold id='2'> date <endfold id='2'>)</endfold id='2'>[2,4]} # Print words two to four of output of ’date’:
print ${<beginfold id='2'>$(</beginfold id='2'>/sbin/ifconfig tun0<endfold id='2'>)</endfold id='2'>[6]}
print ${${<beginfold id='2'>$(</beginfold id='2'> LC_ALL=C /sbin/ifconfig lo <endfold id='2'>)</endfold id='2'>[6]}#addr:}
print ${${<beginfold id='2'>$(</beginfold id='2'>LC_ALL=C /sbin/ifconfig eth0<endfold id='2'>)</endfold id='2'>[7]}:gs/addr://}
print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
print ${${(z)<beginfold id='2'>$(</beginfold id='2'>history -n -1<endfold id='2'>)</endfold id='2'>}[-1]}
print ${${(z)history[<beginfold id='1'>$((</beginfold id='1'>HISTCMD-1<endfold id='1'>))</endfold id='1'>]}[-1]}
print ${(L)s// /-}.jpg
print ${(L)s:gs/ /-/}.jpg
print ${(S)foo//${~sub}/$rep}
print ${(k)ass_array} # prints keys
print ${(v)ass_array} # prints values
print ${JUNK/%./_}                 # substitute last . for a _
print ${JUNK/.(#e)/_}              # substitute last . for a _
print ${arr//(#m)[aeiou]/${(U)MATCH}}
print ${array:t}
print ${foo%%$'\n'}                # strip out a trailing carriage return
print ${foo//$'\n'}                # strip out any carriage returns (some systems use \r)
print ${foo//${~sub}/$rep}
print ${foo: 1 + 2}
print ${foo:<beginfold id='1'>$((</beginfold id='1'> 1 + 2<endfold id='1'>))</endfold id='1'>}
print ${foo:<beginfold id='2'>$(</beginfold id='2'>echo 1 + 2<endfold id='2'>)</endfold id='2'>}
print ${foo:3}
print ${param:&}   (last substitute)
print ${somevar//[^[:alnum:]]/_}   # replace all non-alphanumerics with _ the // indicates global substitution
print ${string[(r)d?,(r)h?]}
print '\e[1;34m fred'
print (*/)#zsh_us.ps
print *(e:age 2006/10/04 2006/10/09:)
print **/*(/^F) | xargs -n1 -t rmdir #delete empty directories
print *.c(e_'[[ ! -e $REPLY:r.o ]]'_)
print -C 1 $X           # print each array element on it's own line
print -l "${(s.:.)line}"
print -l $MATCH X $match
print -l $accum
print -l *(n:t)      # order by name strip directory
print -l **/*(-@)
print -l **/*(On:t)  # recursive reverse order by name, strip directory
print -r -- $^X.$^Y
print -r -- ${(qq)m} > $nameoffile      # save it
print -rC1 /tmp/foo*(u0^@:t)
print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/)
print -rC2 -- ${1:[...]}/*(D:t)
print -rl $HOME/${(l:20::?:)~:-}*
print -rl -- ${${=mapfile[/etc/passwd]}:#*(#i)root*}
print -rl /**/*~^*/path(|/*)
print {<beginfold id='1'>$((</beginfold id='1'>##n<endfold id='1'>))</endfold id='1'>..<beginfold id='1'>$((</beginfold id='1'>##y<endfold id='1'>))</endfold id='1'>}P\ 10P | dc
print root@192.168.168.157:${PWD/test/live}v


# conditions
<beginfold id='1'>[</beginfold id='1'> a <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -f f'f'f <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -f f]'f'f] <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -t 13 <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -t 13] <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -t 13] <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -v abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -z abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc -ef abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc -ef abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc-ef -ef abc-ef <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc == abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc < abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> abc -eq abc <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> abc -eq abc <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> 1+2 -eq 1+2 <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> 1+2 -eq 1+2 <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> a = b <endfold id='1'>c</endfold id='1'> ]
<beginfold id='1'>[</beginfold id='1'> -z 1 -a 1 -eq 1 <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> 2 -eq 1 -o 1 -eq 1 <endfold id='1'>]</endfold id='1'>
<beginfold id='2'>(</beginfold id='2'> <beginfold id='1'>[</beginfold id='1'> a = b <endfold id='1'>]</endfold id='1'> <endfold id='2'>)</endfold id='2'>
<beginfold id='2'>(</beginfold id='2'><beginfold id='1'>[</beginfold id='1'> a = b <endfold id='1'>]</endfold id='1'><endfold id='2'>)</endfold id='2'>
<beginfold id='1'>[[</beginfold id='1'> a = b <endfold id='1'>c</endfold id='1'> ]]
<beginfold id='1'>[[</beginfold id='1'> x =~ a(b c|$)' '{1,}[a[.digit.]] <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> x =~ [ <endfold id='1'>] </endfold id='1'>]]
<beginfold id='1'>[[</beginfold id='1'> x =~ ([ ]) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> x =~ [ <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> x =~ ([) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> (a =~ a) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> (a =~
a) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a =~ a || a -eq 2 <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> (a =~ a) || a -eq 2 <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a<b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a <b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a< b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a < b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'>(! -d .)<endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> ! -d . <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> !(-d .) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -f a || -f b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -f a||-f b <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> ! (a -eq b) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> -d `echo .`] <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -d `echo .`]] <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a != b && ${a}a = b${b} <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'>
  1 -eq 2
<endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'>
  1
  -eq
  2
<endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -""(#i)* == $x <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -f <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -f <0-99> <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> $1 == <-> <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> ?*<0-99> = <0-99> <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -f = ?*<0-99> <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a/sa[s = dsad?*<0-9>dsa$ds <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a/sa[s = dsad?*<0-9>ds/a$ds <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> a =~ <1-2>a<->a<-2>a<2->a([!d]a?s[x[:alnum:]]|d?)p <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> -n file*(#qN) <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> ( -f foo || -f bar ) && $report = y* <endfold id='1'>]]</endfold id='1'> && print File exists.
<beginfold id='1'>[[</beginfold id='1'> $str = ${~pattern} <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> $str = ${~pattern} <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> "?" = ${(~j.|.)array} <endfold id='1'>]]</endfold id='1'>
<beginfold id='2'>(</beginfold id='2'> <beginfold id='1'>[[</beginfold id='1'> a = b <endfold id='1'>]]</endfold id='1'> <endfold id='2'>)</endfold id='2'>
<beginfold id='2'>(</beginfold id='2'><beginfold id='1'>[[</beginfold id='1'> a = b <endfold id='1'>]]</endfold id='1'><endfold id='2'>)</endfold id='2'>

<beginfold id='1'>[[</beginfold id='1'> #comm1
 #comm2
 ! #comm3
 p[1] #comm4
 == #comm5
 p[2] #comm6
 #comm7
 #comm8
<endfold id='1'>]]</endfold id='1'>

<beginfold id='1'>[[</beginfold id='1'> #comm1
 #comm2
 -f #comme3
 #comm4
 p[2] #comm5
 #comm6
 #comm7
<endfold id='1'>]]</endfold id='1'>

<beginfold id='1'>[</beginfold id='1'> a -eq 2 <endfold id='1'>]</endfold id='1'> || <beginfold id='1'>[</beginfold id='1'> a -eq 2] <endfold id='1'>]</endfold id='1'> && <beginfold id='1'>[[</beginfold id='1'> a -eq 2 <endfold id='1'>]]</endfold id='1'> || <beginfold id='1'>[[</beginfold id='1'> a != b <endfold id='1'>]]</endfold id='1'>;
<beginfold id='1'>[</beginfold id='1'> a -eq 2 <endfold id='1'>]</endfold id='1'>||<beginfold id='1'>[</beginfold id='1'> a -eq 2] <endfold id='1'>]</endfold id='1'>&&<beginfold id='1'>[[</beginfold id='1'> a -eq 2 <endfold id='1'>]]</endfold id='1'>||<beginfold id='1'>[[</beginfold id='1'> a != b <endfold id='1'>]]</endfold id='1'>;

<beginfold id='1'>((</beginfold id='1'>3+1+a+$c*(x) & 0x4342_2fd+03-08_5/23#D9a@_^8<endfold id='1'>))</endfold id='1'>
<beginfold id='1'>((</beginfold id='1'>1.3/(2-(a-4))<endfold id='1'>))</endfold id='1'>

# they are not arithmetic evaluations...
<beginfold id='2'>(</beginfold id='2'><beginfold id='2'>(</beginfold id='2'>cmd && cmd<endfold id='2'>)</endfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>
<beginfold id='2'>$(</beginfold id='2'><beginfold id='2'>(</beginfold id='2'>cmd && cmd<endfold id='2'>)</endfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>
<beginfold id='1'>((</beginfold id='1'>cmd &&
cmd<endfold id='1'></endfold id='1'><beginfold id='2'>)</beginfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>
<beginfold id='1'>$((</beginfold id='1'>cmd &&
cmd<endfold id='1'></endfold id='1'><beginfold id='2'>)</beginfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>

print <beginfold id='1'>$((</beginfold id='1'> [#_] sqrt(1e7) 0__39 1423e23 .2443 43.34 34.43e4 .d<endfold id='1'>))</endfold id='1'>

<beginfold id='3'>{</beginfold id='3'> echo
    echo
<endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> echo ; <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> echo <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'>echo<endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'>ls f<endfold id='3'>}</endfold id='3'> always <beginfold id='3'>{</beginfold id='3'>ls<endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'>echo {a}<endfold id='3'>}</endfold id='3'>
}echo
echo {a} {a/b} a{b}/c a/b{c} a/{b} a/{b}c d/{{a}}
echo {a{a{a}}}
echo {a{a{a}a}a}a
echo {a
echo a}
echo{a}
echo{a{a{a}}}
echo{a{a{a}a}a}a
echo{a
echo}

<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo a<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo a}a<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo a <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo a}a <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>

<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo a/b<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo a/b}a<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo a/b <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo a/b}a <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>

<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo >a/b<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'>echo >a/b}a<endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo >a/b <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'> <beginfold id='3'>{</beginfold id='3'> echo >a/b}a <endfold id='3'>}</endfold id='3'> <endfold id='3'>}</endfold id='3'>

<beginfold id='3'>{</beginfold id='3'>ab}c<endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'>a,b}c<endfold id='3'>}</endfold id='3'>
<beginfold id='3'>{</beginfold id='3'>ab<endfold id='3'>}</endfold id='3'>[}
<beginfold id='3'>{</beginfold id='3'>a,b<endfold id='3'>}</endfold id='3'>[}

cat >f{oo,ar}

<beginfold id='2'>(</beginfold id='2'>echo ; echo<endfold id='2'>)</endfold id='2'>
<beginfold id='2'>(</beginfold id='2'>echo
    echo<endfold id='2'>)</endfold id='2'>
<beginfold id='2'>(</beginfold id='2'>echo a<endfold id='2'>)</endfold id='2'>
test a -eq b

# functions
a() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
a  () <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
function f <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
kde.org() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
--func() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
noglob function f <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>

# variables
a=(a b c)
a='a'
a+=b
a[1]='a'
a[$i]='x'
a[<beginfold id='1'>$((</beginfold id='1'>
    2+4
<endfold id='1'>))</endfold id='1'>]='x'
a=([a]=2 `echo` -s > 'ds')
a=(#comment
value#nocomment #comment)
)
a=a cat
a=`ls` cat
a[2+3][d]=5

# control structure
for name in a b c {d,e} ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
for name; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
for name do echo ; <endfold id='4'>done</endfold id='4'>
for ((i=0;i<5;++i)) ; <beginfold id='4'>do</beginfold id='4'> echo $i ; <endfold id='4'>done</endfold id='4'>
for ((i=1;$#A[i];i++)) echo $A[$i]
for c ({1..50}) <beginfold id='3'>{</beginfold id='3'>php ./test.php; sleep 5;<endfold id='3'>}</endfold id='3'>
for count in {1..10}; <beginfold id='4'>do</beginfold id='4'> echo $count ; <endfold id='4'>done</endfold id='4'>
for f (*(.)) mv $f fixed_$f
for f (**/x) cp newx $f
for f (*.txt) <beginfold id='3'>{</beginfold id='3'> echo $f <endfold id='3'>}</endfold id='3'>
for f in **/x; <beginfold id='4'>do</beginfold id='4'>;cp newx $f; <endfold id='4'>done</endfold id='4'>
for f in */include/dbcommon.php; <beginfold id='4'>do</beginfold id='4'>;cp dbcommon.php $f; <endfold id='4'>done</endfold id='4'>
for file (*(ND-.)) IFS= read -re < $file
for i (./*.mp3)<beginfold id='3'>{</beginfold id='3'>mpg321 --w - $i > ${i:r}.wav<endfold id='3'>}</endfold id='3'>
for i in *(.); mv $i ${i:u} # `bar to `BAR
for i in **/*(D@); <beginfold id='1'>[[</beginfold id='1'> -f $i || -d $i <endfold id='1'>]]</endfold id='1'> || echo $i
for i in **/*.gif; convert $i $i:r.jpg
for i in {3,4}; sed s/flag=2/flag=$i/ fred.txt > fred$i.txt
for ip ({217..219} 225) <beginfold id='3'>{</beginfold id='3'>echo -n $ip ;ping -n 1 11.2.2.$ip| grep Received<endfold id='3'>}</endfold id='3'>
for user (${(k)f}) <beginfold id='3'>{</beginfold id='3'>print -rn $f[$user]|mailx -s "..." $user<endfold id='3'>}</endfold id='3'>
for x ( 1 2 {7..4} a b c {p..n} *.php) <beginfold id='3'>{</beginfold id='3'>echo $x<endfold id='3'>}</endfold id='3'>
select name in a ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
select name; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
<beginfold id='5'>if</beginfold id='5'> : ; then echo ; elif <beginfold id='1'>[[</beginfold id='1'> : <endfold id='1'>]]</endfold id='1'> ; then echo ; else echo ; <endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> $# -gt 0 <endfold id='1'>]</endfold id='1'>;then string=$*;else;string=<beginfold id='2'>$(</beginfold id='2'>getclip<endfold id='2'>)</endfold id='2'>;<endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> $# -gt 0 <endfold id='1'>]</endfold id='1'>;then string=$*;else;string=<beginfold id='2'>$(</beginfold id='2'>getclip<endfold id='2'>)</endfold id='2'>;<endfold id='5'>fi</endfold id='5'> # get parameter OR paste buffer
<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> (($x -lt 8) && ($y -ge 32)) || (($z -gt 32) && ($w -eq 16)) <endfold id='1'>]]</endfold id='1'> ; then print "complex combinations"; <endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> builtin cd $1 &> /dev/null ; then echo ; <endfold id='5'>fi</endfold id='5'>
<beginfold id='5'>if</beginfold id='5'> grep -iq 'matching' *.php ;then echo "Found" ;else echo "Not Found"; fim=("${(@Q)${(z)"<beginfold id='2'>$(</beginfold id='2'>cat -- $nameoffile<endfold id='2'>)</endfold id='2'>"}}") <endfold id='5'>fi</endfold id='5'>
while : || : ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
while <beginfold id='2'>(</beginfold id='2'>true<endfold id='2'>)</endfold id='2'><beginfold id='3'>{</beginfold id='3'>echo -n .;sleep 1<endfold id='3'>}</endfold id='3'>
while <beginfold id='2'>(</beginfold id='2'>true<endfold id='2'>)</endfold id='2'><beginfold id='3'>{</beginfold id='3'>echo .;sleep 1<endfold id='3'>}</endfold id='3'>
while true ;<beginfold id='4'>do</beginfold id='4'> date; sleep 5; <endfold id='4'>done</endfold id='4'> # forever
while true; <beginfold id='4'>do</beginfold id='4'> echo "infinite loop"; sleep 5; <endfold id='4'>done</endfold id='4'>
until : ; : ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
<beginfold id='6'>case</beginfold id='6'> a in a<beginfold id='7'>)</beginfold id='7'> <endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>
<beginfold id='6'>case</beginfold id='6'> a in a<beginfold id='7'>)</beginfold id='7'> echo ; <endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>
<beginfold id='6'>case</beginfold id='6'> pwd in (patt1<beginfold id='7'>)</beginfold id='7'> echo ; echo <endfold id='7'>;;</endfold id='7'> (patt*<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;&</endfold id='7'> patt?|patt<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;|</endfold id='7'>
patt<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;;</endfold id='7'> <endfold id='6'>esac</endfold id='6'>
repeat 1+2+`echo 1`+23 <beginfold id='4'>do</beginfold id='4'> echo pl; <endfold id='4'>done</endfold id='4'>
repeat 3 time sleep 3   # single command
repeat 5 ;<beginfold id='4'>do</beginfold id='4'> date; sleep 5; <endfold id='4'>done</endfold id='4'> # multi
foreach x y z ( a `a b`; c ) echo ;end
for x y ( a b bc d ds ) echo $x $y
for x y in a b c ; echo $x $y
for x y ; echo $x $y
<beginfold id='6'>case</beginfold id='6'> w { a<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;&</endfold id='7'> (b?<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'></endfold id='7'><endfold id='6'>}</endfold id='6'>
<beginfold id='6'>case</beginfold id='6'> a in
#a) echo ;;
a#<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;;</endfold id='7'>
<endfold id='6'>esac</endfold id='6'>

for name in a
 b c ;
<beginfold id='4'>do</beginfold id='4'>
echo
<endfold id='4'>done</endfold id='4'>

<beginfold id='6'>case</beginfold id='6'> a in
  a\( | b*c? <beginfold id='7'>)</beginfold id='7'> echo
  <beginfold id='2'>(</beginfold id='2'>b$c<endfold id='2'>)</endfold id='2'> # no pattern
  <endfold id='7'>;;</endfold id='7'>
  (b$c<beginfold id='7'>)</beginfold id='7'> <endfold id='7'>;;</endfold id='7'>
  # no pattern
  (b$c<beginfold id='7'>)</beginfold id='7'>
<endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>

<beginfold id='6'>case</beginfold id='6'> "$1" in
 "a"<beginfold id='7'>)</beginfold id='7'> run_a|&a<endfold id='7'>;;</endfold id='7'>
 "b"<beginfold id='7'>)</beginfold id='7'> run_b<endfold id='7'>;;</endfold id='7'>
 "c"<beginfold id='7'>)</beginfold id='7'> run_c<endfold id='7'>;;</endfold id='7'>
 *<beginfold id='7'>)</beginfold id='7'> echo "Plase choose between 'a', 'b' or 'c'" && exit 1<endfold id='7'>;;</endfold id='7'>
<endfold id='6'>esac</endfold id='6'>

<beginfold id='6'>case</beginfold id='6'> $ans in
 1|a<beginfold id='7'>)</beginfold id='7'> sdba $key<endfold id='7'>;;</endfold id='7'>
 2|f<beginfold id='7'>)</beginfold id='7'> sdbf $key<endfold id='7'>;;</endfold id='7'>
 3|i<beginfold id='7'>)</beginfold id='7'> sdbi $key<endfold id='7'>;;</endfold id='7'>
 *<beginfold id='7'>)</beginfold id='7'> echo "wrong answer $ans\n" <endfold id='7'>;;</endfold id='7'>
<endfold id='6'>esac</endfold id='6'>

<beginfold id='6'>case</beginfold id='6'> "$ans" in
 2|${prog}9<beginfold id='7'>)</beginfold id='7'> cd "<beginfold id='2'>$(</beginfold id='2'>cat /c/aam/${prog}9<endfold id='2'>)</endfold id='2'>" <endfold id='7'>;;</endfold id='7'>
 **<beginfold id='7'>)</beginfold id='7'> echo "wrong number $ans\n" <endfold id='7'>;;</endfold id='7'>
<endfold id='6'>esac</endfold id='6'>

select f in <beginfold id='2'>$(</beginfold id='2'>ls **/*.tex |egrep -i "${param}[^/]*.tex"<endfold id='2'>)</endfold id='2'>
<beginfold id='4'>do</beginfold id='4'>
 <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> "$REPLY" = q <endfold id='1'>]]</endfold id='1'>
 then
    break
 elif <beginfold id='1'>[[</beginfold id='1'> -n "$f" <endfold id='1'>]]</endfold id='1'>; then
    gvim $f
 <endfold id='5'>fi</endfold id='5'>
<endfold id='4'>done</endfold id='4'>

for d (. ./**/*(N/m-2)) <beginfold id='3'>{</beginfold id='3'>
  print -r -- $'\n'${d}:
  cd $d && <beginfold id='3'>{</beginfold id='3'>
     l=(*(Nm-2))
     <beginfold id='1'>((</beginfold id='1'>$#l<endfold id='1'>))</endfold id='1'> && ls -ltd -- $l
     cd ~-
  <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; <beginfold id='4'>do</beginfold id='4'>
    lynx -source $f >${f:t}
<endfold id='4'>done</endfold id='4'>

for f in ./**/*(-@); <beginfold id='4'>do</beginfold id='4'>
    stat +link -A l $f
    <beginfold id='2'>(</beginfold id='2'>cd $f:h & <beginfold id='1'>[[</beginfold id='1'> -e $l.gz <endfold id='1'>]]</endfold id='1'><endfold id='2'>)</endfold id='2'> & ln -sf $l.gz $f
<endfold id='4'>done</endfold id='4'>

for ((i=1; i <= $#fpath; ++i)); <beginfold id='4'>do</beginfold id='4'>
    dir=$fpath[i]
    zwc=${dir:t}.zwc
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $dir == (.|..) || $dir == (.|..)/* <endfold id='1'>]]</endfold id='1'>; then
        continue
    <endfold id='5'>fi</endfold id='5'>
    files=($dir/*(N-.))
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> -w $dir:h && -n $files <endfold id='1'>]]</endfold id='1'>; then
        files=(${${(M)files%/*/*}#/})
        <beginfold id='5'>if</beginfold id='5'> <beginfold id='2'>(</beginfold id='2'> cd $dir:h &&
            zrecompile -p -U -z $zwc $files <endfold id='2'>)</endfold id='2'>; then
        fpath[i]=$fpath[i].zwc
        <endfold id='5'>fi</endfold id='5'>
    <endfold id='5'>fi</endfold id='5'>
<endfold id='4'>done</endfold id='4'>

<beginfold id='5'>if</beginfold id='5'> ztcp pwspc 2811; then
    tcpfd=$REPLY
    handler() <beginfold id='3'>{</beginfold id='3'>
        zle -I
        local line
        <beginfold id='5'>if</beginfold id='5'> ! 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
        <endfold id='5'>fi</endfold id='5'>
        print -r - $line
    <endfold id='3'>}</endfold id='3'>
    zle -F $tcpfd handler
<endfold id='5'>fi</endfold id='5'>

while <beginfold id='1'>[[</beginfold id='1'> $? -eq 0 <endfold id='1'>]]</endfold id='1'> <beginfold id='4'>do</beginfold id='4'>
    b=($=ZPCRE_OP)
    accum+=$MATCH
    pcre_match -b -n $b[2] -- $string
<endfold id='4'>done</endfold id='4'>

# bug #380229
${str:<beginfold id='1'>$((</beginfold id='1'>${#a[1]}+1<endfold id='1'>))</endfold id='1'>}

# from http://zshwiki.org/home/examples/hardstatus
function title <beginfold id='3'>{</beginfold id='3'>
  <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $TERM == "screen" <endfold id='1'>]]</endfold id='1'>; then
    # Use these two for GNU Screen:
    print -nR $'\033k'$1$'\033'\\

    print -nR $'\033]0;'$2$'\a'
  elif <beginfold id='1'>[[</beginfold id='1'> $TERM == "xterm" || $TERM == "rxvt" <endfold id='1'>]]</endfold id='1'>; then
    # Use this one instead for XTerms:
    print -nR $'\033]0;'$*$'\a'
  <endfold id='5'>fi</endfold id='5'>
<endfold id='3'>}</endfold id='3'>

function precmd <beginfold id='3'>{</beginfold id='3'>
  title zsh "$PWD"
<endfold id='3'>}</endfold id='3'>

function preexec <beginfold id='3'>{</beginfold id='3'>
  emulate -L zsh
  local -a cmd; cmd=(${(z)1})
  title $cmd[1]:t "$cmd[2,-1]"
<endfold id='3'>}</endfold id='3'>

function ddump()<beginfold id='3'>{</beginfold id='3'>diff -w ~dump/"$1" "$1"<endfold id='3'>}</endfold id='3'>   # diff local file with new one in dump
function g{0..9} <beginfold id='3'>{</beginfold id='3'> gmark $0 $* <endfold id='3'>}</endfold id='3'>          # declaring multiple functions
function hello_function <beginfold id='3'>{</beginfold id='3'> echo "hello world" ; zle .accept-line<endfold id='3'>}</endfold id='3'>
function scd()<beginfold id='3'>{</beginfold id='3'>setopt nonomatch;e=/dev/null;cd $1(/) &> $e||cd $1*(/) &> $e||cd *$1(/) &> $e||cd *${1}*(/) &> $e||echo sorry<endfold id='3'>}</endfold id='3'>
function vx{0..9} <beginfold id='3'>{</beginfold id='3'>gvim.exe c:/aax/${0/#v/} &<endfold id='3'>}</endfold id='3'>
function {xyt,xyy} <beginfold id='3'>{</beginfold id='3'> <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> "$0" = "xyy" <endfold id='1'>]</endfold id='1'>; then echo run xyy code; else  echo run xyt code; <endfold id='5'>fi</endfold id='5'> ; echo run common code <endfold id='3'>}</endfold id='3'> #

# creating a family of functions
# generate hrefs from url
function href{,s}
<beginfold id='3'>{</beginfold id='3'>
    # href creates an HTML hyperlink from a URL
    # hrefs creates an HTML hyperlink from a URL with modified anchor text
    PROGNAME=`basename $0`
    url=`cat /dev/clipboard`
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> "$PROGNAME" = "href" <endfold id='1'>]</endfold id='1'> ; then
        href="<a href='$url'>$url"
    elif <beginfold id='1'>[</beginfold id='1'> "$PROGNAME" = "hrefs" <endfold id='1'>]</endfold id='1'> ; then
        anchortext=${${(C)url//[_-]/ }:t}
        href="<a href='$url'>$anchortext"
    <endfold id='5'>fi</endfold id='5'>
    echo -n $col
    echo $href > /dev/clipboard | more
<endfold id='3'>}</endfold id='3'>

# create vim scratch files va,vb to vz
function vx{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,t,u,v,w,x,y,z}
<beginfold id='3'>{</beginfold id='3'>
    scratchfile=${0/#v/}
    gvim.exe c:/aax/$scratchfile &
<endfold id='3'>}</endfold id='3'>

VDF()<beginfold id='3'>{</beginfold id='3'>cd *(/om[1]);F=<beginfold id='2'>$(</beginfold id='2'>echo *(.om[1])<endfold id='2'>)</endfold id='2'>;vi $F<endfold id='3'>}</endfold id='3'>
cyg()<beginfold id='3'>{</beginfold id='3'>reply=("<beginfold id='2'>$(</beginfold id='2'>cygpath -m $REPLY<endfold id='2'>)</endfold id='2'>")<endfold id='3'>}</endfold id='3'>
f  ()<beginfold id='3'>{</beginfold id='3'>for i; <beginfold id='4'>do</beginfold id='4'> echo $i;<endfold id='4'>done</endfold id='4'><endfold id='3'>}</endfold id='3'>
fg_light_red=$'%{\e[1;31m%}'
fn() <beginfold id='3'>{</beginfold id='3'> setopt localtraps; trap '' INT; sleep 3; <endfold id='3'>}</endfold id='3'>
nt() <beginfold id='3'>{</beginfold id='3'> <beginfold id='1'>[[</beginfold id='1'> $REPLY -nt $NTREF <endfold id='1'>]]</endfold id='1'> <endfold id='3'>}</endfold id='3'>
preexec()<beginfold id='3'>{</beginfold id='3'> echo using $@[1]<endfold id='3'>}</endfold id='3'>
take()<beginfold id='3'>{</beginfold id='3'><beginfold id='1'>[</beginfold id='1'> $# -eq 1 <endfold id='1'>]</endfold id='1'>  && mkdir "$1" && cd "$1"<endfold id='3'>}</endfold id='3'> # create a directory and move to it in one go

caption always "%3n %t%? (%u)%?%?: %h%?"

preexec() <beginfold id='3'>{</beginfold id='3'>
  emulate -L zsh
  local -a cmd; cmd=(${(z)1})             # Re-parse the command line

  # Construct a command that will output the desired job number.
  <beginfold id='6'>case</beginfold id='6'> $cmd[1] in
      fg<beginfold id='7'>)</beginfold id='7'>
        <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>((</beginfold id='1'> $#cmd == 1 <endfold id='1'>))</endfold id='1'>; then
          # No arguments, must find the current job
          cmd=(builtin jobs -l %+)
        else
          # Replace the command name, ignore extra args.
          cmd=(builtin jobs -l ${(Q)cmd[2]})
        <endfold id='5'>fi</endfold id='5'><endfold id='7'>;;</endfold id='7'>
       %*<beginfold id='7'>)</beginfold id='7'> cmd=(builtin jobs -l ${(Q)cmd[1]})<endfold id='7'>;;</endfold id='7'> # Same as "else" above
       exec<beginfold id='7'>)</beginfold id='7'> shift cmd<endfold id='7'>;&</endfold id='7'> # If the command is 'exec', drop that, because
          # we'd rather just see the command that is being
          # exec'd. Note the ;& to fall through.
       *<beginfold id='7'>)</beginfold id='7'>  title $cmd[1]:t "$cmd[2,-1]"    # Not resuming a job,
          return<endfold id='7'>;;</endfold id='7'>                        # so we're all done
      <endfold id='6'>esac</endfold id='6'>

  local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell

  # Run the command, read its output, and look up the jobtext.
  # Could parse $rest here, but $jobtexts (via $jt) is easier.
  $cmd >>(read num rest
          cmd=(${(z)${(e):-\$jt$num}})
          title $cmd[1]:t "$cmd[2,-1]") 2>/dev/null
<endfold id='3'>}</endfold id='3'>

function precmd() <beginfold id='3'>{</beginfold id='3'>
  title zsh "$IDENTITY:<beginfold id='2'>$(</beginfold id='2'>print -P %~<endfold id='2'>)</endfold id='2'>"
<endfold id='3'>}</endfold id='3'>

"%{^[]0;screen ^En (^Et) ^G%}"

print -nRP $'\033k%(!.#\[.)'$1$'%'$\(\(20\-${#1}\)\)$'< ..<'${${2:+${${${@[${#${@}}]##/*/}/#/ }:-}}//\"/}$'%(!.\].)\033'\\

c() <beginfold id='3'>{</beginfold id='3'> echo -E "<beginfold id='2'>$(</beginfold id='2'><$1<endfold id='2'>)</endfold id='2'>" <endfold id='3'>}</endfold id='3'>
col() <beginfold id='3'>{</beginfold id='3'> for l in ${(f)"<beginfold id='2'>$(</beginfold id='2'><$1<endfold id='2'>)</endfold id='2'>"} ; echo ${${(Az)l}[$2]} <endfold id='3'>}</endfold id='3'>
colx() <beginfold id='3'>{</beginfold id='3'> for l in ${(f)"<beginfold id='2'>$(</beginfold id='2'>eval ${(q)@[2,$]}<endfold id='2'>)</endfold id='2'>"} ; echo ${${(Az)l}[$1]} <endfold id='3'>}</endfold id='3'>

<beginfold id='1'>[[</beginfold id='1'> -r /etc/ssh/ssh_known_hosts <endfold id='1'>]]</endfold id='1'> && _global_ssh_hosts=(${${${${(f)"<beginfold id='2'>$(</beginfold id='2'></etc/ssh/ssh_known_hosts<endfold id='2'>)</endfold id='2'>"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
_ssh_hosts=(${${${${(f)"<beginfold id='2'>$(</beginfold id='2'><$HOME/.ssh/known_hosts<endfold id='2'>)</endfold id='2'>"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
_ssh_config=(<beginfold id='2'>$(</beginfold id='2'>cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p'<endfold id='2'>)</endfold id='2'>) || _ssh_config=()
: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"<beginfold id='2'>$(</beginfold id='2'></etc/hosts<endfold id='2'>)</endfold id='2'>"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()

prefix='(I:'$@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]':)'$prefix || prefix='${('$tmp'I:'$@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]':'${prefix[<beginfold id='1'>$((</beginfold id='1'>$#tmp+4<endfold id='1'>))</endfold id='1'>,-1]}
prefix='${'${j:+($j)}$prefix; suffix+=':#'${@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]//(#m)[\/\'\"]/\\$MATCH}'}'
cmd+='<'${(q)@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]}';'
C=${OPTARG//(#m)[[\/\'\"\\]/\\$MATCH}
$=p $e'"$(<'${(j:<:)${(q)@}}')"'$m

zshaddhistory() <beginfold id='3'>{</beginfold id='3'>
    print -sr -- ${1%%$'\n'}
    fc -p .zsh_local_history
<endfold id='3'>}</endfold id='3'>

TRAPINT() <beginfold id='3'>{</beginfold id='3'>
    print "Caught SIGINT, aborting."
    return <beginfold id='1'>$((</beginfold id='1'> 128 + $1 <endfold id='1'>))</endfold id='1'>
<endfold id='3'>}</endfold id='3'>

zsh_directory_name() <beginfold id='3'>{</beginfold id='3'>
    emulate -L zsh
    setopt extendedglob
    local -a match mbegin mend
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $1 = d <endfold id='1'>]]</endfold id='1'>; then
        # turn the directory into a name
        <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $2 = (#b)(/home/pws/perforce/)([^/]##)* <endfold id='1'>]]</endfold id='1'>; then
            typeset -ga reply
            reply=(p:$match[2] <beginfold id='1'>$((</beginfold id='1'> ${#match[1]} + ${#match[2]} <endfold id='1'>))</endfold id='1'> )
        else
            return 1
        <endfold id='5'>fi</endfold id='5'>
    elif <beginfold id='1'>[[</beginfold id='1'> $1 = n <endfold id='1'>]]</endfold id='1'>; then
        # turn the name into a directory
        <beginfold id='1'>[[</beginfold id='1'> $2 != (#b)p:(?*) <endfold id='1'>]]</endfold id='1'> && return 1
        typeset -ga reply
        reply=(/home/pws/perforce/$match[1])
    elif <beginfold id='1'>[[</beginfold id='1'> $1 = c <endfold id='1'>]]</endfold id='1'>; then
        # complete names
        local expl
        local -a dirs
        dirs=(/home/pws/perforce/*(/:t))
        dirs=(p:${^dirs})
        _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
        return
    else
        return 1
    <endfold id='5'>fi</endfold id='5'>
    return 0
<endfold id='3'>}</endfold id='3'>

<beginfold id='2'>(</beginfold id='2'><endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'>
    print File $1:
    cat $1
<endfold id='3'>}</endfold id='3'> =(print This be the verse)

<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $foo = (a|an)_(#b)(*) <endfold id='1'>]]</endfold id='1'>; then
    print ${foo[$mbegin[1],$mend[1]]}
<endfold id='5'>fi</endfold id='5'>

zshaddhistory() <beginfold id='3'>{</beginfold id='3'>
    emulate -L zsh
    ## uncomment if HISTORY_IGNORE
    ## should use EXTENDED_GLOB syntax
    # setopt extendedglob
    <beginfold id='1'>[[</beginfold id='1'> $1 != ${~HISTORY_IGNORE} <endfold id='1'>]]</endfold id='1'>
<endfold id='3'>}</endfold id='3'>

pick-recent-dirs-file() <beginfold id='3'>{</beginfold id='3'>
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $PWD = ~/text/writing(|/*) <endfold id='1'>]]</endfold id='1'>; then
        reply=(~/.chpwd-recent-dirs-writing)
    else
        reply=(+)
    <endfold id='5'>fi</endfold id='5'>
<endfold id='3'>}</endfold id='3'>

run-help-ssh() <beginfold id='3'>{</beginfold id='3'>
    emulate -LR zsh
    local -a args
    # Delete the "-l username" option
    zparseopts -D -E -a args l:
    # Delete other options, leaving: host command
    args=(${@:#-*})
    <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> ${#args} -lt 2 <endfold id='1'>]]</endfold id='1'>; then
        man ssh
    else
        run-help $args[2]
    <endfold id='5'>fi</endfold id='5'>
<endfold id='3'>}</endfold id='3'>

local -A zdn_top=(
    g   ~/git
    ga  ~/alternate/git
    gs  /scratch/$USER/git/:second2
    :default: /:second1
)

<beginfold id='1'>((</beginfold id='1'> $#files > 0 <endfold id='1'>))</endfold id='1'> && print -rl -- $files | \
    mailx -s "empty files" foo [at] bar.tdl

print -r -- $s[3] ${(l:4:)s[4]} ${(l:8:)s[5]} \
    ${(l:8:)s[6]} ${(l:8:)s[8]} $s[10] $f ${s[14]:+-> $s[14]}

paste <(cut -f1 file1) <(cut -f3 file2) |
    tee >(process1) >(process2) >/dev/null

ls \
> x*

sed '
 s/mvoe/move/g
 s/thier/their/g' myfile


trap '
    # code
    ' NAL

!! # previous command
!!:0 !^ !:2 !$ !#$ !#:2 !#1 !#0
!!:gs/fred/joe/       # edit previous command replace all fred by joe
!!:gs/fred/joe/       # edit previous command replace all fred by joe
!!:s/fred/joe/        # Note : sadly no regexp available with :s///
!!:s/fred/joe/        # edit previous command replace first fred by joe
!$ (last argument of previous command)
!$:h (last argument, strip one level)
!$:h:h (last argument, strip two levels)
!-2 # command before last
!1 # oldest command in your history
!42                   # Re-execute history command 42
!42:p
!?echo
!?saket?:s/somefile1/somefile2/

<beginfold id='1'>((</beginfold id='1'>$#l<endfold id='1'>))</endfold id='1'> && ls -ltd -- $l
<beginfold id='1'>((</beginfold id='1'>val2 = val1 * 2<endfold id='1'>))</endfold id='1'>
<beginfold id='2'>(</beginfold id='2'>mycmd =(myoutput)<endfold id='2'>)</endfold id='2'> &!
: *(.e{'grep -q pattern $REPLY || print -r -- $REPLY'})
: > /apache/access.log  # truncate a log file
< readme.txt
A=(1 2 5 6 7 9) # pre-populate an array
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/zsh --login
C=3 && F=<beginfold id='2'>$(</beginfold id='2'>print *(.om[1,$C])<endfold id='2'>)</endfold id='2'> && for f (<beginfold id='2'>$(</beginfold id='2'>print $F<endfold id='2'>)</endfold id='2'>)<beginfold id='3'>{</beginfold id='3'>php -l $f<endfold id='3'>}</endfold id='3'> && scp -rp <beginfold id='2'>$(</beginfold id='2'>print $F<endfold id='2'>)</endfold id='2'> user@192.168.1.1:$PWD
EDITOR='/bin/vim'
FILE=<beginfold id='2'>$(</beginfold id='2'>echo *(.om[1])<endfold id='2'>)</endfold id='2'> && ls -l $FILE && ssh 192.168.1.1 -l root "zsh -c 'ls -l $PWD/$FILE'"
FILES=( .../files/* )
IFS=$'\n\n'; print -rl -- ${(Oau)${(Oa)<beginfold id='2'>$(</beginfold id='2'>cat file;echo .<endfold id='2'>)</endfold id='2'>[1,-2]}}
IPREFIX=${PREFIX%%\=*}=
PREFIX=${PREFIX#*=}
PROMPT3="Choose File : "
PROMPT="%{$bg[cyan]%}%% "
PS3="$fg_light_red Select file : "
REPORTTIME=10 # Automatically /Report CPU usage for commands running longer than 10 seconds
RPROMPT="[%t]" <beginfold id='2'>(</beginfold id='2'>display the time<endfold id='2'>)</endfold id='2'>
X=(x1 x2)
Y=(+ -)
<beginfold id='1'>[[</beginfold id='1'> "<beginfold id='2'>$(</beginfold id='2'>< $i<endfold id='2'>)</endfold id='2'>" = *\((${(j:|:)~@})\)* <endfold id='1'>]]</endfold id='1'> && echo $i:h:t
<beginfold id='1'>[[</beginfold id='1'> $OSTYPE == (#i)LINUX*(#I) <endfold id='1'>]]</endfold id='1'>;
<beginfold id='1'>[[</beginfold id='1'> 'cell=456' =~ '(cell)=(\d+)' <endfold id='1'>]]</endfold id='1'> && echo $match[1,2] $MATCH
<beginfold id='1'>[[</beginfold id='1'> -e $L/config.php <endfold id='1'>]]</endfold id='1'> && cp -p -update $T/config.php $L
<beginfold id='1'>[[</beginfold id='1'> -n ${key[Left]} <endfold id='1'>]]</endfold id='1'> && bindkey "${key[Left]}" backward-char
<beginfold id='1'>[[</beginfold id='1'> 1 = 0 <endfold id='1'>]]</endfold id='1'> && echo eq || echo neq
<beginfold id='1'>[[</beginfold id='1'> alphabetical -regex-match ^a([^a]+)a([^a]+)a <endfold id='1'>]]</endfold id='1'> &&
^chim^&-&ney-&-&-cheree # reuse LHS
^fred^joe             # edit previous command replace fred by joe
^php^cfm          # modify previous command (good for correcting spellos)
^str1^str2^:G         # replace as many as possible
^str1^str2^:u:p       # replace str1 by str2 change case and just display
a=(**/*(.D));echo $#a  # count files in a (huge) hierarchy
a=(1 2 3 4); b=(a b); print ${a:^b}
a=(a b); b=(1 2); print -l "${a:^b}"; print -l "${${a:^b}}"
a=12345
aa[(e)*]=star
accum=()
alias '..'='cd ..'
alias -g ...='../..'
alias -g NF='*(.om[1])' # newest file
alias gcd="cd $MCD"  # double quote stops once only evaluation
alias mcd="MCD=<beginfold id='2'>$(</beginfold id='2'>pwd<endfold id='2'>)</endfold id='2'>"  # double quote stops once only evaluation
anchortext=${${(C)url//[_-]/ }:t}  # titlecase
arr=(veldt jynx grimps waqf zho buck)
array=(~/.zshenv ~/.zshrc ~/.zlogout)
autoload edit-command-line
autoload -Uz up-line-or-beginning-search
autoload colors ; colors
bindkey "^N" most-recent-file
bindkey -s "^[OS" "\^d\^c\n"
bindkey -s "^[[18~" "ls -l\n"
c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'
cd !$:h
cd !?ls
diff <(find / | sort) <(cat /var/lib/dpkg/info/*.list | sort)
dpath=${upath/#\/c\//c:/}          # convert /c/path/ to c:\path\
drive=<beginfold id='2'>$(</beginfold id='2'><beginfold id='1'>[[</beginfold id='1'> "$LOGNAME" != davidr <endfold id='1'>]]</endfold id='1'> && echo '/o' || echo '/c'<endfold id='2'>)</endfold id='2'> # trad way
drive=${${${LOGNAME:#davidr}:+/o}:-/c}                        # zsh way
egrep -i "^ *mail\(" **/*.php
eval "$1=$PWD"
eval "m=(<beginfold id='2'>$(</beginfold id='2'>cat -- $nameoffile<endfold id='2'>)</endfold id='2'>"
feh $FILES[$RANDOM%$#FILES+1]
foo="twinkle twinkle little star" sub="t*e" rep="spy"
foo=$'bar\n\nbaz\n'
foo=fred-goat-dog.jpg
fred=<beginfold id='1'>$((</beginfold id='1'>6**2 + 6<endfold id='1'>))</endfold id='1'>      # can do maths
<beginfold id='1'>((</beginfold id='1'> $# == 0 <endfold id='1'>))</endfold id='1'>;
<beginfold id='1'>[</beginfold id='1'> "$p1" = "end" <endfold id='1'>]</endfold id='1'> || <beginfold id='1'>[</beginfold id='1'> "$p1" = "-e" <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[</beginfold id='1'> $# -gt 0 <endfold id='1'>]</endfold id='1'>  # parameter cnt > 0 (arguments)
<beginfold id='1'>[</beginfold id='1'> $cnt -eq 1 <endfold id='1'>]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> "$1" == [0-9] <endfold id='1'>]]</endfold id='1'>  # if $1 is a digit
<beginfold id='1'>[[</beginfold id='1'> "$p2" == *[a-zA-Z][a-zA-Z][a-zA-Z]* <endfold id='1'>]]</endfold id='1'>  # contains at least 3 letters
<beginfold id='1'>[[</beginfold id='1'> "$pwd" == *$site2* <endfold id='1'>]]</endfold id='1'>
<beginfold id='1'>[[</beginfold id='1'> "$url" = www* <endfold id='1'>]]</endfold id='1'> # begins with www
<beginfold id='1'>[[</beginfold id='1'> -e /c/aam/z$1 <endfold id='1'>]]</endfold id='1'>  # file exists
p1 p2 p3
pcre_compile -m "\d{5}"
pcre_match -b -- $string
perl -ne 's/(<\/\w+>)/$1\n/g; print' < NF > <beginfold id='2'>$(</beginfold id='2'>print NF<endfold id='2'>)</endfold id='2'>.txt
ps -p $$ | grep $$ | awk '{print $NF}'
r oldstr=newstr
r\m <beginfold id='2'>$(</beginfold id='2'>locate nohup.out<endfold id='2'>)</endfold id='2'>
read -r line <&$fd; print -r - $line
read ans ; # read in a parameter
setopt EXTENDED_GLOB   # lots of clever stuff requires this
source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
ssh -t root@192.18.001.001 'sh -c "cd /tmp && exec zsh -l"'
ssh 192.168.1.218 -l root "zsh -c 'for i (/usr/*(/)) {ls \$i }'"
sshpass -p myppassword scp -rp * user@18.128.158.158:${PWD/staging/release}
str=aa,bb,cc;print ${(j:,:)${(qq)${(s:,:)str}}} # quotify a string
tel blenkinsop | grep -o "[[:alnum:][:graph:]]*@[[:alnum:][:graph:]]*" # filter just an email address from a text stream (not zsh)
touch {t,p}{01..99}.{php,html,c}  # generate 600 test files
touch {y,y2}.cfm
trap - INT
typeset "aa[one\"two\"three\"quotes]"=QQQ
typeset -A aa
typeset -A ass_array; ass_array=(one 1 two 2 three 3 four 4)
typeset -A convtable
typeset -i 16 y
unsetopt XTRACE VERBOSE
unsetopt localtraps
upath=${wpath//\\/\/}              # convert backslashes to forward slashes (Dos to Unix
url='www.some.com/some_strIng-HERe'
val=a:b:c
var=133;<beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> "$var" = <-> <endfold id='1'>]]</endfold id='1'> ; then echo "$var is numeric" ;<endfold id='5'>fi</endfold id='5'>
var=ddddd; <beginfold id='1'>[[</beginfold id='1'> "$var" =~ ^d+$ <endfold id='1'>]]</endfold id='1'> && echo matched || echo did not match
var=dddee; regexp="^e+$"; <beginfold id='1'>[[</beginfold id='1'> "$var" =~ $regexp <endfold id='1'>]]</endfold id='1'> && echo $regexp matched $var || echo $regexp did not match $var
vared -p "choose 1-3 : " -c ans
vared PATH
whence -vsa ${(k)commands[(I)zsh*]}  # search for zsh*
widget
wpath=${wpath//\//\\\\}            # substitute Unix / with dos \ slashes
x=$?
zmodload -F zsh/stat b:zstat
zsh -lxic : 2> >(grep "> alias 'web'")
<beginfold id='3'>{</beginfold id='3'> paste <(cut -f1 file1) <(cut -f3 file2) <endfold id='3'>}</endfold id='3'> > >(process)
