0

I'm trying to bind Control-Tab to a shell function in Bash.

I've tried the following things in my .bashrc:

bind -m vi-insert -x '"\C-\t": some_user_function'
bind -m vi-insert -x '"\C-TAB": some_user_function'
bind -m vi-insert -x '"\C-\TAB": some_user_function'

But neither work. I couldn't find anything in help bind and man bash either.

However bind -m vi-insert -x '"\C-x": some_user_function' work so it is clearly a problem with telling bind to recognize the tab key somehow.

3

short: terminals don't do that.

long: bash runs in a terminal. While some provide an escape sequence for shifttab, you're unlikely to find one doing this for controltab unless you specially configure it yourself (using features of a specific terminal emulator).

  • Oh, I knew about Shift-Tab and thought that Control-Tab will work because the Readline Initialization and Readline Key Bindings sections of man bash suggested that they understand TAB and \t - so I thought that I can combine that with the control key. – Mateusz Piotrowski Mar 24 '17 at 15:05
  • no - it's already a control-key, and only terminals that allow configuring X events (or Windows events...) will be able to do this. – Thomas Dickey Mar 24 '17 at 15:07
  • Thanks, I didn't know about it. It makes perfect sense now. – Mateusz Piotrowski Mar 24 '17 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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