fix(shell): bind arrows directly for bash history search

The macro form `"\e[A": "\C-x\C-p\C-e"` ran history-search-backward then
end-of-line to mimic zsh's cursor-at-end. But history-search-* takes its
prefix from start-of-line to point, and `\C-e` moves point to the end, so
the next Up searched for the whole recalled line, found nothing, and left
Up/Down dead after one press. Bind arrows straight to the search functions;
pure readline has no history-search-end widget, so cursor lands at the
prefix boundary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-09 15:07:12 +02:00
parent 61de00137c
commit 7166d9196a
+11 -11
View File
@@ -6,15 +6,15 @@
$include /etc/inputrc $include /etc/inputrc
# zsh-style prefix history search: type a prefix, Up/Down walk matching # zsh-style prefix history search: type a prefix, Up/Down walk matching
# history entries with cursor at END of line. Empty prefix = previous/next. # history entries. Empty prefix = previous/next.
# #
# Readline's history-search-* leaves the cursor at the prefix boundary, not the # Bind arrows straight to the search functions. Do NOT wrap in a macro that
# end (that's why zsh needs its history-search-end widget). There's no built-in # appends end-of-line (\C-e) to mimic zsh's cursor-at-end: \C-e moves point to
# "search then go to end", so: bind the real functions to throwaway keys, then # the line end, and history-search-* takes its prefix from start-of-line to
# bind the arrows to a MACRO that runs the search and then end-of-line (\C-e). # point -- so the next press searches for the whole recalled line, finds
"\C-x\C-p": history-search-backward # nothing, and Up/Down go dead. Pure readline has no history-search-end widget;
"\C-x\C-n": history-search-forward # cursor lands at the prefix boundary, which is readline's intended behavior.
"\e[A": "\C-x\C-p\C-e" "\e[A": history-search-backward
"\e[B": "\C-x\C-n\C-e" "\e[B": history-search-forward
"\eOA": "\C-x\C-p\C-e" "\eOA": history-search-backward
"\eOB": "\C-x\C-n\C-e" "\eOB": history-search-forward