3

I've been trying to bind a shortcut to switching to a specific window in Byobu, but I'm not having success. I wanted to bind Alt-(screen's number) but it's not working. I think I'm using the wrong ASCII codes.

Take Alt + 1 for example: I've tried using the lines

bind \078 select 1

and

bind \78 select 1

to both ~/.screeenrc and ~/.config/byobu/keybindings, but neither worked.

Am I using the wrong code, or is there no standard ASCII code for Alt + 1?

Pablo Bianchi
  • 17,552
Malabarba
  • 10,576
  • I'm not sure about making new bindings, but just to check: do you know you can do ctrl+a then hit the number for the window you want? – maco Jul 05 '11 at 15:09
  • @maco Yes, I just like how convenient M-1 feels for me. Besides, I removed C-a because I'm just too used to emacs shortcuts, and I kept hitting it while trying to move back. I'm still considering reactivating it, but I do a lot of writing on emacs and I don't think my brain can handle both at the same time. =) – Malabarba Jul 06 '11 at 03:13

1 Answers1

3

First check what octal code is generated when you press alt+1, type in the following:

echo -n C-qM-1 | od -t o1

(If that makes no sense to you: instead of writing C-q, press ctrl-q and for M-1 substitute alt-1, and some character should show up). For example, I have Finnish keyboard and en_US.UTF-8 locale and get:

0000000 302 261

so I put in my .screenrc:

bindkey "\302\261" select 1

Note: by default this will not work in a gnome-terminal at all, since alt+number changes the tab and screen (or bash) doesn't get a chance to see the keypress. Go to Edit > Keyboards Shortcuts... to change the shortcuts.

taneli
  • 2,629
  • This method for inserting M-1 isn't working for me. If I press C-q the system just ignores it, and anything I press later just gets interpreted regularly (M-1 gives me an arg: 1). I thought it my be the gnome-terminal, but I switched to the console (Ctrl-Alt-F2) and the same thing happened. – Malabarba Jul 06 '11 at 03:21
  • Ok, try it in xterm. Seems to work better. – taneli Jul 06 '11 at 07:27
  • Thanks, it works. Using the code the shortcut now works, but only if byobu is running in xterm, otherwise it just gives me that (arg: 1). But I'll look into it later, thanks for the help. – Malabarba Jul 06 '11 at 16:21
  • You can unbind all of the alt+n keymappings with the bash builtin bind, like this: for i in $(seq 0 9) ; do bind -r "\e${i}" ; done – taneli Jul 06 '11 at 20:03