Search code examples
macosmc

How to make Midnight Commander exit to its current directory on MAC


I am using Midnight Commander on MacOS (Sonoma 14.3) and I love it. The only problem that I have is that I am not able to exit to the current directory, despite trying to do what is said in this question. I have the alias in my .bash_profile in my home directory (/Users/alrod). If I type 'mc' I start Midnight Commander (which means the alias is working), but it never exits to the current directory. Here is the line in my .bash_profile. I also tried to use the other script provided with no luck (the commented line).

alias mc=". /usr/local/opt/midnight-commander/libexec/mc/mc-wrapper.sh"
# alias mc=". /usr/local/opt/midnight-commander/libexec/mc/mc-wrapper.csh"

Does someone on MacOS have this feature working? Could you please share how you did it?


Solution

  • echo $SHELL shows that your shell is /bin/zsh so it doesn't read .bash_profile. Copy your alias to ~/.zshrc file; if the file doesn't exist create it — it's a simple text file the same way ~/.bash_profile is (~ means $HOME — your home/profile directory).

    The simplest solution is

    echo 'alias mc=". /usr/local/opt/midnight-commander/libexec/mc/mc-wrapper.sh"' >> ~/.zshrc
    

    and then reread the file into all opened terminals with the command . ~/.zshrc or restart all your terminals/shells.

    PS. See the list of initialization files for zsh in the docs at https://zsh.sourceforge.io/Intro/intro_3.html