Why do `bind` and `.inputrc` behave differently?

14

2

I'm trying to do the right thing and put my key bindings into ~/.inputrc.

However, it turns out that I have to change

bind '"\e\C-j":"\e[1~quiet \e[4~\n"'

into

"\e\C-j": "\eOHquiet \eOF\n"

Now \eOH (nav-block-pos1 bound to beginning-of-line) and \eOF (nav-block-end bound to end-of-line) are themselves bindings in my configuration which I possibly cannot always rely on.

So the main question is why does binding to num-block-pos1 (\e[1~) and num-block-end (\e[4~) work with bind but not in my ~/.inputrc?


Edit:

The whole thing is getting even more complicated, now that I realized that \e\C-j only works for Gnome Terminial (or probably xterm as well, who knows...).

For my TTY it has to be

"\e\C-m": "\e[1~_quiet \e[4~\n"

So is it that various VTs have different implementations of how to interpret keys or what?

user173944

Posted 2012-12-04T06:54:54.990

Reputation:

This is documented in the GNU Readline User Interface manual, section 1.3.

The keymap option is used to set what kind of key representation is used in key bindings definitions.

Relevant information: http://superuser.com/questions/286781/readline-difference-between-vi-vi-move-vi-command-vi-insert-keymaps http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html#SEC9 https://wiki.archlinux.org/index.php/Readline

– Ярослав Рахматуллин – 2012-12-05T00:09:28.387

@ЯрославРахматуллин How exactly is this relevant to the difference in behavior between using bind and using inputrc for the actual binding. Should they not use the same settings? – None – 2012-12-05T06:15:32.193

Answers

2

Your terminal emulator can operate in one of two modes: application mode, and cursor mode (see http://homes.mpimf-heidelberg.mpg.de/%7Erohm/computing/mpimf/notes/terminal.html). It depends on what mode your particular application runs in that determines what escape sequence you need to send.

chepner

Posted 2012-12-04T06:54:54.990

Reputation: 5 645