[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: xterm and command line word movement: CTRL+RightArrow, CTRL+LeftArrow



Volker Wysk wrote:
> Am Freitag, 6. Dezember 2013, 10:51:30 schrieb Zenaan Harkness:
> > SOLVED (gmail breaks threads sorry - I'll upgrade to mutt again next year).

I know you said solved.  Good.  It sounds from what was written like
it might not be solved yet though.

In any case I will note that control-left and control-right move by
words for me in bash and xterm, as apparently you desire, without any
configuration other than the default.  I have no idea why it isn't
working for you.  I feel certain there must be other configuration
that is getting in the way.

By default Debian includes /etc/inputrc that contains:

  # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
  "\e[1;5C": forward-word
  "\e[1;5D": backward-word
  "\e[5C": forward-word
  "\e[5D": backward-word
  "\e\e[C": forward-word
  "\e\e[D": backward-word

This is installed as part of the readline-common.

Works for me.  YMMV and all of that.

> > Update the Xresources and inputrc files as appropriate.
> > Start a new xterm.
> > 
> > This xterm won't work - even running the following command is not
> > enough to make this new xterm work:
> > xrdb -load ~/.Xresources; bind ~/.inputrc
> 
> I don't know, what bind does. It has no manpage. But, probably, /etc/inputrc 
> should be uses instead of ~/.inputrc. Then i'ts loaded when you log out and 
> log in again.

It is a built-in to the bash shell.  It is part of libreadline.

  $ help bind

For other documentation you could look at the upstream online docs.

  https://www.gnu.org/software/bash/manual/html_node/Command-Line-Editing.html

Of particular interest might be:

  re-read-init-file (C-x C-r)
    Read in the contents of the inputrc file, and incorporate any bindings
    or variable assignments found there.

If you are hacking on inputrc files then setting up that key binding
is convenient because then you can tell the shell to re-read the
inputrc file on the fly.

The documentation on the bind builtin is here:

  https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

> > I am not yet able to test logging out and logging back in or reboot -

There is no need to log out.  Just open a new xterm.  The xterm will
read the X resources when it starts.  The xterm will start your bash
shell.  Bash will read the .inputrc file when it starts.

> > I'm guessing that will also do the trick, however for the time being,
> > I usually work in a screen session, and that is now working
> > regardless.

I wonder if you are having a termcap/terminfo problem.  Because screen
usually emulates a TERM=screen terminal type within whatever terminal
you are using.  Sounds like it is working inside that TERM setting.
But if it isn't working outside then I wonder if your TERM outside has
the appropriate terminfo capabilities?

> Logging out and back in is probably what needs to be done. ~/.Xresources and 
> /etc/inputrc should then be reloaded automatically.

Starting a new xterm should be sufficient for Xresources.

> > It seems xrdb -load and bind are not working as advertised in their
> > respective manuals.

Since xrdb is such a simple command I think that extremely unlikely.
You can test it yourself to verify what you are setting.

  xrdb -load ./file
  xrdb -q

The xrdb -q will dump the contents of the memory Xresources.  Just
look and see what you are setting there.  If it is set then it worked.
Perhaps you have set something in the past that is conflicting?

For bash then just restarting bash would be enough.  If I don't have
re-read-init-file bound then I would simple "exec bash" in that window
to start a new one.  The new one will read the new inputrc file.

For xterm note that the Xresources "xterm" all lower case would map to
that exact named program.  I always use "XTerm" in that mixed case to
indicate the class.  Then the resource is used even if the xterm name
is set to something different.  If I want a resource only for some
particular use, such as a background or a font only for a particular
window say debugging, then I use "debug" as the resource name and use
that name "xterm -name debug" as the xterm name and it will use those
resources.  Pretty useful for that purpose.  Many people don't realize
that so I mention it.  If you want your resource to apply to all xterm
then use the "XTerm" mixed case of the class name and not all lower case.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: