3

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?

Andrew
  • 16,315
  • 34
  • 73
  • 77

1 Answers1

4

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
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175