Warning, /frameworks/syntax-highlighting/autotests/folding/test.zsh.fold is written in an unsupported language. File is not indexed.

0001 # basic types:
0002 echo 'single quoted string'
0003 echo "double quoted string"
0004 echo $'string with esc\apes\x0din it'
0005 echo $"string meant to be translated"
0006 
0007 
0008 # comments:
0009 # this is a comment
0010 #this too
0011 echo this is#nt a comment
0012 dcop kate EditInterface#1 #this is
0013 grep -e "^default/linux/amd64/" |\ #this is not a comment but #this is
0014 mkdir this\ isnt\ #a\ comment
0015 mkdir this\ isnt\\\;#a\ comment
0016 mkdir this\\ #is a comment
0017 
0018 # brace expansion
0019 mv my_file.{JPG,jpg}
0020 echo f.{01..100..3} f.{#..Z} f.{\{..\}} f.{$i..$j..$p}
0021 echo f.{01..100} f.{a..Z} f.{'a'..$Z}
0022 # no brace expansion
0023 echo f.{..100} f.{a..Z..}
0024 
0025 
0026 # special characters are escaped:
0027 echo \(output\) \&\| \> \< \" \' \*
0028 
0029 
0030 # variable substitution:
0031 echo $filename.ext
0032 echo $filename_ext
0033 echo ${filename}_ext
0034 echo text${array[$subscript]}.text
0035 echo text${array["string"]}.text
0036 echo short are $_, $$, $?, ${@}, etc.
0037 echo ${variable/a/d}
0038 echo ${1:-default}
0039 echo ${10} $10a
0040 echo $! $=!
0041 
0042 
0043 # expression subst:
0044 echo <beginfold id='1'>$((</beginfold id='1'> cd << ed + 1 <endfold id='1'>))</endfold id='1'>
0045 
0046 
0047 # command subst:
0048 echo <beginfold id='2'>$(</beginfold id='2'>ls -l<endfold id='2'>)</endfold id='2'>
0049 echo `cat myfile`
0050 
0051 
0052 # file subst:
0053 echo <beginfold id='2'>$(</beginfold id='2'><$filename<endfold id='2'>)</endfold id='2'>
0054 echo <beginfold id='2'>$(</beginfold id='2'></path/to/myfile<endfold id='2'>)</endfold id='2'>
0055 
0056 # process subst:
0057 sort <(show_labels) | sed 's/a/bg' > my_file.txt 2>&1
0058 
0059 
0060 # All substitutions also work in strings:
0061 echo "subst ${in}side string"  'not $inside this ofcourse'
0062 echo "The result is <beginfold id='1'>$((</beginfold id='1'> $a + $b <endfold id='1'>))</endfold id='1'>. Thanks!"
0063 echo "Your homedir contains `ls $HOME |wc -l` files."
0064 
0065 
0066 # Escapes in strings:
0067 p="String \` with \$ escapes \" ";
0068 
0069 
0070 # keywords are black, builtins dark purple and common commands lighter purple
0071 set
0072 exit
0073 login
0074 
0075 
0076 # Other colorings:
0077 error() <beginfold id='3'>{</beginfold id='3'>
0078         cat /usr/bin/lesspipe.sh
0079         runscript >& redir.bak
0080         exec 3>&4
0081 <endfold id='3'>}</endfold id='3'>
0082 
0083 
0084 # do - done make code blocks
0085 while <beginfold id='1'>[</beginfold id='1'> $p -lt $q <endfold id='1'>]</endfold id='1'>
0086 <beginfold id='4'>do</beginfold id='4'>
0087         chown 0644 $file.$p
0088 <endfold id='4'>done</endfold id='4'>
0089 
0090 
0091 # braces as well
0092 run_prog | sort -u |
0093 <beginfold id='3'>{</beginfold id='3'>
0094         echo Header
0095         while read a b d
0096         <beginfold id='4'>do</beginfold id='4'>
0097                 echo $a/$b/$c
0098         <endfold id='4'>done</endfold id='4'>
0099         echo Footer
0100 <endfold id='3'>}</endfold id='3'>
0101 
0102 
0103 # Any constructions can be nested:
0104 echo "A long string with <beginfold id='2'>$(</beginfold id='2'>
0105         <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> $count -gt 100 <endfold id='1'>]</endfold id='1'> ; then
0106                 echo "much"
0107         else
0108                 echo "not much"
0109         <endfold id='5'>fi</endfold id='5'> <endfold id='2'>)</endfold id='2'> substitutions." ;
0110 
0111 
0112 # Even the case construct is correctly folded:
0113 test -f blaat &&
0114 <beginfold id='2'>(</beginfold id='2'>  do_something
0115         <beginfold id='6'>case</beginfold id='6'> $p in
0116                 *bak<beginfold id='7'>)</beginfold id='7'>
0117                         do_bak $p
0118                         <endfold id='7'>;;</endfold id='7'>
0119                 *<beginfold id='7'>)</beginfold id='7'>
0120                         dont_bak $p
0121                         <endfold id='7'>;;</endfold id='7'>
0122         <endfold id='6'>esac</endfold id='6'>
0123 <endfold id='2'>)</endfold id='2'> # despite the extra parentheses in the case construction.
0124 
0125 
0126 # more control flow
0127 while :;
0128   break
0129   continue
0130   return
0131 <endfold id='4'>done</endfold id='4'>
0132 
0133 
0134 # variable assignments:
0135 DIR=/dev
0136 p=`ls`
0137 LC_ALL="nl" dcop 'kate*'
0138 _VAR=val
0139 ARR=(this is an array)
0140 ARR2=([this]=too [and]="this too")
0141 usage="$0 -- version $VERSION
0142 Multiple lines of output
0143 can be possible."
0144 ANSWER=yes      # here 'yes' isn't highlighed as command
0145 
0146 
0147 # Some commands expect variable names, these are colored correctly:
0148 export PATH=/my/bin:$PATH BLAAT
0149 export A B D
0150 local p=3  x  y='\'
0151 read x y z <<< $hallo
0152 unset B
0153 declare -a VAR1 VAR2 && exit
0154 declare less a && b
0155 declare a=(1 2)
0156 getopts :h:l::d arg
0157 read #comment
0158 let a=4+4 3+a b=c+3 d+3 d*4 # * is a glob
0159 
0160 # options are recoqnized:
0161 zip -f=file.zip
0162 ./configure  --destdir=/usr
0163 make  destdir=/usr/
0164 
0165 
0166 # [[ and [ correctly need spaces to be regarded as structure,
0167 # otherwise they are patterns (currently treated as normal text)
0168 <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> "$p" == "" <endfold id='1'>]</endfold id='1'> ; then
0169         ls /usr/bin/[a-z]*
0170 elif <beginfold id='1'>[[</beginfold id='1'> $p == 0 <endfold id='1'>]]</endfold id='1'> ; then
0171         ls /usr/share/$p
0172 <endfold id='5'>fi</endfold id='5'>
0173 
0174 # Fixed:
0175 ls a[ab]*               # dont try to interprete as assignment with subscript (fixed)
0176 a[ab]
0177 a[ab]=sa
0178 
0179 
0180 # Here documents are difficult to catch:
0181 cat > myfile << __EOF__
0182 You're right, this is definitely no bash code
0183 But ls more $parameters should be expanded.
0184 __EOF__
0185 
0186 
0187 # quoted:
0188 cat << "EOF" | egrep "this" >&4   # the rest of the line is still considered bash source
0189 You're right, this is definitely no bash code
0190 But ls more $parameters should be expanded. :->
0191 EOF
0192 
0193 cat <<bla || exit
0194 bla bla
0195 bla
0196 
0197 
0198 # indented:
0199 <beginfold id='5'>if</beginfold id='5'> true
0200 then
0201         cat <<- EOF
0202                 Indented text with a $dollar or \$two
0203         EOF
0204 elif <beginfold id='1'>[</beginfold id='1'> -d $file <endfold id='1'>]</endfold id='1'>; then
0205         cat <<- "EOF"
0206                 Indented text without a $dollar
0207         EOF
0208 <endfold id='5'>fi</endfold id='5'>
0209 
0210 <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'>
0211 <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'>
0212 <beginfold id='5'>if</beginfold id='5'> ! cmd1 arg; then echo ok ; <endfold id='5'>fi</endfold id='5'>
0213 
0214 <beginfold id='6'>case</beginfold id='6'> 1 in
0215 2<beginfold id='7'>)</beginfold id='7'> echo xxx;
0216 <endfold id='7'>;;</endfold id='7'>
0217 ?<beginfold id='7'>)</beginfold id='7'> foo || yyy ; foo abc || echo abc <endfold id='7'>;;</endfold id='7'>
0218 1<beginfold id='7'>)</beginfold id='7'> echo yyy;
0219 <endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>
0220 
0221 ls #should be outside of case 1 folding block
0222 
0223 for i in `ls tests/auto/output/*.html`; <beginfold id='4'>do</beginfold id='4'>
0224     refFile=`echo $i | sed -e s,build,src, | sed -e s,output,reference, | sed -e s,.html,.ref.html,`
0225     cp -v $i $refFile
0226 <endfold id='4'>done</endfold id='4'>
0227 
0228 ## >Settings >Configure Kate >Fonts & Colors >Highlitghing Text Styles >Scripts/Bash >Option >Change colors to some distinct color
0229 ## 1- In following line the -ucode should not be colored as option
0230 
0231 pacman -Syu --needed intel-ucode grub
0232 pacman -syu --needed intel-ucode grub
0233 
0234 <beginfold id='1'>[[</beginfold id='1'> $line_name =~ \{([0-9]{1,})\}\{([0-9]{1,})\}(.*) <endfold id='1'>]]</endfold id='1'>
0235 <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'>
0236 rm /data/{hello1,hello2}/input/{bye1,$bye2}/si{a,${b},c{k,p{e,a}}}/*.non
0237 rm /data/{aa,{e,i}t{b,c} # Not closed
0238 rm /data/{aa,{e,i}t{b,c}}
0239 rm /data/{aa,{i}}
0240 rm /data{aa{bb{cc{dd}}}}
0241 rm /data{aaa`aaa}aa`aaa}a
0242 
0243 # TODO `
0244 
0245 # commands
0246 abc
0247 cp
0248 :
0249 .
0250 :#nokeyword
0251 path/cmd
0252 ec\
0253 ho
0254 2
0255 'a'c
0256 $ab
0257 ${ab}c
0258 \ a
0259 !a
0260 'a'[
0261 \ [
0262 !a[
0263 a{}d
0264 a{bc}d
0265 a{b,c}d
0266 a'b'c
0267 a$bc
0268 a${bc}d
0269 a\ b
0270 a!b
0271 
0272 # commands + params
0273 shortopt -ol -f/fd/fd -hfd/fds - -ol'a'b -f'a'/fd/fd -h'a'fd/fds
0274 longopt --long-a --long-b=value --file=* --file=file* --file=dir/file
0275 longopt --long-a'a'b --long'a'-b=value --fi'a'le=*
0276 noopt 3 3d -f -- -f --xx dir/file
0277 opt param#nocomment ab'a'cd ~a .a #comments
0278 path path/file dir/ / // 3/f a@/ 'a'/b d/'a'b a\ d/f f/f\
0279 ile
0280 path ~ ~/ ~a/ . .. ./a ../a
0281 path /path/* /path/f* /path/f@ /path/f@(|) {a/b} a{b}/c a/b{c} a/{b} a/{b}c
0282 glob ? * ?f *f f* f? **/ ~/* ~* /path/f* 'a'* 'a'f/?
0283 # ksh pattern is in conflict with extended pattern
0284 extglob @ @(*) @(f*|f??(f)) f!(+(?(@(*(f)f)f)f)f)f @'a'@(|) a@(?)
0285 echo *.*~(lex|parse).[ch](^D^l1)
0286 echo /tmp/foo*(u0^@:t) *(W,X) *(%W)
0287 subs f! f!! f!s 'a'!s \( $v {a,b} {a} {a}/d {a\,} {a,} {a,\},b} ds/{a,b}sa/s
0288 
0289 ls !?main
0290 ls <beginfold id='2'>$(</beginfold id='2'>echo NF<endfold id='2'>)</endfold id='2'>(:a)
0291 ls ${(s.:.)PATH} | grep '^...s'
0292 ls (#i)*.pmm
0293 ls (#ia1)README
0294 ls (*/)#bar
0295 ls (../)#junk2/down.txt(:a)
0296 ls (^(backup*|cache*|list*|tmp)/)##*(.)
0297 ls (_|)fred.php
0298 ls (dev*|fred*|joe*)/index*
0299 ls (x*~x[3-5])
0300 ls (xx|yy)
0301 ls *(*@)
0302 ls *(+nt)
0303 ls *(.)^php~*.c~*.txt
0304 ls *(.L-20)
0305 ls *(.L0)
0306 ls *(.Om[1,5])
0307 ls *(.^m0)
0308 ls *(.e#age 2017-10-01:00:00:00 2017-10-08:23:59:59#) /tmp
0309 ls *(.e-age 2018/09/01 2018/01/01-)
0310 ls *(.f644)
0311 ls *(.g:root:)
0312 ls *(.m-1)
0313 ls *(.mM+6)
0314 ls *(.mh+3)
0315 ls *(.mh-3)
0316 ls *(.mh3)
0317 ls *(.mw+2)
0318 ls *(.om[0,5]e-age 2017/09/01 2017/10/01-)
0319 ls *(.om[2,$]) old/
0320 ls *(.rwg:nobody:u:root:)
0321 ls *(.u:apache:)
0322 ls *(/)
0323 ls *(/^F)
0324 ls *(L0f.go-w.)
0325 ls *(Lk+100)
0326 ls *(Lm+2)
0327 ls *(R)
0328 ls *([1,10])
0329 ls *(^/,f44?,f.gu+w.,oL+rand,oe:"$cmd -x":P:echo::h)
0330 ls *(m4)
0331 ls *(mh0)
0332 ls *(mw3)
0333 ls *(${globqualifiers}N)
0334 ls *(\^'/')
0335 ls **.php
0336 ls **/*(#ia2)readme
0337 ls **/*(-@)
0338 ls **/*(.)
0339 ls **/*(.:g-w:)
0340 ls **/*(.Lm+10)
0341 ls **/*(D/e:'[[ -e $REPLY/index.php && -e $REPLY/index.html ]]':)
0342 ls **/*(u0WLk+10m0)
0343 ls **/*.(js|php|css)~(djr|libs|dompdf)/*~*/junk/*
0344 ls **/*.(js|php|css)~(libs|locallibs|test|dompdf)/*
0345 ls **/*.(php|inc)
0346 ls **/*.(php|inc)~(libs|locallibs)/*(.OL[1,5])
0347 ls **/*.txt(D.om[1,5])
0348 ls **/*~*(${~${(j/|/)fignore}})(.^*)
0349 ls **/*~*vssver.scc(.om[1,20])
0350 ls **/*~pdf/*(.m0om[1,10])
0351 ls **/^(vssver.scc|*.ini)(.om[1,20])
0352 ls **/^vssver.scc(.om[1,20])
0353 ls **/index.php~dev*(/*)##
0354 ls **/main.{php,js,css}
0355 ls *.(jpg|gif|png)(.)
0356 ls *.*(e-age 2018/06/01 now-)
0357 ls *.*(mM4)
0358 ls *.*~(lex|parse).[ch](^D^l1)
0359 ls *.*~[a-m]*(u:nobody:g:apache:.xX)
0360 ls *.c(#q:s/#%(#b)s(*).c/'S${match[1]}.C'/)
0361 ls *.c(:r)
0362 ls *.c~lex.c
0363 ls *.h~(fred|foo).h
0364 ls *.{aux,dvi,log,toc}
0365 ls *.{jpg,gif}(.N)
0366 ls *[^2].php~*template*
0367 ls *y(2|).cfm
0368 ls *y2#.cfm
0369 ls *~*.*(.)
0370 ls ./*(Om[1,-11])
0371 ls ./**/*(/od) 2> /dev/null
0372 ls ./**/*.(php|inc|js)
0373 ls ./**/*.{inc,php}
0374 ls ./*.back(#qN)
0375 ls ./{html,live}/**/*.(php|inc|js)~(**/wiki|**/dompdf)/*
0376 ls /path/**/*(.a+10e{'stat -sA u +uidr $REPLY; f[$u]="$f[$u]$REPLY"'})
0377 ls <-> <-6> <4-> <4-5> 0<-> {1..5} {2,3} {00..03} (4|5) [3-4]  [3-47-8] 0? ?2 *2
0378 ls =some_file
0379 ls DATA_[0-9](#c,4).csv
0380 ls DATA_[0-9](#c3).csv
0381 ls DATA_[0-9](#c4,).csv
0382 ls DATA_[0-9](#c4,7).csv
0383 ls PHP*/**/*.php
0384 ls [01]<->201[45]/Daily\ report*.csv(e#age 2014/10/22 now#)
0385 ls ^*.(css|php)(.)
0386 ls ^?*.*
0387 ls ^?*.*(D)
0388 ls ^?*.[^.]*(D)
0389 ls a(#c3).txt
0390 ls file<20->
0391 ls foot(fall)#.pl
0392 ls fred<76-88>.pl
0393 ls fred<76->.pl
0394 ls fred^erick*
0395 ls fred{09..13}.pl
0396 ls fred{joe,sid}.pl
0397 ls x*~(x3|x5)
0398 ls x*~^x[3,5]
0399 ls x*~x[3,5]
0400 ls x^[3,5]
0401 ls y2#.cfm y{2,}.cfm y(2|).cfm {y2,y}.cfm (y|y2).cfm y*.cfm
0402 ls {^dev*,}/index.php(.N)
0403 ls {_,}fred.php
0404 ls {p..q}<5->{1..4}.(#I)php(.N)
0405 ls ~1/*(.om[1])
0406 ls **/*.php~*junk*/*  #find all calls to mail, ignoring junk directories
0407 ls **/(*.cfm~(ctpigeonbot|env).cfm)
0408 ls **/*.{js,php,css}~(libs|temp|tmp|test)/*
0409 ls */*.php~libs/*~temp/*~test/*
0410 ls **/(*.cfm~(ctpigeonbot|env).cfm)~*((#s)|/)junk*/*(.)
0411 ls **/*.(js|php|css)~(libs|temp|test)/*
0412 ls **/*.(js|php|css)~libs/*~temp/*~test/*
0413 ls report/**/*.{inc,php}  # searching for a php variable
0414 ls *.log(Ne-age 2006/10/04:10:15 2006/10/04:12:45-)
0415 ls <beginfold id='2'>$(</beginfold id='2'>echo /c/aax/*(.om[1])<endfold id='2'>)</endfold id='2'>(+cyg) &
0416 ls *~vssver.scc(.om[1])
0417 ls /c/aax/*(.om[1]+cyg)
0418 ls ${(ps:\0:)"<beginfold id='2'>$(</beginfold id='2'>grep -lZ foobar ./*.txt(.)<endfold id='2'>)</endfold id='2'>"}
0419 ls [[[[]]x*
0420 
0421 2 - f -f
0422 !a -f
0423 'a' -f
0424 $a -f
0425 ! cmd
0426 
0427 # coproc command (#460301)
0428 coproc ls thisfiledoesntexist 2>&1
0429 coproc <beginfold id='3'>{</beginfold id='3'> ls thisfiledoesntexist; read; <endfold id='3'>}</endfold id='3'> 2>&1
0430 
0431 # redirections (prefix)
0432 <<<s cat
0433 <<<'s' cat
0434 <<<'s's cat
0435 <<<s's's cat
0436 <<<s${s}s cat
0437 <<< s${s}s cat
0438 >&2 cat
0439 <f cat
0440 2>3 cat
0441 2>&3 cat
0442 2>& 3 cat
0443 2>f cat
0444 &>f cat
0445 2>>(xless) cat
0446 2<<(xless) cat
0447 2>>(xless)cat
0448 2<<(xless)cat
0449 
0450 # redirections
0451 cat f>2
0452 cat d/f>2
0453 cat d/f >2
0454 cat d/f >& 2
0455 cat >2 d/f
0456 cat > 2
0457 cat <(echo) <(echo a) <(echo a/f) <(echo ) <(echo a ) <(echo a/f )
0458 cat 2>>(xless)
0459 cat 2<<(xless)
0460 cat 2>&1 &>f &>>f 2<&1- 2<>f 2<<heredoc
0461 bla bla
0462 heredoc
0463 <<-'h' cat
0464 bla
0465 h
0466 <<"'" cat
0467 bla
0468 '
0469 cat <<heredoc
0470 bla bla
0471 heredoc
0472 cat <<heredoc -a
0473 bla bla
0474 heredoc
0475 r=<beginfold id='2'>$(</beginfold id='2'>xxx $@ 2>&1<endfold id='2'>)</endfold id='2'>
0476 
0477 # branches
0478 cat a|cat
0479 cat a&cat
0480 cat a||cat
0481 cat a&&cat
0482 cat a;cat
0483 cat a | cat
0484 cat a & cat
0485 cat a || cat
0486 cat a && cat
0487 cat a ; cat
0488 cat a'a';cat
0489 
0490 # substitutions
0491 echo '' 'a' '\' "" "a" "\\" "$a" "a""a"'a''a' a'b'c a"b"c a$'\n'c
0492 echo a!bc a{a}b a{b,c}d a{b,{d,e}}d a\ b
0493 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
0494 echo ${a[*]} ${a[@]} ${a[${b}]} ${a:-x$z} ${a/g} ${a//f/f} ${a//f*/f*}
0495 echo ${!} ${!a} ${#a[1]} ${a:1:$b} <beginfold id='1'>$((</beginfold id='1'>++i,i--<endfold id='1'>))</endfold id='1'>
0496 echo ${a:^v} ${=a:/#%a#?*/bla} ${x#??(#i)} ${das:-{}<a.zsh}
0497 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'>"}
0498 echo ${(@)foo} ${(@)foo[1,2]} ${${(A)name}[1]} ${(AA)=name=...} ${(Q)${(z)foo}}
0499 echo ${(ps.$sep.)val} ${(ps.${sep}.)val} ${(s.$sep.)val} ${(s.)(.)val}
0500 echo ${(pr:2+3::_::$d:)var} ${(r:2+3::_::$d:)var}
0501 echo ${${:-=cat}:h}
0502 $foo:h34:a:gs/dfs/fds/:s/fds/d'd'f xyz $foo: $foo:O $foo:A
0503 3=$foo:QQQ xyz $a[3,$]:h3:t1:e
0504 echo ${${~foo}//\*/*.c}
0505 echo !$ !!:$ !* !!:* !-2:2 !:-3 !:2* !:2- !:2-3 !^ !:1 !!:1
0506 echo "$bg[blue]$fg[yellow]highlight a message"
0507 echo "$bg[red]$fg[black]${(l:42::-:)}"
0508 echo "${${(@)foo[2,4]}[2]}"
0509 echo "${(j::)${(@Oa)${(s::):-hello}}}"
0510 echo "${(j::)${(@Oa)${(s::):-hello}}}"
0511 echo "<a href='$url'>$anchortext</a>"
0512 echo <beginfold id='1'>$((</beginfold id='1'> sin(1/4.0)**2 + cos(1/4.0)**2 - 1 <endfold id='1'>))</endfold id='1'>
0513 echo $a[${RANDOM}%1000] $a[${RANDOM}%11+10]
0514 echo $convtable[158]
0515 echo ${array[0]: -7 : +  22  }  ${array[1]: num  }
0516 echo ${parameter##word} ${parameter%%word}
0517 echo $f ' # $fred'
0518 echo $f:e $f:h $f:h:h $f:r $f:t $f:t:r $file:r
0519 echo ${(C)foo:gs/-/ /:r} ${(M)0%%<->} ${(j/x/s/x/)foo} ${(l:$COLUMNS::-:)}
0520 echo ${(l:3::0:)${RANDOM}} ${(s/x/)foo%%1*} ${0##*[!0-9]}
0521 echo ${a:2:2} ${a:2} ${a[1,3]} ${d/#?/} ${d/%?/} ${d[1,-2]} ${d[2,$]}
0522 echo ${d[2,-1]} ${file##*/} ${file%.*} ${texfilepath%/*.*} *(f:u+rx,o-x:)
0523 echo *(f:u+rx:) **/*(@-^./=%p) **/*(@-^./=%p) convert_csv.php(:a)
0524 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
0525 cd ${<beginfold id='2'>$(</beginfold id='2'>!!<endfold id='2'>)</endfold id='2'>[3]:h}  # cd to 3rd in list
0526 cd ${<beginfold id='2'>$(</beginfold id='2'>locate zoo.txt<endfold id='2'>)</endfold id='2'>[1]:h}
0527 cd ${drive}/inetpub/wwwdev/www.some.co.uk/
0528 cd **/*.php(.om[1]:h) # cd to directory of newest php file
0529 cd -
0530 cd /tmp/test/;touch {1..5} {6,7,8,12} {00..03}
0531 cd ~www/admin
0532 chmod g+w **/*
0533 chmod someuser /**/*(D^u:${(j.:u:.)${(f)"<beginfold id='2'>$(</beginfold id='2'></etc/passwd<endfold id='2'>)</endfold id='2'>"}%%:*}:)
0534 cp *.mp3(mh-4) /tmp # copy files less than 4 hours old
0535 cp -a file1 file   # -a transfer  permissions etc of file1 to file2preserve
0536 file **/*(D@) | fgrep broken
0537 file **/*(D@) | fgrep broken
0538 file=${1/#\//C:\/} # substitute / with c:/ Beginning of string
0539 file=${1/%\//C:\/} # substitute / with c:/ End of string
0540 file=${1/\//C:\/} # substitute / with c:/ ANYWHERE in string
0541 filelst+=($x)
0542 filelst[<beginfold id='1'>$((</beginfold id='1'>$#filelst+1<endfold id='1'>))</endfold id='1'>]=$x
0543 files=(${(f)"<beginfold id='2'>$(</beginfold id='2'>egrepcmd1l<endfold id='2'>)</endfold id='2'>"} )
0544 files=(${(f)"<beginfold id='2'>$(</beginfold id='2'>ls *$**<endfold id='2'>)</endfold id='2'>"}(.N)) # ")`
0545 files=(**/*(ND.L0m+0m-2))
0546 mkdir $f:h;touch $f
0547 mv Licence\ to\ Print\ Money.pdf !#^:gs/\\ //
0548 path=(${path:#$path_to_remove})
0549 path=(${path:|excl})
0550 pattern=${(b)str}
0551 pattern=${(q)str}
0552 print "$aa[one\"two\"three\"quotes]"
0553 print "$bg[cyan]$fg[blue]Welcome to man zsh-lovers" >> $TTY
0554 print <beginfold id='1'>$((</beginfold id='1'> [#8] x = 32, y = 32 <endfold id='1'>))</endfold id='1'>
0555 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
0556 print <beginfold id='2'>$(</beginfold id='2'>history -n -1|sed 's/.* //'<endfold id='2'>)</endfold id='2'>
0557 print $aa[(e)*]
0558 print $ass_array[one]
0559 print $x $y
0560 print ${#path[1]}       # length of first element in path array
0561 print ${#path}          # length of "path" array
0562 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’:
0563 print ${<beginfold id='2'>$(</beginfold id='2'>/sbin/ifconfig tun0<endfold id='2'>)</endfold id='2'>[6]}
0564 print ${${<beginfold id='2'>$(</beginfold id='2'> LC_ALL=C /sbin/ifconfig lo <endfold id='2'>)</endfold id='2'>[6]}#addr:}
0565 print ${${<beginfold id='2'>$(</beginfold id='2'>LC_ALL=C /sbin/ifconfig eth0<endfold id='2'>)</endfold id='2'>[7]}:gs/addr://}
0566 print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
0567 print ${${(z)<beginfold id='2'>$(</beginfold id='2'>history -n -1<endfold id='2'>)</endfold id='2'>}[-1]}
0568 print ${${(z)history[<beginfold id='1'>$((</beginfold id='1'>HISTCMD-1<endfold id='1'>))</endfold id='1'>]}[-1]}
0569 print ${(L)s// /-}.jpg
0570 print ${(L)s:gs/ /-/}.jpg
0571 print ${(S)foo//${~sub}/$rep}
0572 print ${(k)ass_array} # prints keys
0573 print ${(v)ass_array} # prints values
0574 print ${JUNK/%./_}                 # substitute last . for a _
0575 print ${JUNK/.(#e)/_}              # substitute last . for a _
0576 print ${arr//(#m)[aeiou]/${(U)MATCH}}
0577 print ${array:t}
0578 print ${foo%%$'\n'}                # strip out a trailing carriage return
0579 print ${foo//$'\n'}                # strip out any carriage returns (some systems use \r)
0580 print ${foo//${~sub}/$rep}
0581 print ${foo: 1 + 2}
0582 print ${foo:<beginfold id='1'>$((</beginfold id='1'> 1 + 2<endfold id='1'>))</endfold id='1'>}
0583 print ${foo:<beginfold id='2'>$(</beginfold id='2'>echo 1 + 2<endfold id='2'>)</endfold id='2'>}
0584 print ${foo:3}
0585 print ${param:&}   (last substitute)
0586 print ${somevar//[^[:alnum:]]/_}   # replace all non-alphanumerics with _ the // indicates global substitution
0587 print ${string[(r)d?,(r)h?]}
0588 print '\e[1;34m fred'
0589 print (*/)#zsh_us.ps
0590 print *(e:age 2006/10/04 2006/10/09:)
0591 print **/*(/^F) | xargs -n1 -t rmdir #delete empty directories
0592 print *.c(e_'[[ ! -e $REPLY:r.o ]]'_)
0593 print -C 1 $X           # print each array element on it's own line
0594 print -l "${(s.:.)line}"
0595 print -l $MATCH X $match
0596 print -l $accum
0597 print -l *(n:t)      # order by name strip directory
0598 print -l **/*(-@)
0599 print -l **/*(On:t)  # recursive reverse order by name, strip directory
0600 print -r -- $^X.$^Y
0601 print -r -- ${(qq)m} > $nameoffile      # save it
0602 print -rC1 /tmp/foo*(u0^@:t)
0603 print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/)
0604 print -rC2 -- ${1:[...]}/*(D:t)
0605 print -rl $HOME/${(l:20::?:)~:-}*
0606 print -rl -- ${${=mapfile[/etc/passwd]}:#*(#i)root*}
0607 print -rl /**/*~^*/path(|/*)
0608 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
0609 print root@192.168.168.157:${PWD/test/live}v
0610 
0611 
0612 # conditions
0613 <beginfold id='1'>[</beginfold id='1'> a <endfold id='1'>]</endfold id='1'>
0614 <beginfold id='1'>[</beginfold id='1'> -f f'f'f <endfold id='1'>]</endfold id='1'>
0615 <beginfold id='1'>[</beginfold id='1'> -f f]'f'f] <endfold id='1'>]</endfold id='1'>
0616 <beginfold id='1'>[</beginfold id='1'> -t 13 <endfold id='1'>]</endfold id='1'>
0617 <beginfold id='1'>[</beginfold id='1'> -t 13] <endfold id='1'>]</endfold id='1'>
0618 <beginfold id='1'>[</beginfold id='1'> -t 13] <endfold id='1'>]</endfold id='1'>
0619 <beginfold id='1'>[</beginfold id='1'> -v abc <endfold id='1'>]</endfold id='1'>
0620 <beginfold id='1'>[</beginfold id='1'> -z abc <endfold id='1'>]</endfold id='1'>
0621 <beginfold id='1'>[</beginfold id='1'> abc -ef abc <endfold id='1'>]</endfold id='1'>
0622 <beginfold id='1'>[</beginfold id='1'> abc -ef abc <endfold id='1'>]</endfold id='1'>
0623 <beginfold id='1'>[</beginfold id='1'> abc-ef -ef abc-ef <endfold id='1'>]</endfold id='1'>
0624 <beginfold id='1'>[</beginfold id='1'> abc == abc <endfold id='1'>]</endfold id='1'>
0625 <beginfold id='1'>[</beginfold id='1'> abc < abc <endfold id='1'>]</endfold id='1'>
0626 <beginfold id='1'>[</beginfold id='1'> abc -eq abc <endfold id='1'>]</endfold id='1'>
0627 <beginfold id='1'>[[</beginfold id='1'> abc -eq abc <endfold id='1'>]]</endfold id='1'>
0628 <beginfold id='1'>[</beginfold id='1'> 1+2 -eq 1+2 <endfold id='1'>]</endfold id='1'>
0629 <beginfold id='1'>[[</beginfold id='1'> 1+2 -eq 1+2 <endfold id='1'>]]</endfold id='1'>
0630 <beginfold id='1'>[</beginfold id='1'> a = b <endfold id='1'>c</endfold id='1'> ]
0631 <beginfold id='1'>[</beginfold id='1'> -z 1 -a 1 -eq 1 <endfold id='1'>]</endfold id='1'>
0632 <beginfold id='1'>[</beginfold id='1'> 2 -eq 1 -o 1 -eq 1 <endfold id='1'>]</endfold id='1'>
0633 <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'>
0634 <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'>
0635 <beginfold id='1'>[[</beginfold id='1'> a = b <endfold id='1'>c</endfold id='1'> ]]
0636 <beginfold id='1'>[[</beginfold id='1'> x =~ a(b c|$)' '{1,}[a[.digit.]] <endfold id='1'>]]</endfold id='1'>
0637 <beginfold id='1'>[[</beginfold id='1'> x =~ [ <endfold id='1'>] </endfold id='1'>]]
0638 <beginfold id='1'>[[</beginfold id='1'> x =~ ([ ]) <endfold id='1'>]]</endfold id='1'>
0639 <beginfold id='1'>[[</beginfold id='1'> x =~ [ <endfold id='1'>]]</endfold id='1'>
0640 <beginfold id='1'>[[</beginfold id='1'> x =~ ([) <endfold id='1'>]]</endfold id='1'>
0641 <beginfold id='1'>[[</beginfold id='1'> (a =~ a) <endfold id='1'>]]</endfold id='1'>
0642 <beginfold id='1'>[[</beginfold id='1'> (a =~
0643 a) <endfold id='1'>]]</endfold id='1'>
0644 <beginfold id='1'>[[</beginfold id='1'> a =~ a || a -eq 2 <endfold id='1'>]]</endfold id='1'>
0645 <beginfold id='1'>[[</beginfold id='1'> (a =~ a) || a -eq 2 <endfold id='1'>]]</endfold id='1'>
0646 <beginfold id='1'>[[</beginfold id='1'> a<b <endfold id='1'>]]</endfold id='1'>
0647 <beginfold id='1'>[[</beginfold id='1'> a <b <endfold id='1'>]]</endfold id='1'>
0648 <beginfold id='1'>[[</beginfold id='1'> a< b <endfold id='1'>]]</endfold id='1'>
0649 <beginfold id='1'>[[</beginfold id='1'> a < b <endfold id='1'>]]</endfold id='1'>
0650 <beginfold id='1'>[[</beginfold id='1'>(! -d .)<endfold id='1'>]]</endfold id='1'>
0651 <beginfold id='1'>[[</beginfold id='1'> ! -d . <endfold id='1'>]]</endfold id='1'>
0652 <beginfold id='1'>[[</beginfold id='1'> !(-d .) <endfold id='1'>]]</endfold id='1'>
0653 <beginfold id='1'>[[</beginfold id='1'> -f a || -f b <endfold id='1'>]]</endfold id='1'>
0654 <beginfold id='1'>[[</beginfold id='1'> -f a||-f b <endfold id='1'>]]</endfold id='1'>
0655 <beginfold id='1'>[[</beginfold id='1'> ! (a -eq b) <endfold id='1'>]]</endfold id='1'>
0656 <beginfold id='1'>[</beginfold id='1'> -d `echo .`] <endfold id='1'>]</endfold id='1'>
0657 <beginfold id='1'>[[</beginfold id='1'> -d `echo .`]] <endfold id='1'>]]</endfold id='1'>
0658 <beginfold id='1'>[[</beginfold id='1'> a != b && ${a}a = b${b} <endfold id='1'>]]</endfold id='1'>
0659 <beginfold id='1'>[[</beginfold id='1'>
0660   1 -eq 2
0661 <endfold id='1'>]]</endfold id='1'>
0662 <beginfold id='1'>[[</beginfold id='1'>
0663   1
0664   -eq
0665   2
0666 <endfold id='1'>]]</endfold id='1'>
0667 <beginfold id='1'>[[</beginfold id='1'> -""(#i)* == $x <endfold id='1'>]]</endfold id='1'>
0668 <beginfold id='1'>[[</beginfold id='1'> <endfold id='1'>]]</endfold id='1'>
0669 <beginfold id='1'>[[</beginfold id='1'> -f <endfold id='1'>]]</endfold id='1'>
0670 <beginfold id='1'>[[</beginfold id='1'> -f <0-99> <endfold id='1'>]]</endfold id='1'>
0671 <beginfold id='1'>[[</beginfold id='1'> $1 == <-> <endfold id='1'>]]</endfold id='1'>
0672 <beginfold id='1'>[[</beginfold id='1'> ?*<0-99> = <0-99> <endfold id='1'>]]</endfold id='1'>
0673 <beginfold id='1'>[[</beginfold id='1'> -f = ?*<0-99> <endfold id='1'>]]</endfold id='1'>
0674 <beginfold id='1'>[[</beginfold id='1'> a/sa[s = dsad?*<0-9>dsa$ds <endfold id='1'>]]</endfold id='1'>
0675 <beginfold id='1'>[[</beginfold id='1'> a/sa[s = dsad?*<0-9>ds/a$ds <endfold id='1'>]]</endfold id='1'>
0676 <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'>
0677 <beginfold id='1'>[[</beginfold id='1'> -n file*(#qN) <endfold id='1'>]]</endfold id='1'>
0678 <beginfold id='1'>[[</beginfold id='1'> ( -f foo || -f bar ) && $report = y* <endfold id='1'>]]</endfold id='1'> && print File exists.
0679 <beginfold id='1'>[[</beginfold id='1'> $str = ${~pattern} <endfold id='1'>]]</endfold id='1'>
0680 <beginfold id='1'>[[</beginfold id='1'> $str = ${~pattern} <endfold id='1'>]]</endfold id='1'>
0681 <beginfold id='1'>[[</beginfold id='1'> "?" = ${(~j.|.)array} <endfold id='1'>]]</endfold id='1'>
0682 <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'>
0683 <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'>
0684 
0685 <beginfold id='1'>[[</beginfold id='1'> #comm1
0686  #comm2
0687  ! #comm3
0688  p[1] #comm4
0689  == #comm5
0690  p[2] #comm6
0691  #comm7
0692  #comm8
0693 <endfold id='1'>]]</endfold id='1'>
0694 
0695 <beginfold id='1'>[[</beginfold id='1'> #comm1
0696  #comm2
0697  -f #comme3
0698  #comm4
0699  p[2] #comm5
0700  #comm6
0701  #comm7
0702 <endfold id='1'>]]</endfold id='1'>
0703 
0704 <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'>;
0705 <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'>;
0706 
0707 <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'>
0708 <beginfold id='1'>((</beginfold id='1'>1.3/(2-(a-4))<endfold id='1'>))</endfold id='1'>
0709 
0710 # they are not arithmetic evaluations...
0711 <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'>
0712 <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'>
0713 <beginfold id='1'>((</beginfold id='1'>cmd &&
0714 cmd<endfold id='1'></endfold id='1'><beginfold id='2'>)</beginfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>
0715 <beginfold id='1'>$((</beginfold id='1'>cmd &&
0716 cmd<endfold id='1'></endfold id='1'><beginfold id='2'>)</beginfold id='2'> || cmd<endfold id='2'>)</endfold id='2'>
0717 
0718 print <beginfold id='1'>$((</beginfold id='1'> [#_] sqrt(1e7) 0__39 1423e23 .2443 43.34 34.43e4 .d<endfold id='1'>))</endfold id='1'>
0719 
0720 <beginfold id='3'>{</beginfold id='3'> echo
0721     echo
0722 <endfold id='3'>}</endfold id='3'>
0723 <beginfold id='3'>{</beginfold id='3'> echo ; <endfold id='3'>}</endfold id='3'>
0724 <beginfold id='3'>{</beginfold id='3'> echo <endfold id='3'>}</endfold id='3'>
0725 <beginfold id='3'>{</beginfold id='3'>echo<endfold id='3'>}</endfold id='3'>
0726 <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'>
0727 <beginfold id='3'>{</beginfold id='3'>echo {a}<endfold id='3'>}</endfold id='3'>
0728 }echo
0729 echo {a} {a/b} a{b}/c a/b{c} a/{b} a/{b}c d/{{a}}
0730 echo {a{a{a}}}
0731 echo {a{a{a}a}a}a
0732 echo {a
0733 echo a}
0734 echo{a}
0735 echo{a{a{a}}}
0736 echo{a{a{a}a}a}a
0737 echo{a
0738 echo}
0739 
0740 <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'>
0741 <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'>
0742 <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'>
0743 <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'>
0744 
0745 <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'>
0746 <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'>
0747 <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'>
0748 <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'>
0749 
0750 <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'>
0751 <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'>
0752 <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'>
0753 <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'>
0754 
0755 <beginfold id='3'>{</beginfold id='3'>ab}c<endfold id='3'>}</endfold id='3'>
0756 <beginfold id='3'>{</beginfold id='3'>a,b}c<endfold id='3'>}</endfold id='3'>
0757 <beginfold id='3'>{</beginfold id='3'>ab<endfold id='3'>}</endfold id='3'>[}
0758 <beginfold id='3'>{</beginfold id='3'>a,b<endfold id='3'>}</endfold id='3'>[}
0759 
0760 cat >f{oo,ar}
0761 
0762 <beginfold id='2'>(</beginfold id='2'>echo ; echo<endfold id='2'>)</endfold id='2'>
0763 <beginfold id='2'>(</beginfold id='2'>echo
0764     echo<endfold id='2'>)</endfold id='2'>
0765 <beginfold id='2'>(</beginfold id='2'>echo a<endfold id='2'>)</endfold id='2'>
0766 test a -eq b
0767 
0768 # functions
0769 a() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0770 a  () <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0771 function f <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0772 kde.org() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0773 --func() <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0774 noglob function f <beginfold id='3'>{</beginfold id='3'> echo x; <endfold id='3'>}</endfold id='3'>
0775 
0776 # variables
0777 a=(a b c)
0778 a='a'
0779 a+=b
0780 a[1]='a'
0781 a[$i]='x'
0782 a[<beginfold id='1'>$((</beginfold id='1'>
0783     2+4
0784 <endfold id='1'>))</endfold id='1'>]='x'
0785 a=([a]=2 `echo` -s > 'ds')
0786 a=(#comment
0787 value#nocomment #comment)
0788 )
0789 a=a cat
0790 a=`ls` cat
0791 a[2+3][d]=5
0792 
0793 # control structure
0794 for name in a b c {d,e} ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0795 for name; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0796 for name do echo ; <endfold id='4'>done</endfold id='4'>
0797 for ((i=0;i<5;++i)) ; <beginfold id='4'>do</beginfold id='4'> echo $i ; <endfold id='4'>done</endfold id='4'>
0798 for ((i=1;$#A[i];i++)) echo $A[$i]
0799 for c ({1..50}) <beginfold id='3'>{</beginfold id='3'>php ./test.php; sleep 5;<endfold id='3'>}</endfold id='3'>
0800 for count in {1..10}; <beginfold id='4'>do</beginfold id='4'> echo $count ; <endfold id='4'>done</endfold id='4'>
0801 for f (*(.)) mv $f fixed_$f
0802 for f (**/x) cp newx $f
0803 for f (*.txt) <beginfold id='3'>{</beginfold id='3'> echo $f <endfold id='3'>}</endfold id='3'>
0804 for f in **/x; <beginfold id='4'>do</beginfold id='4'>;cp newx $f; <endfold id='4'>done</endfold id='4'>
0805 for f in */include/dbcommon.php; <beginfold id='4'>do</beginfold id='4'>;cp dbcommon.php $f; <endfold id='4'>done</endfold id='4'>
0806 for file (*(ND-.)) IFS= read -re < $file
0807 for i (./*.mp3)<beginfold id='3'>{</beginfold id='3'>mpg321 --w - $i > ${i:r}.wav<endfold id='3'>}</endfold id='3'>
0808 for i in *(.); mv $i ${i:u} # `bar to `BAR
0809 for i in **/*(D@); <beginfold id='1'>[[</beginfold id='1'> -f $i || -d $i <endfold id='1'>]]</endfold id='1'> || echo $i
0810 for i in **/*.gif; convert $i $i:r.jpg
0811 for i in {3,4}; sed s/flag=2/flag=$i/ fred.txt > fred$i.txt
0812 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'>
0813 for user (${(k)f}) <beginfold id='3'>{</beginfold id='3'>print -rn $f[$user]|mailx -s "..." $user<endfold id='3'>}</endfold id='3'>
0814 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'>
0815 select name in a ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0816 select name; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0817 <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'>
0818 <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'>
0819 <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
0820 <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'>
0821 <beginfold id='5'>if</beginfold id='5'> builtin cd $1 &> /dev/null ; then echo ; <endfold id='5'>fi</endfold id='5'>
0822 <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'>
0823 while : || : ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0824 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'>
0825 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'>
0826 while true ;<beginfold id='4'>do</beginfold id='4'> date; sleep 5; <endfold id='4'>done</endfold id='4'> # forever
0827 while true; <beginfold id='4'>do</beginfold id='4'> echo "infinite loop"; sleep 5; <endfold id='4'>done</endfold id='4'>
0828 until : ; : ; <beginfold id='4'>do</beginfold id='4'> echo ; <endfold id='4'>done</endfold id='4'>
0829 <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'>
0830 <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'>
0831 <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'>
0832 patt<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;;</endfold id='7'> <endfold id='6'>esac</endfold id='6'>
0833 repeat 1+2+`echo 1`+23 <beginfold id='4'>do</beginfold id='4'> echo pl; <endfold id='4'>done</endfold id='4'>
0834 repeat 3 time sleep 3   # single command
0835 repeat 5 ;<beginfold id='4'>do</beginfold id='4'> date; sleep 5; <endfold id='4'>done</endfold id='4'> # multi
0836 foreach x y z ( a `a b`; c ) echo ;end
0837 for x y ( a b bc d ds ) echo $x $y
0838 for x y in a b c ; echo $x $y
0839 for x y ; echo $x $y
0840 <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'>
0841 <beginfold id='6'>case</beginfold id='6'> a in
0842 #a) echo ;;
0843 a#<beginfold id='7'>)</beginfold id='7'> echo <endfold id='7'>;;</endfold id='7'>
0844 <endfold id='6'>esac</endfold id='6'>
0845 
0846 for name in a
0847  b c ;
0848 <beginfold id='4'>do</beginfold id='4'>
0849 echo
0850 <endfold id='4'>done</endfold id='4'>
0851 
0852 <beginfold id='6'>case</beginfold id='6'> a in
0853   a\( | b*c? <beginfold id='7'>)</beginfold id='7'> echo
0854   <beginfold id='2'>(</beginfold id='2'>b$c<endfold id='2'>)</endfold id='2'> # no pattern
0855   <endfold id='7'>;;</endfold id='7'>
0856   (b$c<beginfold id='7'>)</beginfold id='7'> <endfold id='7'>;;</endfold id='7'>
0857   # no pattern
0858   (b$c<beginfold id='7'>)</beginfold id='7'>
0859 <endfold id='7'></endfold id='7'><endfold id='6'>esac</endfold id='6'>
0860 
0861 <beginfold id='6'>case</beginfold id='6'> "$1" in
0862  "a"<beginfold id='7'>)</beginfold id='7'> run_a|&a<endfold id='7'>;;</endfold id='7'>
0863  "b"<beginfold id='7'>)</beginfold id='7'> run_b<endfold id='7'>;;</endfold id='7'>
0864  "c"<beginfold id='7'>)</beginfold id='7'> run_c<endfold id='7'>;;</endfold id='7'>
0865  *<beginfold id='7'>)</beginfold id='7'> echo "Plase choose between 'a', 'b' or 'c'" && exit 1<endfold id='7'>;;</endfold id='7'>
0866 <endfold id='6'>esac</endfold id='6'>
0867 
0868 <beginfold id='6'>case</beginfold id='6'> $ans in
0869  1|a<beginfold id='7'>)</beginfold id='7'> sdba $key<endfold id='7'>;;</endfold id='7'>
0870  2|f<beginfold id='7'>)</beginfold id='7'> sdbf $key<endfold id='7'>;;</endfold id='7'>
0871  3|i<beginfold id='7'>)</beginfold id='7'> sdbi $key<endfold id='7'>;;</endfold id='7'>
0872  *<beginfold id='7'>)</beginfold id='7'> echo "wrong answer $ans\n" <endfold id='7'>;;</endfold id='7'>
0873 <endfold id='6'>esac</endfold id='6'>
0874 
0875 <beginfold id='6'>case</beginfold id='6'> "$ans" in
0876  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'>
0877  **<beginfold id='7'>)</beginfold id='7'> echo "wrong number $ans\n" <endfold id='7'>;;</endfold id='7'>
0878 <endfold id='6'>esac</endfold id='6'>
0879 
0880 select f in <beginfold id='2'>$(</beginfold id='2'>ls **/*.tex |egrep -i "${param}[^/]*.tex"<endfold id='2'>)</endfold id='2'>
0881 <beginfold id='4'>do</beginfold id='4'>
0882  <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> "$REPLY" = q <endfold id='1'>]]</endfold id='1'>
0883  then
0884     break
0885  elif <beginfold id='1'>[[</beginfold id='1'> -n "$f" <endfold id='1'>]]</endfold id='1'>; then
0886     gvim $f
0887  <endfold id='5'>fi</endfold id='5'>
0888 <endfold id='4'>done</endfold id='4'>
0889 
0890 for d (. ./**/*(N/m-2)) <beginfold id='3'>{</beginfold id='3'>
0891   print -r -- $'\n'${d}:
0892   cd $d && <beginfold id='3'>{</beginfold id='3'>
0893      l=(*(Nm-2))
0894      <beginfold id='1'>((</beginfold id='1'>$#l<endfold id='1'>))</endfold id='1'> && ls -ltd -- $l
0895      cd ~-
0896   <endfold id='3'>}</endfold id='3'>
0897 <endfold id='3'>}</endfold id='3'>
0898 
0899 for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; <beginfold id='4'>do</beginfold id='4'>
0900     lynx -source $f >${f:t}
0901 <endfold id='4'>done</endfold id='4'>
0902 
0903 for f in ./**/*(-@); <beginfold id='4'>do</beginfold id='4'>
0904     stat +link -A l $f
0905     <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
0906 <endfold id='4'>done</endfold id='4'>
0907 
0908 for ((i=1; i <= $#fpath; ++i)); <beginfold id='4'>do</beginfold id='4'>
0909     dir=$fpath[i]
0910     zwc=${dir:t}.zwc
0911     <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $dir == (.|..) || $dir == (.|..)/* <endfold id='1'>]]</endfold id='1'>; then
0912         continue
0913     <endfold id='5'>fi</endfold id='5'>
0914     files=($dir/*(N-.))
0915     <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
0916         files=(${${(M)files%/*/*}#/})
0917         <beginfold id='5'>if</beginfold id='5'> <beginfold id='2'>(</beginfold id='2'> cd $dir:h &&
0918             zrecompile -p -U -z $zwc $files <endfold id='2'>)</endfold id='2'>; then
0919         fpath[i]=$fpath[i].zwc
0920         <endfold id='5'>fi</endfold id='5'>
0921     <endfold id='5'>fi</endfold id='5'>
0922 <endfold id='4'>done</endfold id='4'>
0923 
0924 <beginfold id='5'>if</beginfold id='5'> ztcp pwspc 2811; then
0925     tcpfd=$REPLY
0926     handler() <beginfold id='3'>{</beginfold id='3'>
0927         zle -I
0928         local line
0929         <beginfold id='5'>if</beginfold id='5'> ! read -r line <&$1; then
0930             # select marks this fd if we reach EOF,
0931             # so handle this specially.
0932             print "[Read on fd $1 failed, removing.]" >&2
0933             zle -F $1
0934             return 1
0935         <endfold id='5'>fi</endfold id='5'>
0936         print -r - $line
0937     <endfold id='3'>}</endfold id='3'>
0938     zle -F $tcpfd handler
0939 <endfold id='5'>fi</endfold id='5'>
0940 
0941 while <beginfold id='1'>[[</beginfold id='1'> $? -eq 0 <endfold id='1'>]]</endfold id='1'> <beginfold id='4'>do</beginfold id='4'>
0942     b=($=ZPCRE_OP)
0943     accum+=$MATCH
0944     pcre_match -b -n $b[2] -- $string
0945 <endfold id='4'>done</endfold id='4'>
0946 
0947 # bug #380229
0948 ${str:<beginfold id='1'>$((</beginfold id='1'>${#a[1]}+1<endfold id='1'>))</endfold id='1'>}
0949 
0950 # from http://zshwiki.org/home/examples/hardstatus
0951 function title <beginfold id='3'>{</beginfold id='3'>
0952   <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $TERM == "screen" <endfold id='1'>]]</endfold id='1'>; then
0953     # Use these two for GNU Screen:
0954     print -nR $'\033k'$1$'\033'\\
0955 
0956     print -nR $'\033]0;'$2$'\a'
0957   elif <beginfold id='1'>[[</beginfold id='1'> $TERM == "xterm" || $TERM == "rxvt" <endfold id='1'>]]</endfold id='1'>; then
0958     # Use this one instead for XTerms:
0959     print -nR $'\033]0;'$*$'\a'
0960   <endfold id='5'>fi</endfold id='5'>
0961 <endfold id='3'>}</endfold id='3'>
0962 
0963 function precmd <beginfold id='3'>{</beginfold id='3'>
0964   title zsh "$PWD"
0965 <endfold id='3'>}</endfold id='3'>
0966 
0967 function preexec <beginfold id='3'>{</beginfold id='3'>
0968   emulate -L zsh
0969   local -a cmd; cmd=(${(z)1})
0970   title $cmd[1]:t "$cmd[2,-1]"
0971 <endfold id='3'>}</endfold id='3'>
0972 
0973 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
0974 function g{0..9} <beginfold id='3'>{</beginfold id='3'> gmark $0 $* <endfold id='3'>}</endfold id='3'>          # declaring multiple functions
0975 function hello_function <beginfold id='3'>{</beginfold id='3'> echo "hello world" ; zle .accept-line<endfold id='3'>}</endfold id='3'>
0976 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'>
0977 function vx{0..9} <beginfold id='3'>{</beginfold id='3'>gvim.exe c:/aax/${0/#v/} &<endfold id='3'>}</endfold id='3'>
0978 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'> #
0979 
0980 # creating a family of functions
0981 # generate hrefs from url
0982 function href{,s}
0983 <beginfold id='3'>{</beginfold id='3'>
0984     # href creates an HTML hyperlink from a URL
0985     # hrefs creates an HTML hyperlink from a URL with modified anchor text
0986     PROGNAME=`basename $0`
0987     url=`cat /dev/clipboard`
0988     <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[</beginfold id='1'> "$PROGNAME" = "href" <endfold id='1'>]</endfold id='1'> ; then
0989         href="<a href='$url'>$url"
0990     elif <beginfold id='1'>[</beginfold id='1'> "$PROGNAME" = "hrefs" <endfold id='1'>]</endfold id='1'> ; then
0991         anchortext=${${(C)url//[_-]/ }:t}
0992         href="<a href='$url'>$anchortext"
0993     <endfold id='5'>fi</endfold id='5'>
0994     echo -n $col
0995     echo $href > /dev/clipboard | more
0996 <endfold id='3'>}</endfold id='3'>
0997 
0998 # create vim scratch files va,vb to vz
0999 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}
1000 <beginfold id='3'>{</beginfold id='3'>
1001     scratchfile=${0/#v/}
1002     gvim.exe c:/aax/$scratchfile &
1003 <endfold id='3'>}</endfold id='3'>
1004 
1005 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'>
1006 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'>
1007 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'>
1008 fg_light_red=$'%{\e[1;31m%}'
1009 fn() <beginfold id='3'>{</beginfold id='3'> setopt localtraps; trap '' INT; sleep 3; <endfold id='3'>}</endfold id='3'>
1010 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'>
1011 preexec()<beginfold id='3'>{</beginfold id='3'> echo using $@[1]<endfold id='3'>}</endfold id='3'>
1012 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
1013 
1014 caption always "%3n %t%? (%u)%?%?: %h%?"
1015 
1016 preexec() <beginfold id='3'>{</beginfold id='3'>
1017   emulate -L zsh
1018   local -a cmd; cmd=(${(z)1})             # Re-parse the command line
1019 
1020   # Construct a command that will output the desired job number.
1021   <beginfold id='6'>case</beginfold id='6'> $cmd[1] in
1022       fg<beginfold id='7'>)</beginfold id='7'>
1023         <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>((</beginfold id='1'> $#cmd == 1 <endfold id='1'>))</endfold id='1'>; then
1024           # No arguments, must find the current job
1025           cmd=(builtin jobs -l %+)
1026         else
1027           # Replace the command name, ignore extra args.
1028           cmd=(builtin jobs -l ${(Q)cmd[2]})
1029         <endfold id='5'>fi</endfold id='5'><endfold id='7'>;;</endfold id='7'>
1030        %*<beginfold id='7'>)</beginfold id='7'> cmd=(builtin jobs -l ${(Q)cmd[1]})<endfold id='7'>;;</endfold id='7'> # Same as "else" above
1031        exec<beginfold id='7'>)</beginfold id='7'> shift cmd<endfold id='7'>;&</endfold id='7'> # If the command is 'exec', drop that, because
1032           # we'd rather just see the command that is being
1033           # exec'd. Note the ;& to fall through.
1034        *<beginfold id='7'>)</beginfold id='7'>  title $cmd[1]:t "$cmd[2,-1]"    # Not resuming a job,
1035           return<endfold id='7'>;;</endfold id='7'>                        # so we're all done
1036       <endfold id='6'>esac</endfold id='6'>
1037 
1038   local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
1039 
1040   # Run the command, read its output, and look up the jobtext.
1041   # Could parse $rest here, but $jobtexts (via $jt) is easier.
1042   $cmd >>(read num rest
1043           cmd=(${(z)${(e):-\$jt$num}})
1044           title $cmd[1]:t "$cmd[2,-1]") 2>/dev/null
1045 <endfold id='3'>}</endfold id='3'>
1046 
1047 function precmd() <beginfold id='3'>{</beginfold id='3'>
1048   title zsh "$IDENTITY:<beginfold id='2'>$(</beginfold id='2'>print -P %~<endfold id='2'>)</endfold id='2'>"
1049 <endfold id='3'>}</endfold id='3'>
1050 
1051 "%{^[]0;screen ^En (^Et) ^G%}"
1052 
1053 print -nRP $'\033k%(!.#\[.)'$1$'%'$\(\(20\-${#1}\)\)$'< ..<'${${2:+${${${@[${#${@}}]##/*/}/#/ }:-}}//\"/}$'%(!.\].)\033'\\
1054 
1055 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'>
1056 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'>
1057 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'>
1058 
1059 <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=()
1060 _ssh_hosts=(${${${${(f)"<beginfold id='2'>$(</beginfold id='2'><$HOME/.ssh/known_hosts<endfold id='2'>)</endfold id='2'>"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
1061 _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=()
1062 : ${(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=()
1063 
1064 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]}
1065 prefix='${'${j:+($j)}$prefix; suffix+=':#'${@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]//(#m)[\/\'\"]/\\$MATCH}'}'
1066 cmd+='<'${(q)@[<beginfold id='1'>$((</beginfold id='1'>$i+1<endfold id='1'>))</endfold id='1'>]}';'
1067 C=${OPTARG//(#m)[[\/\'\"\\]/\\$MATCH}
1068 $=p $e'"$(<'${(j:<:)${(q)@}}')"'$m
1069 
1070 zshaddhistory() <beginfold id='3'>{</beginfold id='3'>
1071     print -sr -- ${1%%$'\n'}
1072     fc -p .zsh_local_history
1073 <endfold id='3'>}</endfold id='3'>
1074 
1075 TRAPINT() <beginfold id='3'>{</beginfold id='3'>
1076     print "Caught SIGINT, aborting."
1077     return <beginfold id='1'>$((</beginfold id='1'> 128 + $1 <endfold id='1'>))</endfold id='1'>
1078 <endfold id='3'>}</endfold id='3'>
1079 
1080 zsh_directory_name() <beginfold id='3'>{</beginfold id='3'>
1081     emulate -L zsh
1082     setopt extendedglob
1083     local -a match mbegin mend
1084     <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $1 = d <endfold id='1'>]]</endfold id='1'>; then
1085         # turn the directory into a name
1086         <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
1087             typeset -ga reply
1088             reply=(p:$match[2] <beginfold id='1'>$((</beginfold id='1'> ${#match[1]} + ${#match[2]} <endfold id='1'>))</endfold id='1'> )
1089         else
1090             return 1
1091         <endfold id='5'>fi</endfold id='5'>
1092     elif <beginfold id='1'>[[</beginfold id='1'> $1 = n <endfold id='1'>]]</endfold id='1'>; then
1093         # turn the name into a directory
1094         <beginfold id='1'>[[</beginfold id='1'> $2 != (#b)p:(?*) <endfold id='1'>]]</endfold id='1'> && return 1
1095         typeset -ga reply
1096         reply=(/home/pws/perforce/$match[1])
1097     elif <beginfold id='1'>[[</beginfold id='1'> $1 = c <endfold id='1'>]]</endfold id='1'>; then
1098         # complete names
1099         local expl
1100         local -a dirs
1101         dirs=(/home/pws/perforce/*(/:t))
1102         dirs=(p:${^dirs})
1103         _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
1104         return
1105     else
1106         return 1
1107     <endfold id='5'>fi</endfold id='5'>
1108     return 0
1109 <endfold id='3'>}</endfold id='3'>
1110 
1111 <beginfold id='2'>(</beginfold id='2'><endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'>
1112     print File $1:
1113     cat $1
1114 <endfold id='3'>}</endfold id='3'> =(print This be the verse)
1115 
1116 <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $foo = (a|an)_(#b)(*) <endfold id='1'>]]</endfold id='1'>; then
1117     print ${foo[$mbegin[1],$mend[1]]}
1118 <endfold id='5'>fi</endfold id='5'>
1119 
1120 zshaddhistory() <beginfold id='3'>{</beginfold id='3'>
1121     emulate -L zsh
1122     ## uncomment if HISTORY_IGNORE
1123     ## should use EXTENDED_GLOB syntax
1124     # setopt extendedglob
1125     <beginfold id='1'>[[</beginfold id='1'> $1 != ${~HISTORY_IGNORE} <endfold id='1'>]]</endfold id='1'>
1126 <endfold id='3'>}</endfold id='3'>
1127 
1128 pick-recent-dirs-file() <beginfold id='3'>{</beginfold id='3'>
1129     <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> $PWD = ~/text/writing(|/*) <endfold id='1'>]]</endfold id='1'>; then
1130         reply=(~/.chpwd-recent-dirs-writing)
1131     else
1132         reply=(+)
1133     <endfold id='5'>fi</endfold id='5'>
1134 <endfold id='3'>}</endfold id='3'>
1135 
1136 run-help-ssh() <beginfold id='3'>{</beginfold id='3'>
1137     emulate -LR zsh
1138     local -a args
1139     # Delete the "-l username" option
1140     zparseopts -D -E -a args l:
1141     # Delete other options, leaving: host command
1142     args=(${@:#-*})
1143     <beginfold id='5'>if</beginfold id='5'> <beginfold id='1'>[[</beginfold id='1'> ${#args} -lt 2 <endfold id='1'>]]</endfold id='1'>; then
1144         man ssh
1145     else
1146         run-help $args[2]
1147     <endfold id='5'>fi</endfold id='5'>
1148 <endfold id='3'>}</endfold id='3'>
1149 
1150 local -A zdn_top=(
1151     g   ~/git
1152     ga  ~/alternate/git
1153     gs  /scratch/$USER/git/:second2
1154     :default: /:second1
1155 )
1156 
1157 <beginfold id='1'>((</beginfold id='1'> $#files > 0 <endfold id='1'>))</endfold id='1'> && print -rl -- $files | \
1158     mailx -s "empty files" foo [at] bar.tdl
1159 
1160 print -r -- $s[3] ${(l:4:)s[4]} ${(l:8:)s[5]} \
1161     ${(l:8:)s[6]} ${(l:8:)s[8]} $s[10] $f ${s[14]:+-> $s[14]}
1162 
1163 paste <(cut -f1 file1) <(cut -f3 file2) |
1164     tee >(process1) >(process2) >/dev/null
1165 
1166 ls \
1167 > x*
1168 
1169 sed '
1170  s/mvoe/move/g
1171  s/thier/their/g' myfile
1172 
1173 
1174 trap '
1175     # code
1176     ' NAL
1177 
1178 !! # previous command
1179 !!:0 !^ !:2 !$ !#$ !#:2 !#1 !#0
1180 !!:gs/fred/joe/       # edit previous command replace all fred by joe
1181 !!:gs/fred/joe/       # edit previous command replace all fred by joe
1182 !!:s/fred/joe/        # Note : sadly no regexp available with :s///
1183 !!:s/fred/joe/        # edit previous command replace first fred by joe
1184 !$ (last argument of previous command)
1185 !$:h (last argument, strip one level)
1186 !$:h:h (last argument, strip two levels)
1187 !-2 # command before last
1188 !1 # oldest command in your history
1189 !42                   # Re-execute history command 42
1190 !42:p
1191 !?echo
1192 !?saket?:s/somefile1/somefile2/
1193 
1194 <beginfold id='1'>((</beginfold id='1'>$#l<endfold id='1'>))</endfold id='1'> && ls -ltd -- $l
1195 <beginfold id='1'>((</beginfold id='1'>val2 = val1 * 2<endfold id='1'>))</endfold id='1'>
1196 <beginfold id='2'>(</beginfold id='2'>mycmd =(myoutput)<endfold id='2'>)</endfold id='2'> &!
1197 : *(.e{'grep -q pattern $REPLY || print -r -- $REPLY'})
1198 : > /apache/access.log  # truncate a log file
1199 < readme.txt
1200 A=(1 2 5 6 7 9) # pre-populate an array
1201 C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/zsh --login
1202 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
1203 EDITOR='/bin/vim'
1204 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'"
1205 FILES=( .../files/* )
1206 IFS=$'\n\n'; print -rl -- ${(Oau)${(Oa)<beginfold id='2'>$(</beginfold id='2'>cat file;echo .<endfold id='2'>)</endfold id='2'>[1,-2]}}
1207 IPREFIX=${PREFIX%%\=*}=
1208 PREFIX=${PREFIX#*=}
1209 PROMPT3="Choose File : "
1210 PROMPT="%{$bg[cyan]%}%% "
1211 PS3="$fg_light_red Select file : "
1212 REPORTTIME=10 # Automatically /Report CPU usage for commands running longer than 10 seconds
1213 RPROMPT="[%t]" <beginfold id='2'>(</beginfold id='2'>display the time<endfold id='2'>)</endfold id='2'>
1214 X=(x1 x2)
1215 Y=(+ -)
1216 <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
1217 <beginfold id='1'>[[</beginfold id='1'> $OSTYPE == (#i)LINUX*(#I) <endfold id='1'>]]</endfold id='1'>;
1218 <beginfold id='1'>[[</beginfold id='1'> 'cell=456' =~ '(cell)=(\d+)' <endfold id='1'>]]</endfold id='1'> && echo $match[1,2] $MATCH
1219 <beginfold id='1'>[[</beginfold id='1'> -e $L/config.php <endfold id='1'>]]</endfold id='1'> && cp -p -update $T/config.php $L
1220 <beginfold id='1'>[[</beginfold id='1'> -n ${key[Left]} <endfold id='1'>]]</endfold id='1'> && bindkey "${key[Left]}" backward-char
1221 <beginfold id='1'>[[</beginfold id='1'> 1 = 0 <endfold id='1'>]]</endfold id='1'> && echo eq || echo neq
1222 <beginfold id='1'>[[</beginfold id='1'> alphabetical -regex-match ^a([^a]+)a([^a]+)a <endfold id='1'>]]</endfold id='1'> &&
1223 ^chim^&-&ney-&-&-cheree # reuse LHS
1224 ^fred^joe             # edit previous command replace fred by joe
1225 ^php^cfm          # modify previous command (good for correcting spellos)
1226 ^str1^str2^:G         # replace as many as possible
1227 ^str1^str2^:u:p       # replace str1 by str2 change case and just display
1228 a=(**/*(.D));echo $#a  # count files in a (huge) hierarchy
1229 a=(1 2 3 4); b=(a b); print ${a:^b}
1230 a=(a b); b=(1 2); print -l "${a:^b}"; print -l "${${a:^b}}"
1231 a=12345
1232 aa[(e)*]=star
1233 accum=()
1234 alias '..'='cd ..'
1235 alias -g ...='../..'
1236 alias -g NF='*(.om[1])' # newest file
1237 alias gcd="cd $MCD"  # double quote stops once only evaluation
1238 alias mcd="MCD=<beginfold id='2'>$(</beginfold id='2'>pwd<endfold id='2'>)</endfold id='2'>"  # double quote stops once only evaluation
1239 anchortext=${${(C)url//[_-]/ }:t}  # titlecase
1240 arr=(veldt jynx grimps waqf zho buck)
1241 array=(~/.zshenv ~/.zshrc ~/.zlogout)
1242 autoload edit-command-line
1243 autoload -Uz up-line-or-beginning-search
1244 autoload colors ; colors
1245 bindkey "^N" most-recent-file
1246 bindkey -s "^[OS" "\^d\^c\n"
1247 bindkey -s "^[[18~" "ls -l\n"
1248 c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'
1249 cd !$:h
1250 cd !?ls
1251 diff <(find / | sort) <(cat /var/lib/dpkg/info/*.list | sort)
1252 dpath=${upath/#\/c\//c:/}          # convert /c/path/ to c:\path\
1253 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
1254 drive=${${${LOGNAME:#davidr}:+/o}:-/c}                        # zsh way
1255 egrep -i "^ *mail\(" **/*.php
1256 eval "$1=$PWD"
1257 eval "m=(<beginfold id='2'>$(</beginfold id='2'>cat -- $nameoffile<endfold id='2'>)</endfold id='2'>"
1258 feh $FILES[$RANDOM%$#FILES+1]
1259 foo="twinkle twinkle little star" sub="t*e" rep="spy"
1260 foo=$'bar\n\nbaz\n'
1261 foo=fred-goat-dog.jpg
1262 fred=<beginfold id='1'>$((</beginfold id='1'>6**2 + 6<endfold id='1'>))</endfold id='1'>      # can do maths
1263 <beginfold id='1'>((</beginfold id='1'> $# == 0 <endfold id='1'>))</endfold id='1'>;
1264 <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'>
1265 <beginfold id='1'>[</beginfold id='1'> $# -gt 0 <endfold id='1'>]</endfold id='1'>  # parameter cnt > 0 (arguments)
1266 <beginfold id='1'>[</beginfold id='1'> $cnt -eq 1 <endfold id='1'>]</endfold id='1'>
1267 <beginfold id='1'>[[</beginfold id='1'> "$1" == [0-9] <endfold id='1'>]]</endfold id='1'>  # if $1 is a digit
1268 <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
1269 <beginfold id='1'>[[</beginfold id='1'> "$pwd" == *$site2* <endfold id='1'>]]</endfold id='1'>
1270 <beginfold id='1'>[[</beginfold id='1'> "$url" = www* <endfold id='1'>]]</endfold id='1'> # begins with www
1271 <beginfold id='1'>[[</beginfold id='1'> -e /c/aam/z$1 <endfold id='1'>]]</endfold id='1'>  # file exists
1272 p1 p2 p3
1273 pcre_compile -m "\d{5}"
1274 pcre_match -b -- $string
1275 perl -ne 's/(<\/\w+>)/$1\n/g; print' < NF > <beginfold id='2'>$(</beginfold id='2'>print NF<endfold id='2'>)</endfold id='2'>.txt
1276 ps -p $$ | grep $$ | awk '{print $NF}'
1277 r oldstr=newstr
1278 r\m <beginfold id='2'>$(</beginfold id='2'>locate nohup.out<endfold id='2'>)</endfold id='2'>
1279 read -r line <&$fd; print -r - $line
1280 read ans ; # read in a parameter
1281 setopt EXTENDED_GLOB   # lots of clever stuff requires this
1282 source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
1283 ssh -t root@192.18.001.001 'sh -c "cd /tmp && exec zsh -l"'
1284 ssh 192.168.1.218 -l root "zsh -c 'for i (/usr/*(/)) {ls \$i }'"
1285 sshpass -p myppassword scp -rp * user@18.128.158.158:${PWD/staging/release}
1286 str=aa,bb,cc;print ${(j:,:)${(qq)${(s:,:)str}}} # quotify a string
1287 tel blenkinsop | grep -o "[[:alnum:][:graph:]]*@[[:alnum:][:graph:]]*" # filter just an email address from a text stream (not zsh)
1288 touch {t,p}{01..99}.{php,html,c}  # generate 600 test files
1289 touch {y,y2}.cfm
1290 trap - INT
1291 typeset "aa[one\"two\"three\"quotes]"=QQQ
1292 typeset -A aa
1293 typeset -A ass_array; ass_array=(one 1 two 2 three 3 four 4)
1294 typeset -A convtable
1295 typeset -i 16 y
1296 unsetopt XTRACE VERBOSE
1297 unsetopt localtraps
1298 upath=${wpath//\\/\/}              # convert backslashes to forward slashes (Dos to Unix
1299 url='www.some.com/some_strIng-HERe'
1300 val=a:b:c
1301 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'>
1302 var=ddddd; <beginfold id='1'>[[</beginfold id='1'> "$var" =~ ^d+$ <endfold id='1'>]]</endfold id='1'> && echo matched || echo did not match
1303 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
1304 vared -p "choose 1-3 : " -c ans
1305 vared PATH
1306 whence -vsa ${(k)commands[(I)zsh*]}  # search for zsh*
1307 widget
1308 wpath=${wpath//\//\\\\}            # substitute Unix / with dos \ slashes
1309 x=$?
1310 zmodload -F zsh/stat b:zstat
1311 zsh -lxic : 2> >(grep "> alias 'web'")
1312 <beginfold id='3'>{</beginfold id='3'> paste <(cut -f1 file1) <(cut -f3 file2) <endfold id='3'>}</endfold id='3'> > >(process)