Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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?

share|improve this question
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 5 '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 6 '11 at 3:13
up vote 3 down vote accepted

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.

share|improve this answer
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 6 '11 at 3:21
Ok, try it in xterm. Seems to work better. – taneli Jul 6 '11 at 7: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 6 '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 6 '11 at 20:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.