Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I change small scripts in mcedit, I sometimes want to "test" them immediately. Switching to another terminal/virtual console is quite annoying, so ther must be a better way. Actually, not every script is marked as executable, altough in most cases they at least have shebang line.

Is it possible to execute currently opened script from within mcedit? If so, can I pass parameters?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You can edit your User menu file to add/modify key bindings. See here.

As I didn't have a ~/.mc/cedit/menu file, I copied it from /etc/mc/cedit.menu

If you want to run scripts marked as executable and pass parameters you'd add something like

r       run
        PARAM=%{parametes}
        %f $PARAM

to your ~/.mc/cedit/menu file.

In this example r will be the key for running scripts once you are in the User menu (F11), change r to whatever you like. %f is a macro for the open file's filename.

For shell scripts not marked as executables you'd have change the last line in the example above to read

        sh %f $PARAM

There are hints for syntax and lots of templates in the menu file. Also there are filters for filenames extensions, see those templates to have some examples.

share|improve this answer
    
menu entry appears. Instead of the saved script, it seems to run a copy in /tmp. Unfortunately the output isn't provided: no logmessages, no interactivity with the user... –  mbx Jul 17 '11 at 11:56
    
A simple script with pwd in it shows the right path (ie. not /tmp). I didn't have problems with interactivity. To see the output try Ctrl+o, or see the c/c++ language template in your menu file (echo -ne "...Press any key to..."; read). Remember to pass at least one parameter if you asked for them (as in my example above). –  user90485 Jul 17 '11 at 19:21

I don't know if you can do that from within mcedit, but if you run mcedit as the internal editor of midnight commander you hit Ctrl+o to go back and forth to the command line with no need for another terminal.

share|improve this answer
    
that's what I did for quite a while - its annoying. I could use screen as well, but that's not what I want. –  mbx Jul 16 '11 at 15:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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