I was recently confronted with a terminal emulator in an SSH client where Home key would not work by default in Bash.
After hours of investigation and reading about the major hairball that is the Linux terminal, one arrives at:
$ infocmp -L1 | grep -i hom cursor_home=\E[H, key_home=\EOH, key_shome=\E[1;2H, $ bind -p | grep -i beginning-of-line "\C-a": beginning-of-line "\M-OH": beginning-of-line "\M-[H": beginning-of-line
What is right and what is wrong between (i) the terminal emulator, (ii) the terminal settings, and (iii) the readline settings?
My question here is more general- I was wondering if there is any effort out there towards a bash/python script that could help diagnose such misconfigurations. Something like, e.g.:
$ diagnose-terminal Press 'Ctrl+Left`... Terminal emulator sent key code: [...] Terminal driver [xterm] expects key code(s): [...] Readline expects key code(s): [...] Mismatch! The culprit is: [...] Potential workarounds: 1. Add line [...] in config file [...] 2. ...
I am aware that the number of keys potentially misconfigured is large, but handling <20 most used control-related keys (involving arrows/home/end/backspace/del) would probably be extra useful to >95% of misconfigurations. Colors and cursor movement are another topic that could be probed this way, e.g.: use some escape codes, then prompt the user: "Do you see an X in red foreground between dashes that match the rest of the window".