2

I want to use the terminal multiplexer byobu, so I need to use the function keys (F1-F12). However, I am accessing a remote machine via SSH, so I need to send function keys over SSH. (I'm running Ubuntu 10.04.4 LTS.)

This answer to this question explains that "Terminals only understand characters, not keys," so I need to use escape sequences to send function keys over SSH. But I'm not sure what are the control characters for F1-F12 on my particular platform. So, I used the command suggested in the answer:

for x in {1..12}; do echo -n "F$x "; tput kf$x | cat -A; echo; done

I get this output:

F1 ^[OP
F2 ^[OQ
F3 ^[OR
F4 ^[OS
F5 ^[Ot
F6 ^[Ou
F7 ^[Ov
F8 ^[Ol
F9 ^[Ow
F10 ^[Ox
F11 
F12 

This says -- or so it would seem -- that F11 and F12 have no escape sequences associated with them. Have they been stolen by another program, and if so, how can I get them back?

3

tput tells you what the terminal advertises as its function keys. Terminals often don't advertise all the function keys and keychords that they support. To see what escape sequences the terminal actually sends, use the Ctrl+V method mentioned in that same answer: press Ctrl+V in a terminal application that doesn't rebind the Ctrl+V key (such as the shell). Ctrl+V inserts the next character (which will be the escape character) literally, and you'll be able to see the rest of the sequence, which consists of ordinary characters.

If Byobu doesn't detect your terminal's escape sequences correctly, copy the corresponding definitions from /usr/share/byobu/keybindings/f-keys.screen to ~/.byobu/.screenrc and modify the escape sequences to match your terminal. For example, if Ctrl+V F12 inserts ^[[24~, add

bindkey "^[[24~" process x
  • Thanks. What does the x stand for? – Andrew Jun 26 '15 at 14:28
  • @Andrew Register x, which is set to the escape sequence at the top of f-keys.screen. Thus binding a key to process x effectively makes that key a prefix for screen commands. – Gilles Jun 26 '15 at 14:43
  • By any chance, do you have time to chat for a minute? I'm having difficulty knowing what to do. – Andrew Jun 26 '15 at 14:47
  • @Andrew I do now. Even if I'm not around, there's often someone in the chatroom. – Gilles Jun 26 '15 at 20:53

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.