I have some Gentoo systems that have mc installed, but it’s default behaviour is to exit to the directory it was run from. I wanted to change this, because most of the time I’m using it to navigate the filesystem and then after exiting mc I want to be dropped to the directory I have navigated to. To achieve this you can issue this little script which will force Midnight Commander to exit in this directory.
mkdir /etc/profile.d cat > /etc/profile.d/mc-chdir.sh << EOF #!/bin/sh if [ /usr/libexec/mc/mc.sh ]; then . /usr/libexec/mc/mc.sh fi EOF chmod 775 /etc/profile.d/mc-chdir.sh