-1

I like Midnight Commander. Might have to do with starting with DOS machines in the early 90s in Russia, but now I just really like the integration of the command line with a two-panel file list. And a key feature is that Ctrl+Enter copies the name of the currently selected file or directory into the command line, without starting it.

Unfortunately, on Fedora (26 and 27) this fails in Konsole and, apparemntly, in all other X-based terminals too. It does work in the virtual console I get py pressing Ctrl-Alt-F3.

On OpenSuse Leap (42.1, 42.2, 42.3) the Ctrl+Enter functionality works perfectly. And I could not work out any difference. (I use KDE on both, which, as far as I understand, means that on Fedora I have X.org, not Wayland).

How can I make Ctrl+Enter work on Fedora? Alternatively if this is impossible, is there a way to reassign the very useful functionality to some other key combination in Midnight Commander?

(I would also consider alternatives to Midnight Commander itself, but on;y those running in a console window, and it seems there aren't any. I don't need a graphical two-panel file manager, as I use MC to assist in crafting commands quickly).

3

tl;dr: Get used to Alt+Enter (a.k.a. ESC followed by Enter) instead.

Ctrl+Enter generates the exact same sequence in terminal emulators as Enter, so there's no way for an app to distinguish these two. Well, no way by looking at the input stream it receives from the terminal emulator.

mc has an interesting feature called "X11 support". It does not only look at the bytes it receives from the terminal emulator, but (if this support is compiled in, and if X11 connection is available runtime) queries the X11 server for the state of the modifier keys.

So basically it goes like: "Wow, I received an Enter from the terminal emulator. Hey, X11 server, is Ctrl pressed now?"

There are multiple ways this might not work for you.

Fedora's mc may have been compiled without X11 support, I don't know. Check the output of mc --version, does it contain "With support for X11 events"?

su, sudo, screen, tmux, ssh or similar tools can also break this functionality in case the X11 connection isn't available inside them (e.g. credentials not properly set up / forwarded by su or sudo; screen or tmux being detached and reattached from another X server; display not forwarded by ssh).

The feature doesn't work on Wayland either. I suspect it cannot be implemented in Wayland due to its security model, or at least not without some plugin/extension to some core Wayland component. But even if the state of modifiers could be detected, it's not yet done in mc.

  • Thanks! Alt+Enter works and that's enough for me right now. – Mikhail Ramendik Jan 3 '18 at 14:29
0

We still don't have a replacement for Ctrl-Shift-Enter in MC on Wayland.

So lacking one, I suggest to use Alt-m instead. And because Enter is the same as Ctrl-m, this means we would have:

  • Alt-Ctrl-m, ie. Alt-Enter, for Paste file name.
  • Alt-m for Paste full path name.

Note that by default Alt-m is assigned to the Mail action, so we will lose that mapping but it looks like a winning deal.

Here a (replayable) script to apply this new mapping in the default keymap (file /etc/mc/mc.keymap):

sudo sed -ri '/PutCurrentFullSelected/s/=( alt-m;)?/= alt-m;/' /etc/mc/mc.default.keymap
sudo sed -ri '/Mail = alt-m/s/= alt-m/=/;' /etc/mc/mc.default.keymap

Or the patch:

diff --git a/mc/mc.default.keymap b/mc/mc.default.keymap
--- a/mc/mc.default.keymap
+++ b/mc/mc.default.keymap
@@ -33,7 +33,7 @@ Shell = ctrl-o
 PutCurrentPath = alt-a
 PutOtherPath = alt-shift-a
 PutCurrentSelected = alt-enter; ctrl-enter
-PutCurrentFullSelected = ctrl-shift-enter
+PutCurrentFullSelected = alt-m; ctrl-shift-enter
 ViewFiltered = alt-exclamation
 Select = kpplus
 Unselect = kpminus
@@ -313,7 +313,7 @@ Help = f1
 Refresh = ctrl-l
 Goto = alt-l
 Sort = alt-t
-Mail = alt-m
+Mail =
 ParagraphFormat = alt-p
 MatchBracket = alt-b
 ExternalCommand = alt-u

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.