Demos used in zsh presentation to PLUG North, 12-Jan-2009. These are mostly notes to myself of things to show, so portions of some of the examples may be in my head. I've cleaned them up a bit for posting, but many of them rely on having particular zsh options set, so they may not work as expected. Drop me an email (plsnyder at drexel.edu) if you can't figure out why an example is not working or you can't figure out what it's supposed to do. Paul --- zsh-newuser-install: $ sudo useradd -m -d /home/womble womble $ sudo chsh -s /bin/zsh womble $ sudo su - womble [newuser install runs] $ sudo userdel womble ---- Associative arrays $ typeset -i types $ cd /usr/lib $ for x in *; types[${x}]=$(file -b ${x}) $ echo $types{zsh.tpp} ---- Integer variables $ typeset -i 16 foo $ foo=256 $ echo "$foo" $ typeset -i 8 foo $ echo "$foo" $ typeset -i 13 foo $ echo "$foo" --- Tied scalar/variable pair $ typeset -T MEAT meat $ MEAT=Pork:Beef:Mutton $ echo $meat[1] $ meat[2]=Buffalo $ echo $MEAT $ echo $PATH $ echo $path $ typeset -u MEAT $ echo $MEAT --- Right prompt $ RPS1=%t $ RPS1=%~ $ cd /usr/lib/xscreensaver Named directories $ SS=$PWD $ cd $ cd SS --- History $ history $ !ec $ touch weaselbait $ rm !!$ $ !t $ mv weaselbait backup-!#:1.txt $ RPS=%h $ ! --- History Modifiers $ ls /usr/lib/xscreensaver/... $ echo !!$:t $ echo !-2$:t $ history $ echo !$:t:r $ echo !:s/lib/share/ $ bar="quickly quickly" $ echo ${bar:gs/c/r} --- Parameter Expansion Flags $ echo ${(u)bar} $ bar=('peas' 'porridge' 'hot') $ echo ${(oC)bar} $ herenow=(%~ %t) $ echo $herenow $ echo ${(%)herenow[1]} $ echo ${(%)herenow} $ files=(*) $ echo ${(O)files:q} $ echo ${(qj:+:)files} $ man zshexpn --- Ranges $ touch file{01..20} $ ls file{01..20} $ ls file{01..21} $ ls file<1-21> $ ls file<15-> --- ksh-style Glob Operators $ touch beer wine gin $ ls ^*file* $ ls file1^[23] $ touch ian barian barbarian barbarbarian $ ls *(bar)ian $ ls +(bar)ian $ ls !(bar)ian $ ls ?(bar)ian -- Globbing flags $ ls -d *(/) $ touch foo foO Foo fOO FoO FOo FOO $ ls (#i)FOO $ ls fo(#i)o $ ls (#a1)FOO $ chmod +x foo $ ls *(g+x) -- Recursive globbing $ ls ** -- Glob Qualifiers # from zsh-lovers $ print *(e:age today now:) $ print *(e-age 17:00 now-) -- Filename Expansion $ setopt EQUALS $ ls =zsh -- zmv $ touch {01..10}.foo.bar.baz.womble $ ls $ zmv '(*.*)(.*)' '${1//./-}$2' $ ls $ zmv -W '*.txt' '*.text' $ ls -- Random example, add leading zeros to a filename. # from zsh-lovers $ mkdir t1 $ cd t1 $ touch {1..100}file.txt $ zmv '(<1->)(*.txt)' '${(l:3::0:)1}$2' $ ls -- zle $ vared types $ vared PATH $ x=(*) $ echo "$x" >> foo.txt $ zed foo.txt -- Push-line $ bindkey '\[q' push-line-and-edit $ echo foo.txt bar[hit meta-Q] $ ls $ [echo line returns] -- Completion $ cd S $ ls $ ls - $ ls -- $ svn $ svn co $ ifconfig e $ man zsh $ ssh $ bindkey $ cd /usr/share/zsh/4.3.6/functions/Completion/ $ ls Linux $ ls Unix $ ls X/