On Fri, Jun 17, 2011 at 8:13 PM, Dustin Kirkland
<dustin.kirkl...@gmail.com> wrote:
> Howdy!
>
> I'm trying to bind some Shift- and Alt- keys using the bind-key command.
>
> I've found the helpful S- and M- prefixes, which is quite handy and nice.
>
> It seems, though, that my terminal (gnome-terminal) sets TERM=xterm,
> but some key sequences (such as Shift-F2) differ slightly between
> gnome-terminal and xterm.
>
> In any case, if I check the actual keycode for something like Shift-F2
> using cat >/dev/null, I get:
> ^[O1;2Q
>
> Weird, yeah, I know.
>
> So, in screenrc, I could still bind to this sequence easily enough with:
>
> bindkey "^[O1;2Q" split
>
> I'd love to be able to do the same with tmux.  Something like:
> bind-key -n "^[O1;2Q" split-window -v
>
> Is there any way of accomplishing this behavior?

Actually, I have a trivial patch that solves this problem!  Hopefully
the maintainers will be so kind as to apply the attached patch to tmux
head!

   * xterm-keys.c:
     - add gnome-terminal's odd F1-F4 modified keycodes;
       enables binding Shift, Alt, Ctrl + F1-F4

--- tmux-1.3.orig/xterm-keys.c
+++ tmux-1.3/xterm-keys.c
@@ -36,8 +36,8 @@
  *
  * Rather than parsing them, just match against a table.
  *
- * There are two forms for F1-F4 (\\033O_P or \\033[1;_P). We accept either but
- * always output the latter (it comes first in the table).
+ * There are three forms for F1-F4 (\\033O_P and \\033O1;_P and \\033[1;_P).
+ * We accept any but always output the latter (it comes first in the table).
  */

 int    xterm_keys_match(const char *, const char *, size_t);
@@ -50,12 +50,16 @@ struct xterm_keys_entry {

 struct xterm_keys_entry xterm_keys_table[] = {
        { KEYC_F1,      "\033[1;_P" },
+       { KEYC_F1,      "\033O1;_P" },
        { KEYC_F1,      "\033O_P" },
        { KEYC_F2,      "\033[1;_Q" },
+       { KEYC_F2,      "\033O1;_Q" },
        { KEYC_F2,      "\033O_Q" },
        { KEYC_F3,      "\033[1;_R" },
+       { KEYC_F3,      "\033O1;_R" },
        { KEYC_F3,      "\033O_R" },
        { KEYC_F4,      "\033[1;_S" },
+       { KEYC_F4,      "\033O1;_S" },
        { KEYC_F4,      "\033O_S" },
        { KEYC_F5,      "\033[15;_~" },
        { KEYC_F6,      "\033[17;_~" },
--- tmux-1.3.orig/xterm-keys.c
+++ tmux-1.3/xterm-keys.c
@@ -36,8 +36,8 @@
  *
  * Rather than parsing them, just match against a table.
  *
- * There are two forms for F1-F4 (\\033O_P or \\033[1;_P). We accept either but
- * always output the latter (it comes first in the table).
+ * There are three forms for F1-F4 (\\033O_P and \\033O1;_P and \\033[1;_P).
+ * We accept any but always output the latter (it comes first in the table).
  */
 
 int	xterm_keys_match(const char *, const char *, size_t);
@@ -50,12 +50,16 @@ struct xterm_keys_entry {
 
 struct xterm_keys_entry xterm_keys_table[] = {
 	{ KEYC_F1,	"\033[1;_P" },
+	{ KEYC_F1,	"\033O1;_P" },
 	{ KEYC_F1,	"\033O_P" },
 	{ KEYC_F2,	"\033[1;_Q" },
+	{ KEYC_F2,	"\033O1;_Q" },
 	{ KEYC_F2,	"\033O_Q" },
 	{ KEYC_F3,	"\033[1;_R" },
+	{ KEYC_F3,	"\033O1;_R" },
 	{ KEYC_F3,	"\033O_R" },
 	{ KEYC_F4,	"\033[1;_S" },
+	{ KEYC_F4,	"\033O1;_S" },
 	{ KEYC_F4,	"\033O_S" },
 	{ KEYC_F5,	"\033[15;_~" },
 	{ KEYC_F6,	"\033[17;_~" },
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to