4

Instead of the normal cd I've created my own function

function cd {
    builtin cd "$@" && ls -F
}

This works great for when I use commands like cd someDir/subDir but not when I change directories via zsh's auto_cd someDir/subDir.

Is there a way to customize what command gets called for auto_cd?

1 Answer 1

5

The typical way to run-some-command-on-the-changing-of-the-directory is via the chpwd hook function (or list of functions named in the appropriately named chpwd_functions array):

% function chpwd () { pwd }  
% cd ~/tmp
/Users/jdoe/tmp
% pushd /etc
/etc ~/tmp
/etc
% chpwd_functions=( chpwd_do_ls )
% function chpwd_do_ls () { ls }
% cd /
/
Applications ...
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .