[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Request]: Make `history-search` key bindings slightly more user-friendl

From: Rashil Gandhi
Subject: [Request]: Make `history-search` key bindings slightly more user-friendly
Date: Wed, 7 Jul 2021 18:16:43 +0000 (UTC)

Configuration Information [Automatically generated, do not change]:Machine: 
x86_64OS: linux-gnuCompiler: gccCompilation CFLAGS: -g -O2 
-fdebug-prefix-map=/build/bash-a6qmCk/bash-5.0=. -fstack-protector-strong 
-Wformat -Werror=format-security -Wall -Wno-parentheses 
-Wno-format-securityuname output: Linux azureubuntu2 5.4.0-1046-azure 
#48-Ubuntu SMP Tue Apr 13 07:18:42 UTC 2021 x86_64 x86_64 x86_64 
GNU/LinuxMachine Type: x86_64-pc-linux-gnu
Bash Version: 5.0Patch Level: 17Release Status: release
Description:        Many users bind the 'Up' and 'Down' keys to 
`history-search-backward` and `history-search-forward` to allow them to search 
through the history based on what is currently present on the commandline. 
However, if a user is not able to find a desirable history entry, then they 
have to inevitably delete the entire text following the current cursor 
position.        Ideally, if a user presses the 'Down' key the same number of 
times as they press the 'Up' key, the commandline text should revert back to 
the state it was in, before any of the searches were started. The reproduction 
steps below show that this is not currently the case.
Repeat-By:        Minimal reproducible steps. Make sure the history file 
contains at least two entries that start with the same string, for example 
"sudo".        1. Start bash with `bash --noprofile --norc`        2. Run the 
command `bind '"\e[A": history-search-backward'`        3. Run the command 
`bind '"\e[B": history-search-forward'`        4. Type "sudo", and now press 
the 'Up' key some fixed number of times (say x). Bash will show history entries 
starting with "sudo" in decreasing chronological order.        5. Now press 
'Down' key the same number of times (x). After seeing history entries starting 
with "sudo" in increasing chronological order, you'll notice that the 
commandline doesn't get cleared. It stays the same as the last found history 
entry.        6. Now if you didn't find what you were looking for in the 
history search, you will have to clear the added text using 'Ctrl+K' (emacs 
mode).        7. This is slightly cumbersome. Note that some other shells, 
notably zsh and pwsh, do not exhibit this behavior (they restore the pre-search 
state if 'Down' and 'Up' keys are pressed the same number of times.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]