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"