You can modify dired-after-readin-hook to send an appropriate command to your shell buffer. The following code creates a shell called dired-synced-shell if one doesn't already exist, and every time you change a directory in dired, runs a cd on the shell running in buffer dired-synced-shell.
(add-hook 'dired-after-readin-hook (lambda() (unless (get-buffer "dired-synced-shell") (shell "dired-synced-shell")) (process-send-string (get-buffer "dired-synced-shell") (format "cd %s\n" default-directory)) (message "Switched to new directory"))) (add-hook 'dired-after-readin-hook (lambda() (unless (get-buffer "dired-synced-shell") (shell "dired-synced-shell")) (process-send-string (get-buffer "dired-synced-shell") (format "cd %s\n" default-directory)) (message "Switched to new directory"))) OP Edit: Here are two issues I found, with workarounds:
This doesn't work for switching to a dired buffer that already exists. Workaround: press
gto refresh the buffer.This causes my shell prompt to get smashed together with the previous, as it might if the output of the previous command didn't contain a newline. (E.g. if my shell prompt is
[scott@local]$, then on switching to a new dired buffer, I would see[scott@local]$ [scott@local]$. Workaround: add a newline to the beginning of my shell prompt.