Automatically ls when changing directories in zsh

The first thing I do when changing directories in the terminal is ls to get my bearings. I usually do it without thinking.

I used to do this manually, but then I learned that zsh has a way to do this for me. Zsh offers "hook functions", which can be defined and are executed when certain events happen. One of these functions, chpwd, will be "executed whenever the current working directory is changed."

Add something like this to your .zshrc:

chpwd() {

Now you'll ls whenever you cd (or pushd)!

Posted on .