Midnight Commander - exit in current directory

Hi,
iI've searched many pages with some solutions but for me they didn't work.
Is there any option to exit midnight-commander at the directory it was working?
For example, run mc at /root directory and in mc navigate to /usr/share, when exiting mc i wannaI want to be in /usr/share path.

Cheers
 
You should source /usr/local/libexec/mc/mc.{sh,csh} (depends on the used shell) - as SirDice wrote above.
You should add a line to your ~/.profile (if you use sh, or ~/.bashrc if you use bash):
Code:
source /usr/local/libexec/mc/mc.sh
And if you use tcsh you should use ~/.cshrc.
 
uzsolt gave you the real solution. This is an alternative using the hot-key Ctrl+O, it hides the panels (full screen shell) and the current directory is the one the selected panel. Type Ctrl+O again to go back.
 
1- Change shell:
pw usermod root -s /bin/sh


2- Add this to /root/.shrc:
alias mcedit='mcedit -u'
alias mc='. /usr/local/libexec/mc/mc-wrapper.sh'


3- Content of file /usr/local/libexec/mc/mc-wrapper.sh:

MC_USER=`whoami`
rnd=$(openssl rand -base64 6)
MC_PWD_FILE="/tmp/mc-${MC_USER}-${rnd}"

/usr/local/bin/mc -u -P "$MC_PWD_FILE" "$@"


if test -r "$MC_PWD_FILE"; then
MC_PWD="`cat "$MC_PWD_FILE"`"
if test -n "$MC_PWD" && test "$MC_PWD" != "$PWD" && test -d "$MC_PWD"; then
cd "$MC_PWD"
fi
unset MC_PWD
fi

rm -f "$MC_PWD_FILE"

unset MC_PWD_FILE
unset MC_USER
 
Back
Top