On 8/11/22 5:56 PM, Koichi Murase wrote:
Can we also change the behavior of TERM in a similar way with option 4? Currently, a temporal change of TERM clears keybindings of some keys (home, end, right, left, etc.) even when the temporal change does not survive across multiple calls of readline:
I finally got back to look at this, and I couldn't reproduce it. That was expected, since the arrow key binding functions are pretty careful not to overwrite an existing binding. Then I figured out what was going on.
$ bash-dev --norc $ echo "$TERM" screen.xterm-256color $ bind '"\e[1~": bell'
This unbinds the key sequence, since `bell' is not a valid bindable command name. I happened to be using `previous-history' and testing with "\eOH", which rebinds it instead.
$ bind -q beginning-of-line beginning-of-line can be invoked via "\C-a", "\eOH", "\e[H". $ TERM=dumb infocmp >dumb.ti
Bash does call rl_reset_terminal here when restoring the original value of TERM, and it attempts to bind the arrow keys and the other specials (Home, etc.). It finds that "\e[1~" is not bound, and binds it.
$ bind -q beginning-of-line beginning-of-line can be invoked via "\C-a", "\eOH", "\e[1~", "\e[H".
I think the "TERM=$TERM" idiom to reset the readline terminal settings without overwriting existing key bindings is useful enough to retain the current behavior. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/