Skip to content

Instantly share code, notes, and snippets.

@Integralist
Forked from jcleveley-zz/zsh.md
Last active August 29, 2015 14:11
Show Gist options
  • Save Integralist/5e794f37f378d0422e01 to your computer and use it in GitHub Desktop.
Save Integralist/5e794f37f378d0422e01 to your computer and use it in GitHub Desktop.
Zsh tips

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment