I find that I often do the following:
%> cd bla/bla %> ls
I would like it that whenever I
cd into a directory it automatically does an
I fiddled with my
.bashrc for a while, but couldn't figure out how to make it happen.
You can do this with a function:
In general, it is a bad practice to rename a command which already exists, especially for a commonly called command like
I have this in my .bashrc, and it works fine.
Earlier in my .bashrc I have:
off-topic, since the question is tagged /bash, but as some questions are closed as duplicate of this one that don't mention bash:
The chpwd() function is called by zsh whenever the current directory changes (by way of cd, pushd, popd...). tcsh has a similar feature and is probably where zsh got it from.
In bash you cannot recur to aliases for action that require parameter. For this there are functions. So put in your