As a long-time lurker on Stack Exchange, I've found answers to most of my problems without needing to so much as make an account. But today I'm completely stumped with this issue, so I'm reaching out for help.

I've recently discovered Byobu, a frontend for Tmux which uses the Fn keys for common tasks. It's a real blessing for multitasking through SSH to a remote linux server from the Windows PC I have to use at work.

Currently, I'm using gnome-terminal through an SSH tunnel because both PuTTY and MinTTY (the default terminal with Cygwin) seem to send the wrong key codes for the function keys.

I was wondering if there was a way to re-map certain escape codes so at least one of my windows-based terminals can work properly with Tmux. (I guess I could just learn the Ctrl+b/Ctrl+a key combinations, but performing a key combination followed by another key doesn't really strike me as ergonomic.)

In PuTTY, setting Terminal>Keyboard>"The Function keys and keypad" to "XtermR6" seems to push the correct escape sequences for the Fn keys normally, but the Shift and Ctrl modifiers are broken. I can use vim to figure out what codes are being sent by each terminal. Meanwhile, I think I might have looked up the combination tmux is looking for in its source code, but I'm not sure:

Key              Tmux Expects    Gnome-Terminal   PuTTY    MinTTY
Normal F3:                       ^[0R             ^[0R     ^[0R
Ctrl+F3          "\033[13^"      ^[01;5R          ^[0R     ^[[1;5R
Shift+F3         "\033[13$"      ^[01;2R          ^[[25~   ^[[1;2R
Ctrl+Shift+F3    "\033[13@"      ^[01;6R          ^[[25~   ^[[1;6R

So far, MinTTY looks like the best candidate, but it gives me an entirely different problem where byobu ignores 95% of Fn key presses, passing them directly to the client application. I can run cat -v and spam the F2 (new window) key, and it'll print out "^[0Q" four or five times before suddenly spawning a new window.

If anyone has advice, it would be welcome. Most of the stuff I found on the internet said to change the terminal type, but I've tried literally every combination each of the two programs offer.


  • 3
    The sequences you list for tmux are just the rxvt-style modified-key sequences that it recognizes. tmux also recognizes the (unmodified) sequence specified by TERM’s terminfo entry (e.g. kf3 from whatever TERM you are using when attaching to tmux) as well as the xterm-style modified-key sequences from xterm-keys.c. So, the sequences that you report from Gnome-Terminal and MinTTY (although the escape+zeros in your sequences should be escape+letter-ohs (a.k.a. SS3) should be recognized by tmux, but it will only pass them through if you have the xterm-keys option enabled. – Chris Johnsen Sep 29 '13 at 3:54

I have had a similar trouble with PuTTY and screen (I couldn't use Ctrl modifier). The solution I've found was KiTTY - the fork of PuTTY, which is better maintained (last update from 2015/06/02 22:02). My problem with Ctrl key has gone.

By default, Kitty uses Fn keys for its own shortcuts, but you can configure it other way, so Fn keypresses will be sent to your application.

|improve this answer|||||

I use BYOBU myself in the same manner. I just use cygwin these days as F2,3,4 and F6 just work for me and those are the only ones I'm really concerned about. However, when I was using putty, I had the most success with 'The Function keys and keypad' setting set to emulate VT100+

|improve this answer|||||

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.