I use tramp a lot in emacs to edit files on various machines. I also use ssh and shell buffers for all my terminal interaction. This patch lets you set ssh-directory-tracking to use tramp. The patch didn’t apply perfectly to my version of ssh.el, so there was some minor hand work. You then need to set the dir tracking to T. I also needed to change the ssh-tramp-tracking-mode from “sm” to “scp”. It made me happy.
Update:
My current version of emacs (Aquamacs) has this functionality baked in. So now I have this in my startup file.
(require ‘ssh)
(require ‘advice)
(defadvice ssh (after ssh-fs-hook activate)
(message “tracking…”)
(ssh-directory-tracking-mode))