I’d like to execute a particular bash function when I enter a new directory. Somethink like:
alias cd="cd $@ && myfunction"
$@ doesn’t work there, and adding a backslash doesn’t help. I’m also a little worried about messing with cd, and it would be nice if this worked for other commands which changed directory, like pushd and popd.
Any better aliases/commands?
The easiest solution I can come up with is this
That ought to do it. It’ll work with all commands, and will get triggered before the prompt is displayed.