Solved My terminal returns ;5A;5D;5B;5C whenever I use CTRL+arrow

I'm using CentOS Linux release 7.0.1503 (Core) and I ssh into following system:
Code:
    $ uname -a
    FreeBSD X 9.2-RELEASE-p17 FreeBSD 9.2-RELEASE-p17 #0 r282430: Mon May  4 13:59:58 PDT 2015     root@X:/usr/obj/usr/src/sys/R610  amd64
    $
Whenever I try to use CTRL + arrow like I do in Linux terminal, I'm getting following:
Code:
    [alexus@j ~]$ ;5A;5D;5B;5C
My Linux's $TERM:
Code:
    [alexus@wcmisdlin02 Desktop]$ echo $TERM
    xterm-256color
    [alexus@wcmisdlin02 Desktop]$
How would one resolve that?
 
What's CTRL-arrow supposed to do?

... in Linux, using CTRL+arrow, I'm able to faster move my cursor to next space between command/parameters, I believe when I worked via console I was able to do same thing in FreeBSD.
 
That's a shell configuration issue, you need to set up keybindings so that ctrl-arrow is mapped to the correct editing function. Consult the manual of the shell you're using.
 
Unless something changed between 6 and 7, I'd even say it's a local setting. On one of our CentOS 6.6 machines CTRL-left/right simply moves the cursor left/right as if CTRL was never pressed.
 
That's a shell configuration issue, you need to set up keybindings so that ctrl-arrow is mapped to the correct editing function. Consult the manual of the shell you're using.

Can I ask you to be a little bit more specific, manual is pretty big and I don't know what am I looking for.

Unless something changed between 6 and 7, I'd even say it's a local setting. On one of our CentOS 6.6 machines CTRL-left/right simply moves the cursor left/right as if CTRL was never pressed.

I just tried ssh from CentOS 6.6, and CTRL-left/right acts same way for me as on CentOS 7, but locally (without sshing) it works as expected (as I described earlier).
 
It's a common bash(1) configuration, have a look at ~/.inputrc and/or /etc/inputrc. Also keep in mind that FreeBSD doesn't have bash(1) installed by default. That said, I do believe tcsh(1) can be configured to do the same.
 
Code:
[root@j ~]# tail -1 /etc/profile
export INPUTRC=/usr/local/etc/inputrc
[root@j ~]# cat /usr/local/etc/inputrc
"\e[1;5C": forward-word
"\e[1;5D": backward-word
This worked for me too but I created the file in
Code:
 ~/.inputrc
 
This seems to work for me for csh(1) and tcsh(1) with x11/konsole and x11/xterm with KDE Plasma:

Code:
% cat ~/.cshrc | grep bindkey | grep -v \#
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                bindkey '\e[3~'         delete-char
                bindkey '\e[1;5C'       forward-word
                bindkey '\e[1;5D'       backward-word
%

(I took the delete-char hint from Michael Holtstrom's Solaris Basics (2013-09-25).)

I can't figure out how to get the same effect for sh(1)

Postscripts

sh
One minute later, this appeared:
2021-04-21 12:24:05.png


– is it an answer to my question? (Spooky coincidence?) The best answer? I hesitate because I choose to never use vi(1).

If there's a sh-specific answer I might add it to ubuntu - Getting ;5D when hitting ctrl + arrow key in a Terminal on FreeBSD - Server Fault

Without a desktop environment

Whilst the movement seems to be proper (word to word) with applications in Plasma, the movement is wrong (character to character) in, for example, ttyv1. FreeBSD 14.0-CURRENT, if it's relevant.
 
Back
Top