« Back to Index

Zsh tips

View original Gist on GitHub

zsh.md

Path replacement

Moving from: /www/site1/media/css/main to /www/site2/media/css/main can be a pain, but not in zsh:

cd site1 site2

Globbing to find / remove files

Find all pdf files recursively

ls **/*.pdf

Find all files bigger than 10M

ls **/*(.Lm+10)

For more examples type ls **/*( then tab

Jump to previous directories

Enter dirs -v. You should see all the directories from your history stack.

You can use cd to navigate between its entries:

cd +4

Change directories without cd

With auto_cd, no need for cd

cd a_directory
# can be replaced with:
a_directory

Mass rename with zmv

zmv -W '*.txt' '*.markdown'

Resources

reasoniamhere.com/2014/01/11/outrageously-useful-tips-to-master-your-z-shell linuxaria.com/howto/globbing-con-zsh