Search code examples
zshzshrc

option to get the current working directory


I'm using oh-my-zsh and wanted to write a small plugin which would executes command autoamtically when i switch directories. So for example I will have to some kind of mapping like

/Users/ed1t/Dropbox="echo Entering Dropbox Directory"

I could write a function cd() to do this but is that the efficient way of doing it?


Solution

  • I think you're looking for the chpwd hook function.

    chpwd () {
      echo "Changing directory from $OLDPWD to $PWD"
    }