rubyirbruby-3

Ruby 3 IRB home end and ctrl-u not working


I've recently started using Ruby 3 more and it seems the home key (to take me to the beginning of the line) the end key (end of the line) and ctrl-u (clear the line) aren't working.

I'm running Arch Linux with Ruby 3.1.1p18 and a zsh shell. The keys work fine on Ruby 2.7. I've tried with Alacritty and xfce4-terminal and both have the same issue. I'm not using Tmux or anything similar.

There is this similar question from a few years ago but that's for Windows and the solutions didn't help: Backspace and arrow keys aren't working in IRB(Git Bash console) on windows machine


Solution

  • I have found a good solution for this issue in this Archlinux guide: Home_and_End_keys_not_working

    Just create the file ~/.inputrc with the content:

    "\e[1~": beginning-of-line
    "\e[4~": end-of-line
    "\e[7~": beginning-of-line
    "\e[8~": end-of-line
    "\eOH": beginning-of-line
    "\eOF": end-of-line
    "\e[H": beginning-of-line
    "\e[F": end-of-line
    

    This solution works pretty good for me.