Search code examples
mc

Invoke internal midnight commander cd via shell script


I'm trying to use a shell script to have mc cd into some directories, be them virtualfs directories (e.g. ftp, ssh) or local directories. How should I do that?


Solution

  • mc allows you only to launch a new instance with requested path open in one of the panels. For local files you can just provide the directory as argument:

    mc somedirectory
    

    If you prepend sh:// you can open remote directories on other machines as well:

    mc sh://user@host/somedirectory
    

    This works from the command line as well as from shell scripts.