ArchLabs Linux

Home/End Keys Don't Work in xfce4 Terminal

On stock arch, Home/End keys work in xfce terminal.
Don’t work in ArchLabs.

any fix?

thx!

Clue:
Works for su, but not for regular user.

Not an uncommon problem.
https://wiki.archlinux.org/index.php/Home_and_End_keys_not_working

i applied this fix to my ~/.zshrc, using sudoedit from su, but Home and End still don’t work for regular user.
https://wiki.archlinux.org/index.php/Zsh#Key_bindings

Apologies for the issue but it’s very terminal specific.

I wouldn’t use sudoedit to edit files owned by your user as it can result in permission issues if not used correctly.

You’ll need to do a couple things to get the keys working in whatever terminal you like.

  • First open the terminal you’re having issues with, press Ctrl-v (enabling literal output of characters that would otherwise be interpreted by the terminal or shell) then press the key you want to bind. This will output the escape sequence used for that key, eg. the home key outputs ^[[1~. Repeat this for each key you want to bind.

  • Edit either ~/.zsh/settings/bindings.zsh (you’ll see there is already the terminfo solution from the wiki) or your ~/.zshrc, add something like this but replace the escape sequences I use with the ones you got from step 1.

    bindkey -- '^[[1~' beginning-of-line  # Home key
    bindkey -- '^[[4~' end-of-line        # End key
    

This binds the sequence following -- to call the function given after the sequence, the functions can be custom or built-in (I used built-ins above). The sequence also must be strong quoted to avoid shell interpretation.

To learn the built-in functions read the “STANDARD WIDGETS” section of:

man 1 zshzle

# use the / key to start a search then type STANDARD and hit enter

Also note that there are different bind modes for zsh depending if you have vi-mode enabled.

1 Like

thx for notes. i’m getting different results. The Home and End keys gives me:

^[OH
^[OF

Weird, right? But that works with your bindings.

Why do the keys work on ArchLabs su no problem?
Why do the keys work on pure arch non-su no problem?

thx

Because they don’t use any shell config and I’m assuming the sequences you got must be the one it looks for by default. In future releases we’ll be using shell defaults rather than custom configs to avoid problems like yours or this Midnight Commander gets stuck as well as some others.


Not too weird, it can vary depending on what terminal emulator you’re using and what terminal they’re trying to emulate or offer compatibility for.

Sounds good!
Thx for awesome answer. Where did you learn that?

Mostly reading man pages and working on some of my little projects.