This article is a summary of reasoniamhere.com/…/outrageously-useful-tips-to-master-your-z-shell/. The original article is from 2014 and the pages last entry is from 2015. In case the website goes down I want the important bits saved for my reading and learning pleasure ;-)

note
None of the following commands on this page are my own.

File picking

 1# list every file directly below the Sites folder
 2ls Sites
 3
 4# list every file in the folders directly below the Sites folder
 5ls Sites/*
 6
 7# list every file in every folder two levels below the Sites folder
 8ls Sites/*/*
 9
10# list every file anywhere below the Sites folder
11ls Sites/**/*
12
13# list every file that ends in .txt in every folder at any level below the Sites folder
14ls Sites/**/*.txt

Glob operators

 1# list text files that end in a number from 1 to 10
 2ls -l Sites/**/*<1-10>.txt
 3
 4# list text files that start with the letter a
 5ls -l Sites/**/[a]*.txt
 6
 7# list text files that start with either ab or bc
 8ls -l Sites/**/(ab|bc)*.txt
 9
10# list text files that don't start with a lower or uppercase c
11ls -l Sites/**/[^cC]*.txt

Glob qualifiers

 1# show only directories
 2print -l Sites/**/*(/)
 3
 4# show only regular files
 5print -l Sites/**/*(.)
 6
 7# show empty files
 8ls -l Sites/**/*(L0)
 9
10# show files greater than 3 KB
11ls -l Sites/**/*(Lk+3)
12
13# show files modified in the last hour
14print -l Sites/**/*(mh-1)
15
16# sort files from most to least recently modified and show the last 3
17ls -l Sites/**/*(om[1,3])
1ls -l Sites/**/*(.Lm-2mh-1om[1,3])
2# you won't typically write at this level of obfuscation
3
4ls -l Sites/**/*(. Lm-2 mh-1 om [1,3])
5# this is more parseable, but unfortunately Zsh doesn't allow spaces
6# between qualifiers, so you'll get an error

Read more in section 14.8.7 of the manual.

Modifiers

Modifiers are preceded with a colon (:).

 1# A plain old glob
 2print -l Sites/website/images/gif/*.txt
 3
 4# Return the file name (t stands for tail)
 5print -l Sites/website/images/gif/*.txt(:t)
 6
 7# Return the file name without the extension (r stands for remove_extension, I think)
 8print -l Sites/website/images/gif/*.txt(:t:r)
 9
10# Return the extension
11print -l Sites/website/images/gif/*.txt(:e)
12
13# Return the parent folder of the file (h stands for head)
14print -l Sites/website/images/gif/*.txt(:h)
15
16# Return the parent folder of the parent
17print -l Sites/website/images/gif/*.txt(:h:h)
18
19# Return the parent folder of the first file
20print -l Sites/website/images/gif/*.txt([1]:h)
21# Remember you can combine qualifiers and modifiers.