sudo !! sudo !!eg. Check what you're about to delete
$ ls *.backup
a.backup b.backup c.backup
$ ^ls^rm
rm *.backup
Something else that saves a lot of time is to incremental-search backwards through your command history using ctrl-r instead of arrow keys. eg. cycle through every "grep". Press ctrl-r, type grep, and it jumps to to most recent command that contains "grep". Each time you press ctrl-r it will jump further back in time. If it's something you expect to search for a lot, you can even tag commands with # comments then search for the comment. (There's a fine line there though... if you reuse a command really often you should probably alias or script it)Command history uses the 'readline' library so all(?) the other editing-related emacs chords will work on it ctrl-a/ctrl-e to jump to the start/end of the line, ctrl-r/ctrl-s to search, alt-f/alt-b to jump words, etc. Oh, and an emacs kill-ring too, that's pretty useful.
Enjoy.
...
...
But there's one more thing.
This is a feature of GNU Readline, not a feature of bash. Other apps that use readline will also accept these chords.
Things like the ruby and python shells, mysql, etc.
You think you can do a lot in those tools now? Learning to leverage everything that readline gives you will take you to a whole new level.
Have fun exploring :)
Left/Right Option Key Acts As
It is common to use a modifier to send so-called "meta keys". For most users, selecting "+Esc" here is the right choice. The "Meta" option sets the high bit of the input character, and is not compatible with modern systems.
fucking !!
!gre # will run the last command starting with gre (so probably grep)
If you type history, then !<number to the left of the history command>, the shell will execute that command. $ history # shows command history
$ !200 # executes command 200[0]: https://www.gnu.org/software/bash/manual/bashref.html#Event-...