Home/End keys do not work in tmux

前端 未结 8 1742
无人及你
无人及你 2021-01-30 10:37

I\'m currently using tmux with xterm-256color $TERM variable. When in bash under tmux, pressing home/end would insert tilde characters (~). Outside of tmux the home/end keys wor

8条回答
  •  太阳男子
    2021-01-30 10:46

    If you want to stay with xterm-256color in tmux for some reason - use arch solution with inputrc. I tested it in tmux with rxvt, ruby irb, python, lua and home/end keys are ok. Probably every readline app will be ok.

    From the arch wiki:

    First things first:

    do not set $TERM manually - let the terminal do it.


    Many command line applications use the Readline library to read input. So properly configuring Readline can fix Home and End in many cases.

    the default /etc/inputrc file does not include a mapping for home/end keys.

    To check what the emitted escape sequence for these keys is:

    1. Ctrl + V
    2. Home
    3. Spacebar
    4. Ctrl + V
    5. End
    

    this will probably print: $ ^[[1~ ^[[4~. So you have to add a mapping for these sequences to your inputrc (/etc/inputrc to be globally, or only for your user ~/.inputrc):

    "\e[1~": beginning-of-line
    "\e[4~": end-of-line
    

提交回复
热议问题