ZSH reference
Glob qualifiers
/ | directories |
. | plain files |
@ | symbolic links |
* | executable plain files (0100) |
w | owner-writable files (0200) |
W | world-writable files (0002) |
U | files owned by the effective user ID |
^ | negates all qualifiers following it |
File expansion
*(X^/) | All executables but not directories |
*(m0) | Modified today |
*(mw+1) | Modified more than one week ago |
*(mM-1) | Modified within the last month |
*(.oc[1]) | Newest created file |
*(.om[1,3]) | 3 newest modified file |
*(.L+100) | More than 100 Bytes |
*(.Lm-10) | Less than 10 MB |
^x | Matches anything except the pattern x |
x~y | Match anything that matches the pattern x but does not match y. |
(#i)pattern | Case insensitive match |
(#a2)pattern | Approximate matching |
History expansion
!! | Last command |
!0 | 1st word of last command |
!^ | 2nd word of last command (1st argument) |
!$ | Last word of last command |
!* | All parameters of last command |
!!2 | 2nd word of last command |
!!-3 | 3rd last command |
!!-3:2 | 2nd word of 3rd last command |
!string | Last command starting with string |
!?string | Last command that contains string |
!?string?:$ | Last word of last command that contains string |
^old^new | Replace old in the last command by new |
r old=new | Replace old in the last command by new |
!# | Current line |
!#*:gs/old/new | Substitute old in current line parameters by new |
Other expansions
=ls | Expando to the command binary file: /bin/ls |
=(uname -a) | Expand to a temporary file with the output of the command |
Renaming
zmv '* *' '$f:gs/ /_' | Replace spaces in filenames with a underline |
zmv -W '*.sh' '*.pl' | Change the suffix from *.sh to *.pl |
zmv '(*)' '${(L)1}' | lowercase all |
zmv '(*)' '${(U)1}' | uppercase all |
Other
cd old new | Change directory from ../...old.../.. to ../...new.../.. |
cd ~5 | cd to fifth directory in directory stack |