This is the same question I asked I while back, so I'm not taking credit for this, but I had to put
xterm*metaSendsEscape: true
URxvt*altSendsEscape: true
in .Xresources
to make Alt work as Meta in both xterm and urxvt. It is a bit contradictory, but it works. So experiment with those options. Also, I had to put
xrdb ~/.Xresources
in .xinitrc
for it to work.
Edit: My question: Emacs commands in xterm
In "vi" mode you can edit/navigate on the current shell prompt like a line in the vi editor. You can look at it like a one-line text file. Analogously in "emacs" mode you can edit/navigate the current command line using (some) of Emacs' shortcuts.
Example
For example in vi-mode you can do something like (in bash):
$ set -o vi
$ ls hello world
<ESC>
bbdw # results in
$ ls world
In emacs-mode you can hit e.g. Ctrl+A to jump at the start of a line (vi: Ctrl+[, 0 or ESC,0). You can turn on emacs mode via set -o emacs
(in bash, ksh, zsh etc.).
Readline
A lot of interactive command line programs (including bash) use the readline library. Thus, you can configure which input mode to use (vi or emacs) and other options in one place such that every program using readline has the exact same editing/navigating interface.
For example my readline configuration looks like:
$ cat ~/.inputrc
set editing-mode vi
set blink-matching-paren on
For example zsh/ksh does not use readline as far as I know, but also support vi/emacs modes that are very much like the bash/readline one.
Of course, the vi/emacs mode in a command line shell is just a subset of the complete editor feature set. Not every feature makes sense in a command line shell, and some features are more complicated to support than others.
Canonical Mode
Before vi/emacs modes of interactive command line shells 'were invented' your shell would use just the canonical mode of your terminal which only provides a limited set of editing commands (e.g. Ctrl+W to delete the last word.
Best Answer
The two are identical.
Doing
set -o vi
in an interactivebash
shell calls theset
builtin. The C code for theset
builtin callsrl_variable_bind("editing-mode", option_name)
(whereoption_name
will bevi
) which is the Readline library function that sets the command line editing mode.Setting the command line editing mode on the command line with
set -o
in thebash
shell would override the corresponding setting configured in~/.inputrc
.Setting the editing mode in
~/.inputrc
would set it as the default command line editing mode for any application using the Readline library.