Make Midnight Commander Exit to Its Current Directory

Kernel, Main, Utilities & Applications, Miscellaneous Devices.
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Make Midnight Commander Exit to Its Current Directory

Unread post 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.

Akuma
Posts: 138
Joined: Sat Dec 11, 2021 9:50 pm
Has thanked: 24 times
Been thanked: 46 times

Re: Make Midnight Commander Exit to Its Current Directory

Unread post 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.
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Make Midnight Commander Exit to Its Current Directory

Unread post by Caldor »

The wrapper is there by default anyway. But I did suspect it could be done without the wrapper.
Akuma
Posts: 138
Joined: Sat Dec 11, 2021 9:50 pm
Has thanked: 24 times
Been thanked: 46 times

Re: Make Midnight Commander Exit to Its Current Directory

Unread post 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:
Post Reply