-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to prevent navigating in the command history (arrow keys) from requiring pressing the Return key twice #531
Comments
With the default setting, @NitramO-YT Could you check the reply to #382? |
Okay, i checked my |
Yes, but that's intentional. The goal of @NitramO-YT Could you check the reply to #382 for the adjustment of the configuration? The adjustment necessary to achieve the behavior you describe is also described there. It is also described in the Q&A page (the fifth item). |
That is a duplicate of #80 and #101. As described in Maunal §4.11.1, you can specify
Yes.
Please read README. It is described in README §2.8. Also, there is a pointer in the Note at the top of README.
The readline bindable function If you really want to use
Please use the following instead (Note: you need ble-bind -x C-f fzf-history-widget |
Okay, let's forget about fzf for now, i read #80 & #101 and i still don't understand how to do what i want, but by reading it i learned about Ctrl+P and Ctrl+N and i tried it and it's exactly what i want but for the arrow keys, also with
if you press arrow up many times and then Ctrl+C to quit and then arrow up again and press arrow down to go back then you can go infinitely to after the last command |
Okay, so ChatGPT explained me, i did
in my |
Well this works, but actually places my Caret Cursor at the start of the line and not at the end like how it should do natively, is there any fix? |
So what do you want to achieve? I thought you wanted the setting in oh-my-bash but wanted to run a command with a single RET. In addition, I thought you wanted to hide the status. If that is the case, the setting would be: ble-bind -f up 'history-search-backward immediate-accept:hide-status'
ble-bind -f down 'history-search-forward immediate-accept:hide-status' However, if you wanted the behavior of C-p and C-n for up and down, it is actually the default setting. The behavior difference is because you or oh-my-bash overwrite the keybindings for up and down. You can just remove these settings overwriting the default one. Or, while still loading oh-my-bash, you can again overwrite the keybindings to the default one in ble-bind -m 'emacs' -f 'up' 'backward-line history'
ble-bind -m 'emacs' -f 'down' 'forward-line history'
What do you mean by "infinitely"? Doesn't that as many times as you pressed up instead of the infinite times? If it means really the infinite times, I cannot reproduce the behavior. If it means as many times as you have pressed up, it is another intentional change to the Readline behavior. The behavior is controlled by the ble-bind -f up 'history-search-backward immediate-accept:hide-status:action=load'
ble-bind -f down 'history-search-forward immediate-accept:hide-status:action=load'
This is nonsense...everything is wrong. Fortunately, this just defines four key names (UP, DOWN, history-search-backward:immediate-accept:hide-status, history-search-forward:immediate-accept:hide-status) internally but does not affect any behavior because there are no keys with such names (it should be noted that key names are case sensitive in ble.sh, so UP and DOWN are distinct from up and down).
Is that really what you have in your ble-bind -f up 'history-search-backward immediate-accept:hide-status:action=load:point=end'
ble-bind -f down 'history-search-forward immediate-accept:hide-status:action=load:point=end' |
So, to summarize, I don't know what you actually want because the description seems inconsistent. While you say you want the behavior of C-p and C-n, your request seems inconsistent with the behavior of C-p and C-n. Anyway, you might try the following settings and choose the one you like: # option 1
ble-bind -f up 'history-search-backward immediate-accept:hide-status'
ble-bind -f down 'history-search-forward immediate-accept:hide-status'
# option 2
# (set no keybindings but remove oh-my-bash)
# option 3
ble-bind -m 'emacs' -f 'up' 'backward-line history'
ble-bind -m 'emacs' -f 'down' 'forward-line history'
# option 4
# (set no keybindings)
# option 5
ble-bind -f up 'history-search-backward immediate-accept:hide-status:action=load'
ble-bind -f down 'history-search-forward immediate-accept:hide-status:action=load'
# option 6
ble-bind -f up 'history-search-backward immediate-accept:hide-status:action=load:point=end'
ble-bind -f down 'history-search-forward immediate-accept:hide-status:action=load:point=end'
# option 7
ble-bind -f up 'history-search-backward point=end'
ble-bind -f down 'history-search-forward point=end'
# option 8
ble-bind -f up 'history-search-backward immediate-accept:hide-status:point=end'
ble-bind -f down 'history-search-forward immediate-accept:hide-status:point=end' |
Sorry, i pasted the wrong lines, this wasn't working so i asked again and he gave me
That was these lines which were working as i wanted (apart from the wrong cursor placement) So i tried both
and
in my To explain again what i wanted was: And about Ctrl+p / Ctrl+n i poorly explained and what i wanted to say was that without needing to config these binds (like you said on #80) with
it worked like natively as the way i wanted for arrows! Thanks again for your valuable help and time! |
Look at this video: |
Ah, I see.
Ah, yeah. That makes sense.
OK, the behavior is indeed strange. The number after |
Hi, is there any way to prevent this behavior or disable the option which do that when you navigate through the command history (arrow keys) you then have to press enter twice to execute the command? (Something else than pressing Ctrl+J everytime instead of Return)
Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: