1# basic types:
2echo 'single quoted string'
3echo "double quoted string"
4echo $'string with esc\apes\x0din it'
5echo $"string meant to be translated"
6
7
8# comments:
9# this is a comment
10#this too
11echo this is#nt a comment
12dcop kate EditInterface#1 #this is
13grep -e "^default/linux/amd64/" |\ #this is not a comment but #this is
14mkdir this\ isnt\ #a\ comment
15mkdir this\ isnt\\\;#a\ comment
16mkdir this\\ #is a comment
17
18# brace expansion
19mv my_file.{JPG,jpg}
20echo f.{01..100..3} f.{#..Z} f.{\{..\}} f.{$i..$j..$p}
21echo f.{01..100} f.{a..Z} f.{'a'..$Z}
22# no brace expansion
23echo f.{..100} f.{a..Z..}
24
25
26# special characters are escaped:
27echo \(output\) \&\| \> \< \" \' \*
28
29
30# variable substitution:
31echo $filename.ext
32echo $filename_ext
33echo ${filename}_ext
34echo text${array[$subscript]}.text
35echo text${array["string"]}.text
36echo short are $_, $$, $?, ${@}, etc.
37echo ${variable/a/d}
38echo ${1:-default}
39echo ${10} $10a
40echo $! $=!
41
42
43# expression subst:
44echo $(( cd << ed + 1 ))
45
46
47# command subst:
48echo $(ls -l)
49echo `cat myfile`
50
51
52# file subst:
53echo $(<$filename)
54echo $(</path/to/myfile)
55
56# process subst:
57sort <(show_labels) | sed 's/a/bg' > my_file.txt 2>&1
58
59
60# All substitutions also work in strings:
61echo "subst ${in}side string"  'not $inside this ofcourse'
62echo "The result is $(( $a + $b )). Thanks!"
63echo "Your homedir contains `ls $HOME |wc -l` files."
64
65
66# Escapes in strings:
67p="String \` with \$ escapes \" ";
68
69
70# keywords are black, builtins dark purple and common commands lighter purple
71set
72exit
73login
74
75
76# Other colorings:
77error() {
78	cat /usr/bin/lesspipe.sh
79	runscript >& redir.bak
80	exec 3>&4
81}
82
83
84# do - done make code blocks
85while [ $p -lt $q ]
86do
87	chown 0644 $file.$p
88done
89
90
91# braces as well
92run_prog | sort -u |
93{
94	echo Header
95	while read a b d
96	do
97		echo $a/$b/$c
98	done
99	echo Footer
100}
101
102
103# Any constructions can be nested:
104echo "A long string with $(
105	if [ $count -gt 100 ] ; then
106		echo "much"
107	else
108		echo "not much"
109	fi ) substitutions." ;
110
111
112# Even the case construct is correctly folded:
113test -f blaat &&
114(	do_something
115	case $p in
116		*bak)
117			do_bak $p
118			;;
119		*)
120			dont_bak $p
121			;;
122	esac
123) # despite the extra parentheses in the case construction.
124
125
126# more control flow
127while :;
128  break
129  continue
130  return
131done
132
133
134# variable assignments:
135DIR=/dev
136p=`ls`
137LC_ALL="nl" dcop 'kate*'
138_VAR=val
139ARR=(this is an array)
140ARR2=([this]=too [and]="this too")
141usage="$0 -- version $VERSION
142Multiple lines of output
143can be possible."
144ANSWER=yes	# here 'yes' isn't highlighed as command
145
146
147# Some commands expect variable names, these are colored correctly:
148export PATH=/my/bin:$PATH BLAAT
149export A B D
150local p=3  x  y='\'
151read x y z <<< $hallo
152unset B
153declare -a VAR1 VAR2 && exit
154declare less a && b
155declare a=(1 2)
156getopts :h:l::d arg
157read #comment
158let a=4+4 3+a b=c+3 d+3 d*4 # * is a glob
159
160# options are recoqnized:
161zip -f=file.zip
162./configure  --destdir=/usr
163make  destdir=/usr/
164
165
166# [[ and [ correctly need spaces to be regarded as structure,
167# otherwise they are patterns (currently treated as normal text)
168if [ "$p" == "" ] ; then
169	ls /usr/bin/[a-z]*
170elif [[ $p == 0 ]] ; then
171	ls /usr/share/$p
172fi
173
174# Fixed:
175ls a[ab]*		# dont try to interprete as assignment with subscript (fixed)
176a[ab]
177a[ab]=sa
178
179
180# Here documents are difficult to catch:
181cat > myfile << __EOF__
182You're right, this is definitely no bash code
183But ls more $parameters should be expanded.
184__EOF__
185
186
187# quoted:
188cat << "EOF" | egrep "this" >&4   # the rest of the line is still considered bash source
189You're right, this is definitely no bash code
190But ls more $parameters should be expanded. :->
191EOF
192
193cat <<bla || exit
194bla bla
195bla
196
197
198# indented:
199if true
200then
201	cat <<- EOF
202		Indented text with a $dollar or \$two
203	EOF
204elif [ -d $file ]; then
205	cat <<- "EOF"
206		Indented text without a $dollar
207	EOF
208fi
209
210if ! { cmd1 && cmd2 ; }; then echo ok ; fi
211if ! {cmd1 && cmd2}; then echo ok ; fi
212if ! cmd1 arg; then echo ok ; fi
213
214case 1 in
2152) echo xxx;
216;;
217?) foo || yyy ; foo abc || echo abc ;;
2181) echo yyy;
219esac
220
221ls #should be outside of case 1 folding block
222
223for i in `ls tests/auto/output/*.html`; do
224    refFile=`echo $i | sed -e s,build,src, | sed -e s,output,reference, | sed -e s,.html,.ref.html,`
225    cp -v $i $refFile
226done
227
228## >Settings >Configure Kate >Fonts & Colors >Highlitghing Text Styles >Scripts/Bash >Option >Change colors to some distinct color
229## 1- In following line the -ucode should not be colored as option
230
231pacman -Syu --needed intel-ucode grub
232pacman -syu --needed intel-ucode grub
233
234[[ $line_name =~ \{([0-9]{1,})\}\{([0-9]{1,})\}(.*) ]]
235[[ $name =~ (.*)_(S[0-9]{2})(E[0-9]{2,3}[a-z]{0,1})_(.*) ]]
236rm /data/{hello1,hello2}/input/{bye1,$bye2}/si{a,${b},c{k,p{e,a}}}/*.non
237rm /data/{aa,{e,i}t{b,c} # Not closed
238rm /data/{aa,{e,i}t{b,c}}
239rm /data/{aa,{i}}
240rm /data{aa{bb{cc{dd}}}}
241rm /data{aaa`aaa}aa`aaa}a
242
243# TODO `
244
245# commands
246abc
247cp
248:
249.
250:#nokeyword
251path/cmd
252ec\
253ho
2542
255'a'c
256$ab
257${ab}c
258\ a
259!a
260'a'[
261\ [
262!a[
263a{}d
264a{bc}d
265a{b,c}d
266a'b'c
267a$bc
268a${bc}d
269a\ b
270a!b
271
272# commands + params
273shortopt -ol -f/fd/fd -hfd/fds - -ol'a'b -f'a'/fd/fd -h'a'fd/fds
274longopt --long-a --long-b=value --file=* --file=file* --file=dir/file
275longopt --long-a'a'b --long'a'-b=value --fi'a'le=*
276noopt 3 3d -f -- -f --xx dir/file
277opt param#nocomment ab'a'cd ~a .a #comments
278path path/file dir/ / // 3/f a@/ 'a'/b d/'a'b a\ d/f f/f\
279ile
280path ~ ~/ ~a/ . .. ./a ../a
281path /path/* /path/f* /path/f@ /path/f@(|) {a/b} a{b}/c a/b{c} a/{b} a/{b}c
282glob ? * ?f *f f* f? **/ ~/* ~* /path/f* 'a'* 'a'f/?
283# ksh pattern is in conflict with extended pattern
284extglob @ @(*) @(f*|f??(f)) f!(+(?(@(*(f)f)f)f)f)f @'a'@(|) a@(?)
285echo *.*~(lex|parse).[ch](^D^l1)
286echo /tmp/foo*(u0^@:t) *(W,X) *(%W)
287subs f! f!! f!s 'a'!s \( $v {a,b} {a} {a}/d {a\,} {a,} {a,\},b} ds/{a,b}sa/s
288
289ls !?main
290ls $(echo NF)(:a)
291ls ${(s.:.)PATH} | grep '^...s'
292ls (#i)*.pmm
293ls (#ia1)README
294ls (*/)#bar
295ls (../)#junk2/down.txt(:a)
296ls (^(backup*|cache*|list*|tmp)/)##*(.)
297ls (_|)fred.php
298ls (dev*|fred*|joe*)/index*
299ls (x*~x[3-5])
300ls (xx|yy)
301ls *(*@)
302ls *(+nt)
303ls *(.)^php~*.c~*.txt
304ls *(.L-20)
305ls *(.L0)
306ls *(.Om[1,5])
307ls *(.^m0)
308ls *(.e#age 2017-10-01:00:00:00 2017-10-08:23:59:59#) /tmp
309ls *(.e-age 2018/09/01 2018/01/01-)
310ls *(.f644)
311ls *(.g:root:)
312ls *(.m-1)
313ls *(.mM+6)
314ls *(.mh+3)
315ls *(.mh-3)
316ls *(.mh3)
317ls *(.mw+2)
318ls *(.om[0,5]e-age 2017/09/01 2017/10/01-)
319ls *(.om[2,$]) old/
320ls *(.rwg:nobody:u:root:)
321ls *(.u:apache:)
322ls *(/)
323ls *(/^F)
324ls *(L0f.go-w.)
325ls *(Lk+100)
326ls *(Lm+2)
327ls *(R)
328ls *([1,10])
329ls *(^/,f44?,f.gu+w.,oL+rand,oe:"$cmd -x":P:echo::h)
330ls *(m4)
331ls *(mh0)
332ls *(mw3)
333ls **.php
334ls **/*(#ia2)readme
335ls **/*(-@)
336ls **/*(.)
337ls **/*(.:g-w:)
338ls **/*(.Lm+10)
339ls **/*(D/e:'[[ -e $REPLY/index.php && -e $REPLY/index.html ]]':)
340ls **/*(u0WLk+10m0)
341ls **/*.(js|php|css)~(djr|libs|dompdf)/*~*/junk/*
342ls **/*.(js|php|css)~(libs|locallibs|test|dompdf)/*
343ls **/*.(php|inc)
344ls **/*.(php|inc)~(libs|locallibs)/*(.OL[1,5])
345ls **/*.txt(D.om[1,5])
346ls **/*~*(${~${(j/|/)fignore}})(.^*)
347ls **/*~*vssver.scc(.om[1,20])
348ls **/*~pdf/*(.m0om[1,10])
349ls **/^(vssver.scc|*.ini)(.om[1,20])
350ls **/^vssver.scc(.om[1,20])
351ls **/index.php~dev*(/*)##
352ls **/main.{php,js,css}
353ls *.(jpg|gif|png)(.)
354ls *.*(e-age 2018/06/01 now-)
355ls *.*(mM4)
356ls *.*~(lex|parse).[ch](^D^l1)
357ls *.*~[a-m]*(u:nobody:g:apache:.xX)
358ls *.c(#q:s/#%(#b)s(*).c/'S${match[1]}.C'/)
359ls *.c(:r)
360ls *.c~lex.c
361ls *.h~(fred|foo).h
362ls *.{aux,dvi,log,toc}
363ls *.{jpg,gif}(.N)
364ls *[^2].php~*template*
365ls *y(2|).cfm
366ls *y2#.cfm
367ls *~*.*(.)
368ls ./*(Om[1,-11])
369ls ./**/*(/od) 2> /dev/null
370ls ./**/*.(php|inc|js)
371ls ./**/*.{inc,php}
372ls ./*.back(#qN)
373ls ./{html,live}/**/*.(php|inc|js)~(**/wiki|**/dompdf)/*
374ls /path/**/*(.a+10e{'stat -sA u +uidr $REPLY; f[$u]="$f[$u]$REPLY"'})
375ls <-> <-6> <4-> <4-5> 0<-> {1..5} {2,3} {00..03} (4|5) [3-4]  [3-47-8] 0? ?2 *2
376ls =some_file
377ls DATA_[0-9](#c,4).csv
378ls DATA_[0-9](#c3).csv
379ls DATA_[0-9](#c4,).csv
380ls DATA_[0-9](#c4,7).csv
381ls PHP*/**/*.php
382ls [01]<->201[45]/Daily\ report*.csv(e#age 2014/10/22 now#)
383ls ^*.(css|php)(.)
384ls ^?*.*
385ls ^?*.*(D)
386ls ^?*.[^.]*(D)
387ls a(#c3).txt
388ls file<20->
389ls foot(fall)#.pl
390ls fred<76-88>.pl
391ls fred<76->.pl
392ls fred^erick*
393ls fred{09..13}.pl
394ls fred{joe,sid}.pl
395ls x*~(x3|x5)
396ls x*~^x[3,5]
397ls x*~x[3,5]
398ls x^[3,5]
399ls y2#.cfm y{2,}.cfm y(2|).cfm {y2,y}.cfm (y|y2).cfm y*.cfm
400ls {^dev*,}/index.php(.N)
401ls {_,}fred.php
402ls {p..q}<5->{1..4}.(#I)php(.N)
403ls ~1/*(.om[1])
404ls **/*.php~*junk*/*  #find all calls to mail, ignoring junk directories
405ls **/(*.cfm~(ctpigeonbot|env).cfm)
406ls **/*.{js,php,css}~(libs|temp|tmp|test)/*
407ls */*.php~libs/*~temp/*~test/*
408ls **/(*.cfm~(ctpigeonbot|env).cfm)~*((#s)|/)junk*/*(.)
409ls **/*.(js|php|css)~(libs|temp|test)/*
410ls **/*.(js|php|css)~libs/*~temp/*~test/*
411ls report/**/*.{inc,php}  # searching for a php variable
412ls *.log(Ne-age 2006/10/04:10:15 2006/10/04:12:45-)
413ls $(echo /c/aax/*(.om[1]))(+cyg) &
414ls *~vssver.scc(.om[1])
415ls /c/aax/*(.om[1]+cyg)
416ls ${(ps:\0:)"$(grep -lZ foobar ./*.txt(.))"}
417ls [[[[]]x*
418
4192 - f -f
420!a -f
421'a' -f
422$a -f
423
424# redirections (prefix)
425<<<s cat
426<<<'s' cat
427<<<'s's cat
428<<<s's's cat
429<<<s${s}s cat
430<<< s${s}s cat
431>&2 cat
432<f cat
4332>3 cat
4342>&3 cat
4352>& 3 cat
4362>f cat
437&>f cat
4382>>(xless) cat
4392<<(xless) cat
4402>>(xless)cat
4412<<(xless)cat
442
443# redirections
444cat f>2
445cat d/f>2
446cat d/f >2
447cat d/f >& 2
448cat >2 d/f
449cat > 2
450cat <(echo) <(echo a) <(echo a/f) <(echo ) <(echo a ) <(echo a/f )
451cat 2>>(xless)
452cat 2<<(xless)
453cat 2>&1 &>f &>>f 2<&1- 2<>f 2<<heredoc
454bla bla
455heredoc
456<<-'h' cat
457bla
458h
459<<"'" cat
460bla
461'
462r=$(xxx $@ 2>&1)
463
464# branches
465cat a|cat
466cat a&cat
467cat a||cat
468cat a&&cat
469cat a;cat
470cat a | cat
471cat a & cat
472cat a || cat
473cat a && cat
474cat a ; cat
475cat a'a';cat
476
477# substitutions
478echo '' 'a' '\' "" "a" "\\" "$a" "a""a"'a''a' a'b'c a"b"c a$'\n'c
479echo a!bc a{a}b a{b,c}d a{b,{d,e}}d a\ b
480echo a$bc a$b/c a${b}c a$((b-3))c a$(b)c a$(a b c)c
481echo ${a[*]} ${a[@]} ${a[${b}]} ${a:-x$z} ${a/g} ${a//f/f} ${a//f*/f*}
482echo ${!a} ${#a[1]} ${a:1:$b} $((++i,i--))
483echo ${a:^v} ${=a:/#%a#?*/bla} ${x#??(#i)} ${das:-{}<a.zsh}
484echo ${(f)"$(<$1)"} ${${(Az)l}[$2]} ${(f)"$(eval ${(q)@[2,$]})"}
485echo ${(@)foo} ${(@)foo[1,2]} ${${(A)name}[1]} ${(AA)=name=...} ${(Q)${(z)foo}}
486echo ${(ps.$sep.)val} ${(ps.${sep}.)val} ${(s.$sep.)val} ${(s.)(.)val}
487echo ${(pr:2+3::_::$d:)var} ${(r:2+3::_::$d:)var}
488echo ${${:-=cat}:h}
489$foo:h34:a:gs/dfs/fds/:s/fds/d'd'f xyz $foo: $foo:O $foo:A
4903=$foo:QQQ xyz $a[3,$]:h3:t1:e
491echo ${${~foo}//\*/*.c}
492echo !$ !!:$ !* !!:* !-2:2 !:-3 !:2* !:2- !:2-3 !^ !:1 !!:1
493echo "$bg[blue]$fg[yellow]highlight a message"
494echo "$bg[red]$fg[black]${(l:42::-:)}"
495echo "${${(@)foo[2,4]}[2]}"
496echo "${(j::)${(@Oa)${(s::):-hello}}}"
497echo "${(j::)${(@Oa)${(s::):-hello}}}"
498echo "<a href='$url'>$anchortext</a>"
499echo $(( sin(1/4.0)**2 + cos(1/4.0)**2 - 1 ))
500echo $a[${RANDOM}%1000] $a[${RANDOM}%11+10]
501echo $convtable[158]
502echo ${array[0]: -7 : +  22  }  ${array[1]: num  }
503echo ${parameter##word} ${parameter%%word}
504echo $f ' # $fred'
505echo $f:e $f:h $f:h:h $f:r $f:t $f:t:r $file:r
506echo ${(C)foo:gs/-/ /:r} ${(M)0%%<->} ${(j/x/s/x/)foo} ${(l:$COLUMNS::-:)}
507echo ${(l:3::0:)${RANDOM}} ${(s/x/)foo%%1*} ${0##*[!0-9]}
508echo ${a:2:2} ${a:2} ${a[1,3]} ${d/#?/} ${d/%?/} ${d[1,-2]} ${d[2,$]}
509echo ${d[2,-1]} ${file##*/} ${file%.*} ${texfilepath%/*.*} *(f:u+rx,o-x:)
510echo *(f:u+rx:) **/*(@-^./=%p) **/*(@-^./=%p) convert_csv.php(:a)
511cd $(locate -l1 -r "/zoo.txt$")(:h) # cd to directory of first occurence of a file zoo.txt
512cd ${$(!!)[3]:h}  # cd to 3rd in list
513cd ${$(locate zoo.txt)[1]:h}
514cd ${drive}/inetpub/wwwdev/www.some.co.uk/
515cd **/*.php(.om[1]:h) # cd to directory of newest php file
516cd -
517cd /tmp/test/;touch {1..5} {6,7,8,12} {00..03}
518cd ~www/admin
519chmod g+w **/*
520chmod someuser /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
521cp *.mp3(mh-4) /tmp # copy files less than 4 hours old
522cp -a file1 file   # -a transfer  permissions etc of file1 to file2preserve
523file **/*(D@) | fgrep broken
524file **/*(D@) | fgrep broken
525file=${1/#\//C:\/} # substitute / with c:/ Beginning of string
526file=${1/%\//C:\/} # substitute / with c:/ End of string
527file=${1/\//C:\/} # substitute / with c:/ ANYWHERE in string
528filelst+=($x)
529filelst[$(($#filelst+1))]=$x
530files=(${(f)"$(egrepcmd1l)"} )
531files=(${(f)"$(ls *$**)"}(.N)) # ")`
532files=(**/*(ND.L0m+0m-2))
533mkdir $f:h;touch $f
534mv Licence\ to\ Print\ Money.pdf !#^:gs/\\ //
535path=(${path:#$path_to_remove})
536path=(${path:|excl})
537pattern=${(b)str}
538pattern=${(q)str}
539print "$aa[one\"two\"three\"quotes]"
540print "$bg[cyan]$fg[blue]Welcome to man zsh-lovers" >> $TTY
541print $(( [#8] x = 32, y = 32 ))
542print $((${${(z)${(f)"$(dirs -v)"}[-1]}[1]} + 1)) # or
543print $(history -n -1|sed 's/.* //')
544print $aa[(e)*]
545print $ass_array[one]
546print $x $y
547print ${#path[1]}       # length of first element in path array
548print ${#path}          # length of "path" array
549print ${$( date )[2,4]} # Print words two to four of output of ’date’:
550print ${$(/sbin/ifconfig tun0)[6]}
551print ${${$( LC_ALL=C /sbin/ifconfig lo )[6]}#addr:}
552print ${${$(LC_ALL=C /sbin/ifconfig eth0)[7]}:gs/addr://}
553print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
554print ${${(z)$(history -n -1)}[-1]}
555print ${${(z)history[$((HISTCMD-1))]}[-1]}
556print ${(L)s// /-}.jpg
557print ${(L)s:gs/ /-/}.jpg
558print ${(S)foo//${~sub}/$rep}
559print ${(k)ass_array} # prints keys
560print ${(v)ass_array} # prints values
561print ${JUNK/%./_}                 # substitute last . for a _
562print ${JUNK/.(#e)/_}              # substitute last . for a _
563print ${arr//(#m)[aeiou]/${(U)MATCH}}
564print ${array:t}
565print ${foo%%$'\n'}                # strip out a trailing carriage return
566print ${foo//$'\n'}                # strip out any carriage returns (some systems use \r)
567print ${foo//${~sub}/$rep}
568print ${foo: 1 + 2}
569print ${foo:$(( 1 + 2))}
570print ${foo:$(echo 1 + 2)}
571print ${foo:3}
572print ${param:&}   (last substitute)
573print ${somevar//[^[:alnum:]]/_}   # replace all non-alphanumerics with _ the // indicates global substitution
574print ${string[(r)d?,(r)h?]}
575print '\e[1;34m fred'
576print (*/)#zsh_us.ps
577print *(e:age 2006/10/04 2006/10/09:)
578print **/*(/^F) | xargs -n1 -t rmdir #delete empty directories
579print *.c(e_'[[ ! -e $REPLY:r.o ]]'_)
580print -C 1 $X           # print each array element on it's own line
581print -l "${(s.:.)line}"
582print -l $MATCH X $match
583print -l $accum
584print -l *(n:t)      # order by name strip directory
585print -l **/*(-@)
586print -l **/*(On:t)  # recursive reverse order by name, strip directory
587print -r -- $^X.$^Y
588print -r -- ${(qq)m} > $nameoffile      # save it
589print -rC1 /tmp/foo*(u0^@:t)
590print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/)
591print -rC2 -- ${1:[...]}/*(D:t)
592print -rl $HOME/${(l:20::?:)~:-}*
593print -rl -- ${${=mapfile[/etc/passwd]}:#*(#i)root*}
594print -rl /**/*~^*/path(|/*)
595print {$((##n))..$((##y))}P\ 10P | dc
596print root@192.168.168.157:${PWD/test/live}v
597
598
599# conditions
600[ a ]
601[ -f f'f'f ]
602[ -f f]'f'f] ]
603[ -t 13 ]
604[ -t 13] ]
605[ -t 13] ]
606[ -v abc ]
607[ -z abc ]
608[ abc -ef abc ]
609[ abc -ef abc ]
610[ abc-ef -ef abc-ef ]
611[ abc == abc ]
612[ abc < abc ]
613[ abc -eq abc ]
614[[ abc -eq abc ]]
615[ 1+2 -eq 1+2 ]
616[[ 1+2 -eq 1+2 ]]
617[ a = b c ]
618( [ a = b ] )
619([ a = b ])
620[[ a = b c ]]
621[[ x =~ a(b c|$)' '{1,}[a[.digit.]] ]]
622[[ x =~ [ ] ]]
623[[ x =~ ([ ]) ]]
624[[ x =~ [ ]]
625[[ x =~ ([) ]]
626[[ a<b ]]
627[[ a <b ]]
628[[ a< b ]]
629[[ a < b ]]
630[[(! -d .)]]
631[[ ! -d . ]]
632[[ !(-d .) ]]
633[[ -f a || -f b ]]
634[[ -f a||-f b ]]
635[ -d `echo .`] ]
636[[ -d `echo .`]] ]]
637[[ a != b && ${a}a = b${b} ]]
638[[ $1 == <-> ]]
639[[ a =~ <1-2>a<->a<-2>a<2->a([!d]a?s[x[:alnum:]]|d?)p ]]
640[[ -n file*(#qN) ]]
641[[ ( -f foo || -f bar ) && $report = y* ]] && print File exists.
642[[ $str = ${~pattern} ]]
643[[ $str = ${~pattern} ]]
644[[ "?" = ${(~j.|.)array} ]]
645( [[ a = b ]] )
646([[ a = b ]])
647
648
649[ a -eq 2 ] || [ a -eq 2] ] && [[ a -eq 2 ]] || [[ a != b ]];
650[ a -eq 2 ]||[ a -eq 2] ]&&[[ a -eq 2 ]]||[[ a != b ]];
651
652((3+1+a+$c*(x) & 0x4342_2fd+03-08_5/23#D9a@_^8))
653((1.3/(2-(a-4))))
654
655# they are not arithmetic evaluations...
656((cmd && cmd) || cmd)
657$((cmd && cmd) || cmd)
658((cmd &&
659cmd) || cmd)
660$((cmd &&
661cmd) || cmd)
662
663print $(( [#_] sqrt(1e7) 0__39 1423e23 .2443 43.34 34.43e4 .d))
664
665{ echo
666    echo
667}
668{ echo ; }
669{ echo }
670{echo}
671{ls f} always {ls}
672{echo {a}}
673}echo
674echo {a} {a/b} a{b}/c a/b{c} a/{b} a/{b}c d/{{a}}
675echo {a{a{a}}}
676echo {a{a{a}a}a}a
677echo {a
678echo a}
679echo{a}
680echo{a{a{a}}}
681echo{a{a{a}a}a}a
682echo{a
683echo}
684
685{ {echo a} }
686{ {echo a}a} }
687{ { echo a } }
688{ { echo a}a } }
689
690{ {echo a/b} }
691{ {echo a/b}a} }
692{ { echo a/b } }
693{ { echo a/b}a } }
694
695{ {echo >a/b} }
696{ {echo >a/b}a} }
697{ { echo >a/b } }
698{ { echo >a/b}a } }
699
700{ab}c}
701{a,b}c}
702{ab}[}
703{a,b}[}
704
705cat >f{oo,ar}
706
707(echo ; echo)
708(echo
709    echo)
710(echo a)
711test a -eq b
712
713# functions
714a() { echo x; }
715a  () { echo x; }
716function f { echo x; }
717kde.org() { echo x; }
718--func() { echo x; }
719noglob function f { echo x; }
720
721# variables
722a=(a b c)
723a='a'
724a+=b
725a[1]='a'
726a[$i]='x'
727a[$((
728    2+4
729))]='x'
730a=([a]=2 `echo` -s > 'ds')
731a=(#comment
732value#nocomment #comment)
733)
734a=a cat
735a=`ls` cat
736a[2+3][d]=5
737
738# control structure
739for name in a b c {d,e} ; do echo ; done
740for name; do echo ; done
741for name do echo ; done
742for ((i=0;i<5;++i)) ; do echo $i ; done
743for ((i=1;$#A[i];i++)) echo $A[$i]
744for c ({1..50}) {php ./test.php; sleep 5;}
745for count in {1..10}; do echo $count ; done
746for f (*(.)) mv $f fixed_$f
747for f (**/x) cp newx $f
748for f (*.txt) { echo $f }
749for f in **/x; do;cp newx $f; done
750for f in */include/dbcommon.php; do;cp dbcommon.php $f; done
751for file (*(ND-.)) IFS= read -re < $file
752for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
753for i in *(.); mv $i ${i:u} # `bar to `BAR
754for i in **/*(D@); [[ -f $i || -d $i ]] || echo $i
755for i in **/*.gif; convert $i $i:r.jpg
756for i in {3,4}; sed s/flag=2/flag=$i/ fred.txt > fred$i.txt
757for ip ({217..219} 225) {echo -n $ip ;ping -n 1 11.2.2.$ip| grep Received}
758for user (${(k)f}) {print -rn $f[$user]|mailx -s "..." $user}
759for x ( 1 2 {7..4} a b c {p..n} *.php) {echo $x}
760select name in a ; do echo ; done
761select name; do echo ; done
762if : ; then echo ; elif [[ : ]] ; then echo ; else echo ; fi
763if [ $# -gt 0 ];then string=$*;else;string=$(getclip);fi
764if [ $# -gt 0 ];then string=$*;else;string=$(getclip);fi # get parameter OR paste buffer
765if [[ (($x -lt 8) && ($y -ge 32)) || (($z -gt 32) && ($w -eq 16)) ]] ; then print "complex combinations"; fi
766if builtin cd $1 &> /dev/null ; then echo ; fi
767if grep -iq 'matching' *.php ;then echo "Found" ;else echo "Not Found"; fim=("${(@Q)${(z)"$(cat -- $nameoffile)"}}") fi
768while : || : ; do echo ; done
769while (true){echo -n .;sleep 1}
770while (true){echo .;sleep 1}
771while true ;do date; sleep 5; done # forever
772while true; do echo "infinite loop"; sleep 5; done
773until : ; : ; do echo ; done
774case a in a) esac
775case a in a) echo ; esac
776case pwd in (patt1) echo ; echo ;; (patt*) echo ;& patt?|patt) echo ;|
777patt) echo ;; esac
778repeat 1+2+`echo 1`+23 do echo pl; done
779repeat 3 time sleep 3   # single command
780repeat 5 ;do date; sleep 5; done # multi
781foreach x y z ( a `a b`; c ) echo ;end
782for x y ( a b bc d ds ) echo $x $y
783for x y in a b c ; echo $x $y
784for x y ; echo $x $y
785case w { a) echo ;& (b?) echo }
786case a in
787#a) echo ;;
788a#) echo ;;
789esac
790
791for name in a
792 b c ;
793do
794echo
795done
796
797case a in
798  a\( | b*c? ) echo
799  (b$c) # no pattern
800  ;;
801  (b$c) ;;
802  # no pattern
803  (b$c)
804esac
805
806case "$1" in
807 "a") run_a|&a;;
808 "b") run_b;;
809 "c") run_c;;
810 *) echo "Plase choose between 'a', 'b' or 'c'" && exit 1;;
811esac
812
813case $ans in
814 1|a) sdba $key;;
815 2|f) sdbf $key;;
816 3|i) sdbi $key;;
817 *) echo "wrong answer $ans\n" ;;
818esac
819
820case "$ans" in
821 2|${prog}9) cd "$(cat /c/aam/${prog}9)" ;;
822 **) echo "wrong number $ans\n" ;;
823esac
824
825select f in $(ls **/*.tex |egrep -i "${param}[^/]*.tex")
826do
827 if [[ "$REPLY" = q ]]
828 then
829    break
830 elif [[ -n "$f" ]]; then
831    gvim $f
832 fi
833done
834
835for d (. ./**/*(N/m-2)) {
836  print -r -- $'\n'${d}:
837  cd $d && {
838     l=(*(Nm-2))
839     (($#l)) && ls -ltd -- $l
840     cd ~-
841  }
842}
843
844for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; do
845    lynx -source $f >${f:t}
846done
847
848for f in ./**/*(-@); do
849    stat +link -A l $f
850    (cd $f:h & [[ -e $l.gz ]]) & ln -sf $l.gz $f
851done
852
853for ((i=1; i <= $#fpath; ++i)); do
854    dir=$fpath[i]
855    zwc=${dir:t}.zwc
856    if [[ $dir == (.|..) || $dir == (.|..)/* ]]; then
857        continue
858    fi
859    files=($dir/*(N-.))
860    if [[ -w $dir:h && -n $files ]]; then
861        files=(${${(M)files%/*/*}#/})
862        if ( cd $dir:h &&
863            zrecompile -p -U -z $zwc $files ); then
864        fpath[i]=$fpath[i].zwc
865        fi
866    fi
867done
868
869if ztcp pwspc 2811; then
870    tcpfd=$REPLY
871    handler() {
872        zle -I
873        local line
874        if ! read -r line <&$1; then
875            # select marks this fd if we reach EOF,
876            # so handle this specially.
877            print "[Read on fd $1 failed, removing.]" >&2
878            zle -F $1
879            return 1
880        fi
881        print -r - $line
882    }
883    zle -F $tcpfd handler
884fi
885
886while [[ $? -eq 0 ]] do
887    b=($=ZPCRE_OP)
888    accum+=$MATCH
889    pcre_match -b -n $b[2] -- $string
890done
891
892# bug #380229
893${str:$((${#a[1]}+1))}
894
895# from http://zshwiki.org/home/examples/hardstatus
896function title {
897  if [[ $TERM == "screen" ]]; then
898    # Use these two for GNU Screen:
899    print -nR $'\033k'$1$'\033'\\
900
901    print -nR $'\033]0;'$2$'\a'
902  elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
903    # Use this one instead for XTerms:
904    print -nR $'\033]0;'$*$'\a'
905  fi
906}
907
908function precmd {
909  title zsh "$PWD"
910}
911
912function preexec {
913  emulate -L zsh
914  local -a cmd; cmd=(${(z)1})
915  title $cmd[1]:t "$cmd[2,-1]"
916}
917
918function ddump(){diff -w ~dump/"$1" "$1"}   # diff local file with new one in dump
919function g{0..9} { gmark $0 $* }          # declaring multiple functions
920function hello_function { echo "hello world" ; zle .accept-line}
921function scd(){setopt nonomatch;e=/dev/null;cd $1(/) &> $e||cd $1*(/) &> $e||cd *$1(/) &> $e||cd *${1}*(/) &> $e||echo sorry}
922function vx{0..9} {gvim.exe c:/aax/${0/#v/} &}
923function {xyt,xyy} { if [ "$0" = "xyy" ]; then echo run xyy code; else  echo run xyt code; fi ; echo run common code } #
924
925# creating a family of functions
926# generate hrefs from url
927function href{,s}
928{
929    # href creates an HTML hyperlink from a URL
930    # hrefs creates an HTML hyperlink from a URL with modified anchor text
931    PROGNAME=`basename $0`
932    url=`cat /dev/clipboard`
933    if [ "$PROGNAME" = "href" ] ; then
934        href="<a href='$url'>$url"
935    elif [ "$PROGNAME" = "hrefs" ] ; then
936        anchortext=${${(C)url//[_-]/ }:t}
937        href="<a href='$url'>$anchortext"
938    fi
939    echo -n $col
940    echo $href > /dev/clipboard | more
941}
942
943# create vim scratch files va,vb to vz
944function 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}
945{
946    scratchfile=${0/#v/}
947    gvim.exe c:/aax/$scratchfile &
948}
949
950VDF(){cd *(/om[1]);F=$(echo *(.om[1]));vi $F}
951cyg(){reply=("$(cygpath -m $REPLY)")}
952f  (){for i; do echo $i;done}
953fg_light_red=$'%{\e[1;31m%}'
954fn() { setopt localtraps; trap '' INT; sleep 3; }
955nt() { [[ $REPLY -nt $NTREF ]] }
956preexec(){ echo using $@[1]}
957take(){[ $# -eq 1 ]  && mkdir "$1" && cd "$1"} # create a directory and move to it in one go
958
959caption always "%3n %t%? (%u)%?%?: %h%?"
960
961preexec() {
962  emulate -L zsh
963  local -a cmd; cmd=(${(z)1})             # Re-parse the command line
964
965  # Construct a command that will output the desired job number.
966  case $cmd[1] in
967      fg)
968        if (( $#cmd == 1 )); then
969          # No arguments, must find the current job
970          cmd=(builtin jobs -l %+)
971        else
972          # Replace the command name, ignore extra args.
973          cmd=(builtin jobs -l ${(Q)cmd[2]})
974        fi;;
975       %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
976       exec) shift cmd;& # If the command is 'exec', drop that, because
977          # we'd rather just see the command that is being
978          # exec'd. Note the ;& to fall through.
979       *)  title $cmd[1]:t "$cmd[2,-1]"    # Not resuming a job,
980          return;;                        # so we're all done
981      esac
982
983  local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
984
985  # Run the command, read its output, and look up the jobtext.
986  # Could parse $rest here, but $jobtexts (via $jt) is easier.
987  $cmd >>(read num rest
988          cmd=(${(z)${(e):-\$jt$num}})
989          title $cmd[1]:t "$cmd[2,-1]") 2>/dev/null
990}
991
992function precmd() {
993  title zsh "$IDENTITY:$(print -P %~)"
994}
995
996"%{^[]0;screen ^En (^Et) ^G%}"
997
998print -nRP $'\033k%(!.#\[.)'$1$'%'$\(\(20\-${#1}\)\)$'< ..<'${${2:+${${${@[${#${@}}]##/*/}/#/ }:-}}//\"/}$'%(!.\].)\033'\\
999
1000c() { echo -E "$(<$1)" }
1001col() { for l in ${(f)"$(<$1)"} ; echo ${${(Az)l}[$2]} }
1002colx() { for l in ${(f)"$(eval ${(q)@[2,$]})"} ; echo ${${(Az)l}[$1]} }
1003
1004[[ -r /etc/ssh/ssh_known_hosts ]] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
1005_ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
1006_ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
1007: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
1008
1009prefix='(I:'$@[$(($i+1))]':)'$prefix || prefix='${('$tmp'I:'$@[$(($i+1))]':'${prefix[$(($#tmp+4)),-1]}
1010prefix='${'${j:+($j)}$prefix; suffix+=':#'${@[$(($i+1))]//(#m)[\/\'\"]/\\$MATCH}'}'
1011cmd+='<'${(q)@[$(($i+1))]}';'
1012C=${OPTARG//(#m)[[\/\'\"\\]/\\$MATCH}
1013$=p $e'"$(<'${(j:<:)${(q)@}}')"'$m
1014
1015zshaddhistory() {
1016    print -sr -- ${1%%$'\n'}
1017    fc -p .zsh_local_history
1018}
1019
1020TRAPINT() {
1021    print "Caught SIGINT, aborting."
1022    return $(( 128 + $1 ))
1023}
1024
1025zsh_directory_name() {
1026    emulate -L zsh
1027    setopt extendedglob
1028    local -a match mbegin mend
1029    if [[ $1 = d ]]; then
1030        # turn the directory into a name
1031        if [[ $2 = (#b)(/home/pws/perforce/)([^/]##)* ]]; then
1032            typeset -ga reply
1033            reply=(p:$match[2] $(( ${#match[1]} + ${#match[2]} )) )
1034        else
1035            return 1
1036        fi
1037    elif [[ $1 = n ]]; then
1038        # turn the name into a directory
1039        [[ $2 != (#b)p:(?*) ]] && return 1
1040        typeset -ga reply
1041        reply=(/home/pws/perforce/$match[1])
1042    elif [[ $1 = c ]]; then
1043        # complete names
1044        local expl
1045        local -a dirs
1046        dirs=(/home/pws/perforce/*(/:t))
1047        dirs=(p:${^dirs})
1048        _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
1049        return
1050    else
1051        return 1
1052    fi
1053    return 0
1054}
1055
1056() {
1057    print File $1:
1058    cat $1
1059} =(print This be the verse)
1060
1061if [[ $foo = (a|an)_(#b)(*) ]]; then
1062    print ${foo[$mbegin[1],$mend[1]]}
1063fi
1064
1065zshaddhistory() {
1066    emulate -L zsh
1067    ## uncomment if HISTORY_IGNORE
1068    ## should use EXTENDED_GLOB syntax
1069    # setopt extendedglob
1070    [[ $1 != ${~HISTORY_IGNORE} ]]
1071}
1072
1073pick-recent-dirs-file() {
1074    if [[ $PWD = ~/text/writing(|/*) ]]; then
1075        reply=(~/.chpwd-recent-dirs-writing)
1076    else
1077        reply=(+)
1078    fi
1079}
1080
1081run-help-ssh() {
1082    emulate -LR zsh
1083    local -a args
1084    # Delete the "-l username" option
1085    zparseopts -D -E -a args l:
1086    # Delete other options, leaving: host command
1087    args=(${@:#-*})
1088    if [[ ${#args} -lt 2 ]]; then
1089        man ssh
1090    else
1091        run-help $args[2]
1092    fi
1093}
1094
1095local -A zdn_top=(
1096    g   ~/git
1097    ga  ~/alternate/git
1098    gs  /scratch/$USER/git/:second2
1099    :default: /:second1
1100)
1101
1102(( $#files > 0 )) && print -rl -- $files | \
1103    mailx -s "empty files" foo [at] bar.tdl
1104
1105print -r -- $s[3] ${(l:4:)s[4]} ${(l:8:)s[5]} \
1106    ${(l:8:)s[6]} ${(l:8:)s[8]} $s[10] $f ${s[14]:+-> $s[14]}
1107
1108paste <(cut -f1 file1) <(cut -f3 file2) |
1109    tee >(process1) >(process2) >/dev/null
1110
1111ls \
1112> x*
1113
1114sed '
1115 s/mvoe/move/g
1116 s/thier/their/g' myfile
1117
1118
1119trap '
1120    # code
1121    ' NAL
1122
1123!! # previous command
1124!!:0 !^ !:2 !$ !#$ !#:2 !#1 !#0
1125!!:gs/fred/joe/       # edit previous command replace all fred by joe
1126!!:gs/fred/joe/       # edit previous command replace all fred by joe
1127!!:s/fred/joe/        # Note : sadly no regexp available with :s///
1128!!:s/fred/joe/        # edit previous command replace first fred by joe
1129!$ (last argument of previous command)
1130!$:h (last argument, strip one level)
1131!$:h:h (last argument, strip two levels)
1132!-2 # command before last
1133!1 # oldest command in your history
1134!42                   # Re-execute history command 42
1135!42:p
1136!?echo
1137!?saket?:s/somefile1/somefile2/
1138
1139(($#l)) && ls -ltd -- $l
1140((val2 = val1 * 2))
1141(mycmd =(myoutput)) &!
1142: *(.e{'grep -q pattern $REPLY || print -r -- $REPLY'})
1143: > /apache/access.log  # truncate a log file
1144< readme.txt
1145A=(1 2 5 6 7 9) # pre-populate an array
1146C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/zsh --login
1147C=3 && F=$(print *(.om[1,$C])) && for f ($(print $F)){php -l $f} && scp -rp $(print $F) user@192.168.1.1:$PWD
1148EDITOR='/bin/vim'
1149FILE=$(echo *(.om[1])) && ls -l $FILE && ssh 192.168.1.1 -l root "zsh -c 'ls -l $PWD/$FILE'"
1150FILES=( .../files/* )
1151IFS=$'\n\n'; print -rl -- ${(Oau)${(Oa)$(cat file;echo .)[1,-2]}}
1152IPREFIX=${PREFIX%%\=*}=
1153PREFIX=${PREFIX#*=}
1154PROMPT3="Choose File : "
1155PROMPT="%{$bg[cyan]%}%% "
1156PS3="$fg_light_red Select file : "
1157REPORTTIME=10 # Automatically /Report CPU usage for commands running longer than 10 seconds
1158RPROMPT="[%t]" (display the time)
1159X=(x1 x2)
1160Y=(+ -)
1161[[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t
1162[[ $OSTYPE == (#i)LINUX*(#I) ]];
1163[[ 'cell=456' =~ '(cell)=(\d+)' ]] && echo $match[1,2] $MATCH
1164[[ -e $L/config.php ]] && cp -p -update $T/config.php $L
1165[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
1166[[ 1 = 0 ]] && echo eq || echo neq
1167[[ alphabetical -regex-match ^a([^a]+)a([^a]+)a ]] &&
1168^chim^&-&ney-&-&-cheree # reuse LHS
1169^fred^joe             # edit previous command replace fred by joe
1170^php^cfm          # modify previous command (good for correcting spellos)
1171^str1^str2^:G         # replace as many as possible
1172^str1^str2^:u:p       # replace str1 by str2 change case and just display
1173a=(**/*(.D));echo $#a  # count files in a (huge) hierarchy
1174a=(1 2 3 4); b=(a b); print ${a:^b}
1175a=(a b); b=(1 2); print -l "${a:^b}"; print -l "${${a:^b}}"
1176a=12345
1177aa[(e)*]=star
1178accum=()
1179alias '..'='cd ..'
1180alias -g ...='../..'
1181alias -g NF='*(.om[1])' # newest file
1182alias gcd="cd $MCD"  # double quote stops once only evaluation
1183alias mcd="MCD=$(pwd)"  # double quote stops once only evaluation
1184anchortext=${${(C)url//[_-]/ }:t}  # titlecase
1185arr=(veldt jynx grimps waqf zho buck)
1186array=(~/.zshenv ~/.zshrc ~/.zlogout)
1187autoload edit-command-line
1188autoload -Uz up-line-or-beginning-search
1189autoload colors ; colors
1190bindkey "^N" most-recent-file
1191bindkey -s "^[OS" "\^d\^c\n"
1192bindkey -s "^[[18~" "ls -l\n"
1193c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'
1194cd !$:h
1195cd !?ls
1196diff <(find / | sort) <(cat /var/lib/dpkg/info/*.list | sort)
1197dpath=${upath/#\/c\//c:/}          # convert /c/path/ to c:\path\
1198drive=$([[ "$LOGNAME" != davidr ]] && echo '/o' || echo '/c') # trad way
1199drive=${${${LOGNAME:#davidr}:+/o}:-/c}                        # zsh way
1200egrep -i "^ *mail\(" **/*.php
1201eval "$1=$PWD"
1202eval "m=($(cat -- $nameoffile)"
1203feh $FILES[$RANDOM%$#FILES+1]
1204foo="twinkle twinkle little star" sub="t*e" rep="spy"
1205foo=$'bar\n\nbaz\n'
1206foo=fred-goat-dog.jpg
1207fred=$((6**2 + 6))      # can do maths
1208(( $# == 0 ));
1209[ "$p1" = "end" ] || [ "$p1" = "-e" ]
1210[ $# -gt 0 ]  # parameter cnt > 0 (arguments)
1211[ $cnt -eq 1 ]
1212[[ "$1" == [0-9] ]]  # if $1 is a digit
1213[[ "$p2" == *[a-zA-Z][a-zA-Z][a-zA-Z]* ]]  # contains at least 3 letters
1214[[ "$pwd" == *$site2* ]]
1215[[ "$url" = www* ]] # begins with www
1216[[ -e /c/aam/z$1 ]]  # file exists
1217p1 p2 p3
1218pcre_compile -m "\d{5}"
1219pcre_match -b -- $string
1220perl -ne 's/(<\/\w+>)/$1\n/g; print' < NF > $(print NF).txt
1221ps -p $$ | grep $$ | awk '{print $NF}'
1222r oldstr=newstr
1223r\m $(locate nohup.out)
1224read -r line <&$fd; print -r - $line
1225read ans ; # read in a parameter
1226setopt EXTENDED_GLOB   # lots of clever stuff requires this
1227source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
1228ssh -t root@192.18.001.001 'sh -c "cd /tmp && exec zsh -l"'
1229ssh 192.168.1.218 -l root "zsh -c 'for i (/usr/*(/)) {ls \$i }'"
1230sshpass -p myppassword scp -rp * user@18.128.158.158:${PWD/staging/release}
1231str=aa,bb,cc;print ${(j:,:)${(qq)${(s:,:)str}}} # quotify a string
1232tel blenkinsop | grep -o "[[:alnum:][:graph:]]*@[[:alnum:][:graph:]]*" # filter just an email address from a text stream (not zsh)
1233touch {t,p}{01..99}.{php,html,c}  # generate 600 test files
1234touch {y,y2}.cfm
1235trap - INT
1236typeset "aa[one\"two\"three\"quotes]"=QQQ
1237typeset -A aa
1238typeset -A ass_array; ass_array=(one 1 two 2 three 3 four 4)
1239typeset -A convtable
1240typeset -i 16 y
1241unsetopt XTRACE VERBOSE
1242unsetopt localtraps
1243upath=${wpath//\\/\/}              # convert backslashes to forward slashes (Dos to Unix
1244url='www.some.com/some_strIng-HERe'
1245val=a:b:c
1246var=133;if [[ "$var" = <-> ]] ; then echo "$var is numeric" ;fi
1247var=ddddd; [[ "$var" =~ ^d+$ ]] && echo matched || echo did not match
1248var=dddee; regexp="^e+$"; [[ "$var" =~ $regexp ]] && echo $regexp matched $var || echo $regexp did not match $var
1249vared -p "choose 1-3 : " -c ans
1250vared PATH
1251whence -vsa ${(k)commands[(I)zsh*]}  # search for zsh*
1252widget
1253wpath=${wpath//\//\\\\}            # substitute Unix / with dos \ slashes
1254x=$?
1255zmodload -F zsh/stat b:zstat
1256zsh -lxic : 2> >(grep "> alias 'web'")
1257{ paste <(cut -f1 file1) <(cut -f3 file2) } > >(process)
1258