You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have "Home" and "End" keys on my numpad.
I want to use them to navigate to the beginning and end of the line respectively:
Instead it prints out ^[[1~ and ^[[4~.
I don't think it's a problem with my setup. these numpad Home/End keys work on the following interpreters on this system
python
node
deno
ocaml (with rlwrap)
rlwrap irb produces the same results for me as above.
Result of irb_info
Please paste the result of irb_info command in IRB.
ex.)
irb(main):001:0> irb_info
=>
Ruby version: 3.1.2
IRB version: irb 1.4.1 (2021-12-25)
InputMethod: ReidlineInputMethod with Reline 0.3.0 and /home/lewis/.inputrc
RUBY_PLATFORM: x86_64-linux
LANG env: en_NZ.utf8
East Asian Ambiguous Width: 1
However, in your particular case, you may have additional problems because I use Alacritty as well and its terminfo is similar to XTerm. With both Alacritty and XTerm, Home and End (both the normal ones and the ones on the numpad when numlock is off) should not be sending ^[[1~ and ^[[4~ but rather ^[[H and ^[[F (or ^[OH and ^[OF when in application mode).
Have you figured out what is going on with your terminal yet? You should start by making sure your terminal sends what it is supposed to. I use Alacritty too and I don't what you've done to make it send escapes codes that look more like the linux TERM than alacritty and xterm TERM. I think you should focus on that, although it is true after fixing that you may still be experiencing problems until one or more of the PRs above get merged in.
You can use showkey -a to find out what your keys are sending.
There's 5 other interpreters (haskell, python, node, deno, ocaml) on this system that handle my home and end keys just fine. It's a little bit hard for me to imagine they all have extensive workarounds for my "weird" setup. It feels a lot more like reline is doing something brittle.
But if there's a handful of PRs around this issue already, me adding another is unlikely to help, so I appreciate the context around this.
Not sure what you mean by python3 not handling home and end. I am typing it in the python interpreter right now (3.11.5) and it works absolutely fine. Where as irb (1.6.2) gives me:
@LAC-Tech The issue has been fixed and released in Reline, so the issue should be gone once you upgraded it. But I'd recommend upgrading to the latest Reline + IRB with gem install irb.
Activity
sshock commentedon Oct 9, 2022
Possibly related: #330 (comment)
However, in your particular case, you may have additional problems because I use Alacritty as well and its terminfo is similar to XTerm. With both Alacritty and XTerm, Home and End (both the normal ones and the ones on the numpad when numlock is off) should not be sending
^[[1~and^[[4~but rather^[[Hand^[[F(or^[OHand^[OFwhen in application mode).LAC-Tech commentedon Oct 10, 2022
Are you familiar with reline? I had a brief poke around the source code but couldn't figure out where I might make this change.
sshock commentedon Oct 11, 2022
What are you wanting to change? Multiple PRs already exist to fix several issues with the keys not working properly:
Have you figured out what is going on with your terminal yet? You should start by making sure your terminal sends what it is supposed to. I use Alacritty too and I don't what you've done to make it send escapes codes that look more like the linux TERM than alacritty and xterm TERM. I think you should focus on that, although it is true after fixing that you may still be experiencing problems until one or more of the PRs above get merged in.
You can use
showkey -ato find out what your keys are sending.LAC-Tech commentedon Oct 13, 2022
There's 5 other interpreters (haskell, python, node, deno, ocaml) on this system that handle my home and end keys just fine. It's a little bit hard for me to imagine they all have extensive workarounds for my "weird" setup. It feels a lot more like reline is doing something brittle.
But if there's a handful of PRs around this issue already, me adding another is unlikely to help, so I appreciate the context around this.
Here's the
showkey -afor Home and End.sshock commentedon Oct 13, 2022
Oh, good. Your Home and End are actually sending what they are supposed to.
So yeah, either one of ruby/reline#433 or ruby/reline#462 would fix your problem.
In the meantime, you can try this workaround or any of the other workarounds mentioned in that issue.
st0012 commentedon Jul 19, 2023
I think this has been addressed by ruby/reline#569? cc @tompng
tompng commentedon Jul 19, 2023
Home and End keys for
\e[Hand\e[Fis fixed in ruby/reline#569Reline handles
\e[1~and\e[4~only if terminfo haskend=\E[4~andkhome=\E[1~.Table of some tools handle
\e[1~\e[4~by default or not(unlike issue description, python2 and python3 does not handle
\e[1~\e[4~)LAC-Tech commentedon Aug 28, 2023
This will fix will be in an upcoming irb release?
Not sure what you mean by python3 not handling home and end. I am typing it in the python interpreter right now (3.11.5) and it works absolutely fine. Where as irb (1.6.2) gives me:
st0012 commentedon Aug 28, 2023
@LAC-Tech The issue has been fixed and released in Reline, so the issue should be gone once you upgraded it. But I'd recommend upgrading to the latest Reline + IRB with
gem install irb.LAC-Tech commentedon Aug 28, 2023
Thanks so much! works great now.