Linux – How to bind action to ctrl-f1 in screen

consolegnu-screenlinuxterminfo

I know I can do:

bindkey "...." action

where …. is what i get by typing ctrl-v and then ctrl-f1. but it looks bad, contains bad characters (^[), and is generally not cool.

when binding to f1, i can do:

bindkey -k k1 action

but I can't seem to find termcap capability name for ctrl-functionkey.

Where can I find it?

When I press ctrl-v ctrl-f1 on terminal I get:

^[O5P

these are 4 bytes, not 5:

=$ echo "^[O5P" | hexdump -C
00000000  1b 4f 35 50 0a                                    |.O5P.|

Best Answer

Unfortunately, screen apparently doesn't understand enough function keys to be able to process Ctrl-F1. At least I have not been able to get bindkey -k FF stuff "pressed Ctrl-F1" to work even after trying to define FF or kf25 using the termcap or terminfo commands in ~/.screenrc. I also tried "kf25" in the bindkey command. In either case, I get a "bindkey: unknown key" message.

Perhaps you or someone else will be able to get farther using the information here.

Otherwise, you can continue to use the ugly, uncool method. For onlookers, it's uncool to use hard-coded escape sequences instead of capability names because it won't be portable to other terminal types.

Capability names:

                    termcap        terminfo        xterm

F1                     k1            kf1           ^[OP

Shift-F1               F3            kf13          ^[O2P

Ctrl-F1                FF            kf25          ^[O5P

Ctrl-Shift-F1          FR            kf37          ^[O6P

Output from tput:

$ tput -Txterm kf25 | hd
00000000  1b 4f 35 50                                       |.O5P|