Page 1 of 1

Make Midnight Commander Exit to Its Current Directory

Posted: Mon Sep 05, 2022 5:02 pm
by Caldor

It has annoyed me for a long time how Midnight Commander does not by default just exist to the directory you just moved to. That is often why I use Norton Commander clones of some kind, to browse directories fast and then obviously to also help do filemanagement overall.

But browsing to the folder I want to run commands in, quit Midnight Commander and then be in the folder where I launched MC from is pretty annoying.

So here is how to enable that feature.

Run the command

Code: Select all

nano ~/.profile

Then write the line (or copy it if you are using Putty):

Code: Select all

alias mc='source /usr/libexec/mc/mc-wrapper.sh'

Restart Putty, or exit the shell and reload it on the MiSTer to have it use these new settings and it should now exit to the active folder :)

I hope this might be made default on the MiSTer. But... once you know how I guess its easy enough to change.


Re: Make Midnight Commander Exit to Its Current Directory

Posted: Thu Sep 08, 2022 3:13 pm
by Akuma
or dont run the wrapper at all

Code: Select all

alias mc='f(){ local f=$(mktemp -u);$(which mc) -P $f "$@";cd $(cat $f);rm $f;};f'
If the -P option would just return the working directory on exit, alias mc='cd $(mc -P "$@")' would have been enough.

EDIT: almost forgot, I don't want it to be the default.

Re: Make Midnight Commander Exit to Its Current Directory

Posted: Fri Sep 09, 2022 8:20 pm
by Caldor
The wrapper is there by default anyway. But I did suspect it could be done without the wrapper.

Re: Make Midnight Commander Exit to Its Current Directory

Posted: Sat Sep 10, 2022 1:11 pm
by Akuma
Caldor wrote: Fri Sep 09, 2022 8:20 pm The wrapper is there by default anyway. But I did suspect it could be done without the wrapper.
I saw, what a weird solution :lol: