Playing with macros:
Bind the function key F8 to multiply by two the last word (up the previous space) (F8 key code found by using
$ bind '"\e[19~": "\C-w\C-y\C-y"'
That could be made permanent by sending the same text to
$ echo '"\e[19~": "\C-w\C-y\C-y"' >> ~/.inputrc
to get 2^4 times the zero. (still 5 keystrokes).
to get 2^3 book words.
Multiply by 4:
$ bind '"\e[19~": "\C-w\C-y\C-y\C-w\C-y\C-y"'
Multiply by 8 (the same number as the function key)
$ bind '"\e[19~": "\C-w\C-y\C-y\C-w\C-y\C-y\C-w\C-y\C-y"'
Still 3 keypresses.
Cheat by multipling by 16.
$ bind '"\e[19~": "\C-w\C-y\C-y\C-w\C-y\C-y\C-w\C-y\C-y\C-w\C-y\C-y"'
Only 2 keypress. (and still an useful simple function)
^^^^^^^^^^^^^^^^ (base 36? Hah!) :-P
$ bind '"\e[19~": "0000000000000000"'
Just 1 (yes: one) keystroke.
Changing the binding for ctrl+U:
Send this to
echo '"\C-u": universal-argument >> ~/.inputrc
do it as is usual in emacs (as you wanted):
foo --bar=baz ctrl+U 16 ctrl+U 0
7 keys (after the "setting up").
Use the default "multiply by 4" of "universal-argument" and end with
foo --bar=baz ctrl+Uctrl+Uctrl+V0
Only 5 keys.
Using the alt+n access to (arg: n)
foo --bar=baz Alt+16Ctrl+V0
That's 6 keys to get the 16 zeros.
Not changing any keyboard shortcut:
If in your bash you have
bash C-u kills the currently-being-typed line.
"\C-u": is bind to
But that might also help:
When, what is before the cursor is erased, it is also placed in the "kill-ring".
ctrl+u erases and
ctrl+y yanks back what was erased.
On a clean line: Type
00 erase it and yank it back twice to make it
Repeat to get
00000000 (8 zeros), finally type the command and yank back twice.
The first set (7 keys keep ctrl pressed):
00 ctrl+Uctrl+Yctrl+Y ctrl+U
The second set (5 keys)
That will get eight zeros in the erase ring, then type what you want:
foo --bar=baz ctrl-Y ctrl-Y
foo --bar=baz 0000000000000000
After you get the idea, you may as well, type what you need, go to the start of the line (ctrl-Y), do as above (up to eight zeros) go to the end (ctrl-E) and yank twice.
foo --bar=baz ctrl-A00 ctrl-Uctrl-Yctrl-Y ctrl-Uctrl-Yctrl-Y ctrl-U ctrl-Ectrl-Yctrl-Y
That's 15 keys (beside the command itself).
Not short, I know, but that is working only with what was available.
This is a little shorter:
0000 ctrl-U ctrl-Y ctrl-Y ctrl-Y ctrl-Y ctrl-A foo --bar=baz
That's 11 keys