Bash – Fix Shift+Arrow Keys Producing A,B,C,D

arrow keysbash

When using the bash shell, I tried to use Shift+LEFT to highlight and copy the command I typed in (rather then using the mouse). However, I got a lot of C's instead. I later realized that Shift+UP makes A, Shift+DOWN makes B, and Shift+RIGHT also makes D.

Why does this happen?

I think it is from the raw keystroke data (^[[A,^[[B,^[[C, and ^[[D), but it is just a capital letter (no ^[[ at the beginning).

Best Answer

Pressing Ctrl+V will cause the next keypress to be input literally. For Shift+ this results in "^[[1;2A". The terminal driver consumes the "^[[1;2" as an invalid escape sequence, leaving only the "A".

Related Question