Bash – wrong key sequence bindings with control+alt+space

bashgnome-terminalinputrc

I am trying to install some key sequence bindings but I have trouble.
My shell is bash, my terminal is gnome-terminal, and my system is Ubuntu 14.04 in graphic mode.
Edit : my keyboard is french azerty with the numeric pad and ctrl,fn,super,alt.

Edit: a bash guide, readline chapter

I want to add contol+alt+space, but this exact sequence does not work while similar other sequences work fine.
My goal is to run shell-expand-line readline but i tried upcase-word to compare.

–Let's analyze my goal's installation effect.

This is my ~/.inputrc added (ctrl+meta+space):

"\e\C- ": shell-expand-line

This is the new result of bind -p :

"\e\C-@": shell-expand-line

Of course I started a couple terminals, one before installation and one after every installation in order to compare thoroughly.

–Some experiments to ensure control+alt works in place of control+meta.

The system should emulate Meta with Alt and bash should emulate Meta with Escape, both using the byte '\033'. I tried both Alt and Esc to conclude it works fine. I tested some ctrl+meta+letter sequences to be sure.

By the way, the individual samples of Ctrl+Alt are simple : expanding an isolated tilde '~' (shell-expand-line) or changing case in random lowercase words (upcase-word) with ctrl+meta+e or ctrl+meta+v. Ctrl+meta+e is already binding to shell-expand-line so i just mixed the bindings with the useless ctrl+meta+v.

–Some more intricate observations…

I read '^@' illustrates 'NUL' character. Why this escape?

I tested xev and pressed ctrl+alt+space : the character reported is 'NUL' character.

I saw alt+space usually open the window menu of gnome-terminal while alt enables menus, of course without control key.

A conflict seems to come from the system, but I am a newbie. I just read most of the bash manual (especially readline chapter) and one forum advice about xev.

–Question

Is there more to say or to correct?
Why the sequences are rewritten?
How can I make my ctrl+alt+space work with bash and gnome-terminal ?

Edit : I found that '@' is transformed in 'NUL' because of a bitwise mask applied when escaping, but i do not see any reason why Alt+space gives 'NUL'.

Best Answer

Your gnome-terminal (actually the underlying vte-0.34) emits the wrong sequence for ctrl+Alt+space. The bug (https://bugzilla.gnome.org/show_bug.cgi?id=710349) was fixed in vte-0.36.

If you're not afraid of hacking a little bit and you're able to safely revert things in case of trouble, you can try to install vte-0.36 on your Ubuntu 14.04. You'll get many other fixes and improments along with this one. You might find a PPA or a package in Gnome3 staging, or compile it for yourself. Upgrading to this version of vte doesn't require touching any other software components. A complete restart of gnome-terminal is required (close all the windows).

Related Question