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?
  • Create a bash script, not a function. I guess mc does not know about shell functions when launching editor. – Marki555 May 15 '15 at 20:25
  • It worked! Thank you, random person from the Internet! Your wisdom is much appreciated! :) – butla May 18 '15 at 22:08

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 ~/myEditor.sh
tmux new-window "vim $1"

export EDITOR=~/myEditor.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.