Further, holding Alt followed by numeric argument followed by dot, gives you an argument at a specific position. For example, Alt + 1, Alt + . copies the first argument.
!-1:gs/hello/world
which runs the last command with all instances of hello replaced by world. !-1 can be any so called event designator, for instance !n to refer to any specific line number from history or !string for last command containing a particular string.
Seriously people, read the man page for bash. Your shell has so many cool features.
$ echo "hello hello hello world" hello hello hello world $ ^hello^bonjour^ echo "bonjour hello hello world" bonjour hello hello world
Why? The last command is more general, you can just drop the g from the command I wrote to only replace the first occurrence. Besides, :[g]s/old/new should already be familiar to anyone who has used vim, so that is almost like having to learn zero new things.
^-t
No, more having to press C-r multiple times just to get sequential group of commands from history.
Also keep in mind that most interactive command-line tools are built upon readline and can understand all those bindings (think python REPL, mysql/psql...)
Haha of course. I use it so frequently I can't imagine how anyone uses their shell without it.
>can understand all those bindings
I knew that but just being reminded helped me realize that C-o is probably going to be useful in the REPL as well. Thanks.
Real programmers use set -o vi
Bash is more than just bash. Composition is a killer technique.