Page 1 of 2

In inputrc, making backward-word and forward-word work

Posted: 19. Jun 2013, 18:49
by Atticus
I'm not sure if this is just me, but I've gotten used to pressing Ctrl-left-click and Ctrl-right-click in the terminal to move backward and forward a word, rather than just a letter. However, in Salix OS, when I press Ctrl-left-click, it just enters the letters "%5D" over and over. I found a solution here which basically says:

Code: Select all

Add the following lines to ~/.inputrc:

"\e[1;5C": forward-word   # ctrl + right
"\e[1;5D": backward-word  # ctrl + left 
then to reload, type:

Code: Select all

bind -f ~/.inputrc
I'm not sure if it was just me having this problem, but I figured I would report my issue and the solution I found and maybe this will get into the next version of Salix OS.

Thanks!

Re: In inputrc, making backward-word and forward-word work

Posted: 20. Jun 2013, 07:48
by gapan
I'm sorry, but where does that happen? Where do you see it?

Re: In inputrc, making backward-word and forward-word work

Posted: 20. Jun 2013, 10:44
by thenktor
This happens in xterm or other terminal emulators (with TERM=xterm). Press [CTRL]+[Left] or [CTRL]+[Right]. The default inputrc in Slackware has this:

Code: Select all

"\eOd": backward-word
"\eOc": forward-word
I have no idea which keys this escape sequences refer to.

To get the escape sequence of a key (or key combination) type [CTRL]+[v] followed by the key:
[CTRL]+[v] [CTRL]+[Left] results in ^[[1;5D.

So if you want to use [CTRL]+[Left] for backward-word you have to add to inputrc:

Code: Select all

"\e[1;5D": backward-word  # ctrl + left
;)

Re: In inputrc, making backward-word and forward-word work

Posted: 20. Jun 2013, 11:16
by gapan
but he's talking about ctrl-left-click and ctrl-right-click. Certainly the only thing that makes a click is the mouse?

Re: In inputrc, making backward-word and forward-word work

Posted: 20. Jun 2013, 13:36
by mimosa
Well, there's ratclick :twisted:

Also I believe you can tell bash to use vim-like editing ... yes, here's a link to info about that and more:

http://blog.sanctum.geek.nz/command-line-editing/

The 'fc' thing looks very handy, though beware (I just tried it and) if you exit your editor without saving (:q in vim) the previous command is executed unchanged.

EDIT

To exit without changing the command, and without executing it either (like ctrl-c in bash) do in vim

Code: Select all

:cq
(from a comment on a post about fc)

Re: In inputrc, making backward-word and forward-word work

Posted: 24. Jun 2013, 07:57
by thenktor
gapan wrote:but he's talking about ctrl-left-click and ctrl-right-click. Certainly the only thing that makes a click is the mouse?
I don't think he really means click. He means the keys. Everything else does not make sense for me ;)

Re: In inputrc, making backward-word and forward-word work

Posted: 24. Jun 2013, 21:00
by Atticus
Hi guys, sorry I meant Ctrl+leftbutton and Ctrl+rightbutton, not mouse clicks.

Re: In inputrc, making backward-word and forward-word work

Posted: 26. Jun 2013, 09:06
by gapan
Atticus wrote:Hi guys, sorry I meant Ctrl+leftbutton and Ctrl+rightbutton, not mouse clicks.
OK, so did you really try this solution or are you just posting what you found?

BTW, the \eOd and \eOc codes are for ctrl-left and ctrl-right keys, it's just only that they work in rxvt.

Re: In inputrc, making backward-word and forward-word work

Posted: 27. Jun 2013, 10:40
by thenktor
gapan wrote:BTW, the \eOd and \eOc codes are for ctrl-left and ctrl-right keys, it's just only that they work in rxvt.
So the correct inputrc entry would be:

Code: Select all

$if term=rxvt-unicode
"\eOd": backward-word     # ctrl + left 
"\eOc": forward-word      # ctrl + right
$else
"\e[1;5D": backward-word  # ctrl + left 
"\e[1;5C": forward-word   # ctrl + right
$endif
There are probably a lot of other differences in rxvt. See the insane inputrc of OpenSUSE: http://pastebin.com/g6e6NyL9 ;)

Re: In inputrc, making backward-word and forward-word work

Posted: 8. Jul 2013, 23:21
by Atticus
gapan wrote:
Atticus wrote:Hi guys, sorry I meant Ctrl+leftbutton and Ctrl+rightbutton, not mouse clicks.
OK, so did you really try this solution or are you just posting what you found?

BTW, the \eOd and \eOc codes are for ctrl-left and ctrl-right keys, it's just only that they work in rxvt.
I have been using the solution I posted and it has worked great for me. I'm on Salix 14.0 with Xfce using Xfce Terminal. Unfortunately, I don't have much experience with ~/.inputrc and how it works with other terminal emulators so I can't really offer you a well engineered solution beyond what I've posted.

My hope is that even if this suggestion isn't enacted in Salix then at least people who have this issue will find a solution here.