How do I make the F-keys work in byobu, for midnight commander (mc), htop, etc?

26,389

Solution 1

You can easily toggle on/off the use of the F-keys inside of Byobu (tmux) by pressing either:

  • shift-F12 (in tmux)

  • ctrl-a-! (in screen)

Full disclosure: I'm the author and maintainer of Byobu.

Solution 2

On midnight commander to trigger for example the F2 key:

  • Press Alt+2 (simultaneously)
  • Press ESC, 2 (one after the other).

Which is more convenient than switching using:

  • Shift+F12 (in tmux, default on byobu)

  • Ctrl+A+! (in screen)

Solution 3

Hah, a man after my own heart :)

Short answer: add my ppa (ppa:izx/private) and update byobu (or manually install the deb). Byobu will default to screen as the backend with F-key behavior restored to old 4.x style.

Long answer: Use byobu-select-backend to switch to screen if you haven't already, and add line $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen.disable after the line $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen in /usr/share/byobu/keybindings/common.

Entire patch:

+++ byobu-5.17/usr/share/byobu/keybindings/common
@@ -1 +1,3 @@
 source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen
+source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen.disable
+
--- byobu-5.17.orig/etc/byobu/backend
+++ byobu-5.17/etc/byobu/backend
@@ -1,4 +1,4 @@
 # BYOBU_BACKEND can currently be "screen" or "tmux"
 # Override this on a per-user basis by editing "$BYOBU_CONFIG_DIR/backend"
 # or by launching either "byobu-screen" or "byobu-tmux" instead of "byobu".
-#BYOBU_BACKEND="tmux"
+BYOBU_BACKEND="screen"
Share:
26,389

Related videos on Youtube

Jorge Castro
Author by

Jorge Castro

Updated on September 18, 2022

Comments

  • Jorge Castro
    Jorge Castro almost 2 years

    I use byobu with the tmux backend on my 12.04 server. I'd like to use the midnight commander shortcut keys with it, but the F keys don't work.

    I've seen some posts on the issues here:

    but they are out of date and don't seem to work for newer versions of byobu. How can I either work around this or use MC in a way that works better?

    • jrg
      jrg about 12 years
      Same goes for htop and others.
  • jrg
    jrg about 12 years
    But what if we wanted to keep it with tmux?
  • ish
    ish about 12 years
    @jrg: I'm not that familiar with tmux, sorry -- I tried the new byobu but after this now-fixed bug, switched back to the screen-backend because I'm used to it and happy with it, whatever its limitations.
  • Pykler
    Pykler over 9 years
    How do you make it off by default, and turn it on as needed? @Dustin-Kirkland
  • Admin
    Admin over 9 years
    @Dustin The second one works perfectly for me. However, after toggling F-keys on and off, I have to confirm the escape sequence again using F9 before I can toggle F-keys on again.
  • gerlos
    gerlos over 9 years
    This is useful mostly when you use MC inside byobu on Mac OS X, since some F-keys are already used by the system. I find myself using ESC, 9 quite often.
  • QkiZ
    QkiZ over 9 years
    not working :P any of this key bindings
  • David Tod
    David Tod over 9 years
    Dustin, while that works fine for most keys, Shift-Fx seems to be completely ignored by mc when running in Byobu (with Tmux here). I can understand that for shift-F12 (for obvious reasons) – but what do I miss for e.g. Shift-F3 or Shift-F4 (which I frequently need)?
  • David Tod
    David Tod over 9 years
    Any way to extend that to Shift-Fx? Even with Byobu keybindings disabled, Shift-Fx seem to be "blind" (don't work). Tried Esc--Shift-4, no effect.
  • Andrea Borga
    Andrea Borga over 8 years
    @Dustin: it would be nice to add those short cuts also in the shift-F1 documentation! I was looking for this for a while! Thanks!
  • Leo
    Leo over 6 years
    You could also use byobu-keybindings command, equivalent to those key combinations.
  • Kangarooo
    Kangarooo about 4 years
    @dustin-kirkland can you put in help.ubuntu.com/community/Byobu how to make it work in Putty? CTRL+F2 doesnt work in putty. Also Launchpad does not know where byobu tracks support requests. answers.launchpad.net/byobu BUG REPORT bugs.launchpad.net/byobu/+bug/1882373
  • Csabi Vidó
    Csabi Vidó over 3 years
    If you are on a Chromebook and you think you only have F1 through F10, you should know that you can use the number row with the super key (search) to enter F-keys. Now you can enter F-keys F11 and F12.