Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash, numeric prefix for emacs bindings?

Is it possible to use emacs bindings in bash shell with numeric arguments, for example in emacs C-u 5 C-d deletes five characters. Is there an equivalent way of doing the same in bash prompt?

Thanks

like image 584
Anycorn Avatar asked Feb 14 '10 06:02

Anycorn


People also ask

How do I set key bindings in Emacs?

The manual way is to use C-h k KEY to describe what KEY is bound to; the other way is to describe a function, FUNCTION , with C-h f FUNCTION . Because Emacs is a self-documenting editor all functions, variables, keys, etc. known to Emacs are accessible through the describe-xxx commands. Type C-h C-h to see them all.

What is Emacs prefix argument?

The prefix argument is a pseudo-argument that is automatically available for each Emacs command. When you use a command, its behavior might differ, depending on the value of the prefix argument. You can use 'C-u' to set the prefix argument value to use, and thus affect the command's behavior.

What is prefix command?

A command prefix is a prefix of a command (in the sense of rule 2 of the dodekalogue, i.e., a sequence of words) that is constructed with the expectation that zero or more arguments will be appended to it and that the resulting command will be evaluated.

What is the prefix of argument?

argue + ment = argument.


1 Answers

Emacs is usually the default editing mode (set -o emacs).

From Introduction to Line Editing and Readine Arguments:

The text C-k is read as 'Control-K' and describes the character produced when the Control key is depressed and the k key is struck.

The text M-k is read as 'Meta-K' and describes the character produced when the meta key (if you have one) is depressed, and the k key is struck. If you do not have a meta key, the identical keystroke can be generated by typing ESC first, and then typing k. Either process is known as metafying the k key.

The general way to pass numeric arguments to a command is to type meta digits before the command. For example, to give the C-d command an argument of 10, you could type M-1 0 C-d.

Bash Emacs Editing Mode (readline) Cheat Sheet

like image 178
jschmier Avatar answered Sep 20 '22 00:09

jschmier