1

I'd like to run a function whenever the current directory in eshell changes (like a eshell-chdir-hook, but that doesn't exist). How can I do this?

2
  • There are functions within eshell that detect things like a cd ... entry, which triggers an elisp function -- e.g., eshell/cd -- depending upon whether certain modules have been loaded. You could modify that function and attach your own hook, depending upon whether you use that particular module. I took over eshell completely by making one large custom library and I no longer use modules, but it shouldn't be difficult to track down if you need some further assistance.
    – lawlist
    Sep 1, 2015 at 3:36
  • No idea whether there is an Emacs hook for this, but you could presumably use a (shell) alias to change directories, and have that alias invoke Emacs in batch mode to invoke some Emacs function. Not saying this is a great solution...
    – Drew
    Sep 1, 2015 at 3:36

1 Answer 1

2

Well duh. The answer is to use eshell-directory-change-hook.

2
  • Yep, there it is at the bottom of eshell/cd
    – lawlist
    Sep 1, 2015 at 4:01
  • @lawlist yup. :) Thanks for the tip.
    – PythonNut
    Sep 1, 2015 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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