Custom function as "edit" in Midnight Commander

by user2252728   Last Updated May 15, 2015 11:14 AM

The problem

I'm using tmux and I want MC to open files for editing in another tmux window, so that I can keep browsing files while editing.

What I've tried

MC checks if EDITOR variable is set and then interprets it as a program for editing, so if I do export EDITOR=vim then MC will use vim to open files.

I've tried to build on that:

function foo () { tmux new-window "vim $1"; }
export EDITOR=foo

If I do $EDITOR some_file then I get the file open in vim in another tmux windows - exactly what I wanted.

Sadly, when I try to edit in MC it goes blank for a second and then returns to normal MC window. MC doesn't seem to keep any logs and I don't get any error message.

The question(s)

  • Do you know what I'm doing wrong?
  • Do you have a usable workaround for what I want?
  • Should I create a feature request/bug for MC?

Answers 1

You are defining a shell function, which is unknown for mc when it is trying to start the editor.

The correct way is to create a bash script, not a function. Then set EDITOR value to it, for example:

$ cat ~/
tmux new-window "vim $1"

export EDITOR=~/
May 19, 2015 07:57 AM

Related Questions

Midnight Commander rewrites the ini file

Updated February 27, 2017 10:01 AM

Sizes of the panels in Midnight Commander

Updated April 30, 2017 17:01 PM

How to change UI language for midnight commander Mac

Updated October 02, 2017 20:01 PM

More visible space in mc for command lines

Updated December 16, 2017 11:01 AM