2

I would like to have the OLD behavior of mc, when exiting meant that I will be at the directory where I was before I started mc. I'm only a user on the system, I suspect it's a Suse Linux. The which mc command outputs /usr/bin/mc which is an ELF executable file. The relevant part of my process tree looks like this after I started Midnight Commander:

root     20974  \_ sshd: user [priv]
user     20982  |   \_ sshd: user@pts/5
user     20985  |       \_ -bash
user     32211  |           \_ /usr/bin/mc -P /tmp/mc-user/mc.pwd.20985
user     32213  |               \_ bash -rcfile .bashrc

My suspicion is that bash (I think due to some configuration that I'm not aware of) reads /tmp/mc-user/mc.pwd.20985 after mc exited and then changes its current directory to that directory.

Where is this configuration? How can I disable it?

Update: @hlovdal inspired inquiry

user@node01:/tmp> which mc
/usr/bin/mc
user@node01:/tmp> type mc
mc is a function
mc ()
{
    . /usr/share/mc/mc-wrapper.sh
}

Which means that on my system mc is a bash function, so I will need to search the location of this definition or somehow unset it. I placed this addition to help later visitors.

  • 1
    Should you only want this behavior occasionally, and have it change the directory most of the time, you could press Shift+F10 to quit. That key combination causes mc not to change the parent shell's directory, even if you have the alias or function in place. – egmont Sep 22 '15 at 20:07
1

On my system I have

$ type mc
mc is aliased to `. /usr/libexec/mc/mc-wrapper.sh'
$ cat /usr/libexec/mc/mc-wrapper.sh
MC_USER=`id | sed 's/[^(]*(//;s/).*//'`
MC_PWD_FILE="${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$"
/usr/bin/mc -P "$MC_PWD_FILE" "$@"

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

rm -f "$MC_PWD_FILE"
unset MC_PWD_FILE
$

which seems to match your behaviour, so to disable changing directory after exit just disable the mc alias.

| improve this answer | |
  • So in this case the answer would be unalias mc in ~/.bash_profile or some similar place. For my case it would be unset mc. Thanks for the idea! I had no clue that type exists. – Notinlist Nov 28 '14 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.