This blog post gives instructions how to make the current directory of the shell calling Midnight Commander be mc's current directory upon exiting from mc.
The quick answer is to add alias mc=". /usr/share/mc/bin/mc-wrapper.sh" (or something similar, with a different path) to your shell startup script. If you don't know how to do that, read on.
On Ubuntu (Hardy, Jaunty, Karmic etc.) or Debian (Lenny etc.), run this as root (copy-paste as a whole):
grep -l bash\.bashrc /etc/profile || (echo echo 'test "$PS1" && test "$BASH" && . /etc/bash.bashrc') | tee -a /etc/profile echo 'type -p -a mc >/dev/null && alias mc=". /usr/share/mc/bin/mc-wrapper.sh"' | tee -a /etc/bash.bashrc
On the Mac OS/X with mc installed from MacPorts, open a Terminal window, type sudo bash, press Enter, type your password, press Enter, and then run the following (copy-paste as a whole):
grep -l bashrc /etc/profile || (echo echo 'test "$PS1" && test "$BASH" && . /etc/bashrc') | tee -a /etc/profile echo 'type -p -a mc >/dev/null && alias mc=". /opt/local/share/mc/bin/mc-wrapper.sh"' | tee -a /etc/bashrc
After doing so, open a new terminal window (or SSH connection), and it should work as expected (try it by running mc /tmp, and exiting by pressing Esc, 0, Enter).
For your information, the underlying solution (in mc-wrapper.sh) makes Midnight Commander print its current directory when it exits, and then the caller shell code does a cd command to that directory.