2

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?

3

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 ...
  • auto_cd is an option, listed in man zshoptions. – Gilles Jun 8 '16 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.