Bash save for later
This is a very simple tip, but I use it all the time. What do you do when you're typing a long shell command and you realize you forgot some other commands that need to happen first? You could cut and paste to a text editor to save it for later or you could prepend your other commands and hope you don't make a mistake.
$ do_something && do_something_else && do_something_later with_a | lot_of `complex_args` > "and stuff you don't want to type a second time"
I like to hit ctrl-a (go to start of line) then comment out the line.
$ #do_something_later with_a | lot_of `complex_args` > "and stuff you don't want to type a second time"
$ do_something
$ do_something_else
Now I can do a bunch of work in the shell. When I want to go back to my long complex command, I hit ctrl-r (reverse history search) then hash. Then I can just uncomment instead of retyping everything.
(reverse-i-search)`#': #do_something_later with_a | lot_of `complex_args` > "and stuff you don't want to type a second time"
Written by Chris Kentfield
Related protips
3 Responses
Good tip! And you can also use Ctrl-a, Ctrl-k and Ctrl-y sequence.
Cheers!
@dongli That's works well too. It looks like there's also a "kill ring" like in Emacs so that you can hit Alt-y if you want to cycle through lines you've killed in the shell.