I have shift-tab bound to shell-expand-line in my .inputrc. However, I want shift-tab to also insert a space character after doing the shell-expand-line. How can I do this?

This is what my .inputrc currently looks like:

"^[[Z": shell-expand-line

The ^[[Z is what shift-tab looks like. I've tried the following possibilities, but they don't work:

"^[[Z": "shell-expand-line "
"^[[Z": shell-expand-line " "
"^[[Z": shell-expand-line" "

1 Answer 1


Bindings have to specify either a builtin command, or a text macro (a string that will be inserted), not a combination of the two. But the macro can contain another bound key sequence that does specify a command, plus any characters you want to insert. As shell-expand-line is already bound to C-M-e in bash, all you need is

"\e[Z": "\e\C-e "

If you wanted to use a command that didn't already have such a binding, you could create an intermediate binding, such as

"\C-\xff": shell-expand-line
"\e[Z": "\C-\xff "
  • \C-E is \C-e -- in the terminal, there's no difference between ctrl and ctrl-shift. Better use \xff instead.
    – user313992
    Oct 25, 2019 at 14:42
  • additionally for the particular case asked in the OP, there's no need for an intermediate key because shell-expand-line is by default C-M-e
    – xdavidliu
    Oct 25, 2019 at 14:46
  • @pizdelect Thanks, I hadn't tested that properly. I made it \C-\xff as just \xff caused other side-effects.
    – JigglyNaga
    Oct 25, 2019 at 14:54
  • @xdavidliu Good point, I didn't notice the default binding. I've added the one-line solution, but leaving the "intermediate" method as it's useful for the more general case.
    – JigglyNaga
    Oct 25, 2019 at 14:55
  • for some reason "\C-\M-e " didn't work for me; I had to use "\e-^E ", where the ^E is a literal C-e character inserted using emacs...
    – xdavidliu
    Oct 25, 2019 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .