In the last post I described a nicer version of the shell
dirs command that labels each directory with its position, so that you can
pushd directly to the one you want.
One problem with it is that emacs shell-mode generally uses
dirs to track which directory you're in. And you do want it to track directories for you. Our nicer version of
dirs produces output that isn't readable to emacs.
Of course the natural solution is:
(setq shell-dirstack-query "command dirs")
to pick up the shell's builtin
dirs. Sadly, you can't just throw that line into your .emacs file, because shell-mode sets
shell-dirstack-queryevery time you start a new shell. It sets it unconditionally and globally, which is a ridiculous design flaw, but that's how it goes. There is no hook that runs after it sets the value, either.
So you're stuck with needing a workaround:
- Name your command something other than
- Use a flag on your new
dirsto get the nicer behavior.
- Write your own emacs function to start a shell:
(defun engisneering-shell ()
(setq shell-dirstack-query "command dirs"))