6 ms·
Typing Esc then . does the trick too.
by lolive 6y ago
Typing Esc then . does the trick too.
- cerved 6y agowhat, what?
- gadiyar 6y agoI didn't know this. Really neat!
- teptoria 6y agoWow amazing! Thanks :)
- itsmarsu 6y agoThat's just magical
- thomasahle 6y agoHow does that work?
- alex_smart 6y agoAlt + . does the same thing as well, with the added advantage that you can keep pressing alt and then hit . several times to go through all the "last arguments" in your history one by one. 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.
- seesawtron 6y agoCool one. "Ctrl + R" also does the same thing to search through past commands and then "Tab" to select the command you are looking for.
- alex_smart 6y agoMay favorite bash "trick" is: !-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.
- tikkabhuna 6y agoAnd if you only have a single instance to replace, you can use ^old^new^ $ echo "hello hello hello world" hello hello hello world $ ^hello^bonjour^ echo "bonjour hello hello world" bonjour hello hello world
- alex_smart 6y agoI know that this expansion exists, but never use it in practice. 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.
- dcassett 6y agoThis is great for removing an option from a prior command such as unzip -t ...: ^-t
- rswail 6y agoTIL! Oh this one is nice... now just to get my fingers to remember it.
- 6y ago
- nmfisher 6y agoYou just blew my mind.
- madacol 6y agoMore shortcuts like that https://stackoverflow.com/questions/38176514/re-run-previous-command-with-different-arguments/55067306#55067306 https://stackoverflow.com/questions/38176514/re-run-previous...
- mraza007 6y agoI have been looking for this Thanks for sharing :)
- emmelaich 6y agoOnly in emacs editing mode. Real programmers use set -o vi
- stjohnswarts 6y agoI use that on test machines a lot and had put it in bashrc and heard some cussing from other devs so now I just have to type it every time I spend more than acouple seconds in a terminal :) .