Skip to content

Instantly share code, notes, and snippets.

@jcleveley-zz
Last active March 21, 2016 14:18
Show Gist options
  • Save jcleveley-zz/3a5d8285637393286563 to your computer and use it in GitHub Desktop.
Save jcleveley-zz/3a5d8285637393286563 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

https://coderwall.com/p/yepegw/mass-renaming-files-with-zmv-zsh

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