4

In MC I can copy the name of the current file from the list of files to the console pressing Ctrl+Enter.

Suppose I want several files to copy to console. Example: want to create *.zip with several files:

zip new_zip.zip a.txt b.txt c.txt 231202fkfo3f.txt 

I can select several files with Insert (or equiv. Ctrl+t). I want one shortcut to use after that for all those selected files names to go right to the console. Something like Ctrl+Enter.

What are the ways of doing it?

3

If you press Ctrl+x t, it will paste the names of all the files you've tagged with Ctrl+t or Insert to the command line.

1

A similar built-in solution is available from the F2 user menu. It is called "Do something on the tagged files", and runs the given command on the files one-by-one.

New commands could be added to this menu. It's a bit tricky solution, but it worked for me. (Subshell support is necessary.)

User menu config file is usually located at:

/etc/mc/mc.menu

My solution is based on "Do something on the tagged files". I've copied its lines and modified like this:

+ t t
p       Put selected files to history
    set %t
    while [ -n "$1" ]; do
      STR="$STR \\\"$1\\\""
      shift
    done
    bash -ic "history -s $STR" > /dev/null

First line means that it should be shown only if multiple files are selected. The second line contains a title and a shortcut inside user menu (p). After that comes a shell script which adds selected filenames to your history.

Add these lines to mc.menu and be aware of tabulation. First and second line has no tabulation, and the script is tabulated with TABs. Otherwise mc would not be able to parse it.

After that you should select some files and press F2. Press the newly added "Put selected files to history". Now they are added to the history, but it should be re-read to be used. Press Ctrl + O, and you should type history -r to command line. Finally you will find the selected filenames by pressing UP key.

An alternative solution could be used also. Perhaps it is easier to simply print the string to the terminal, and after that you can copy-paste it. Following script implements this:

+ t t
p       Print selected files to subshell
    set %t
    while [ -n "$1" ]; do
      STR="$STR \"$1\""
      shift
    done
    echo "$STR"
  • Thank you for your answer. Sorry, for a very late response... – Andrey Bzikadze Nov 4 '15 at 8:43

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.