Re:What's the one Linux command you wish you knew years ago?
by matheusalmeida on Sunday November 20, 2011 @05:26AM
(#3257800)
It's not a command but it is still useful. When you are typing a long command and you realize that you need to do other command or set of commands first, usually you type ctrl + c to cancel it. By default it does not save in the history. If you put # (comment the command) in front of the command (you can do it quickly with Ctrl + a #) and then you can use Ctrl + r to get it back. I'm sure there are other ways to save the command in the history but it is a simple way to have the same effect.
[ Parent
| on HN ]
Re:What's the one Linux command you wish you knew years ago?
by sjs on Sunday November 20, 2011 @11:50AM
(#3258437)
For those using zsh hit alt-q to stash the current command. After you run the next command your stashed line will be brought back for you.
alt-h behaves similarly but runs `man <command you were typing>`, so if you have this:
$ rsync -
and need to check the options, hit alt-h and the man page for rsync comes up. When you exit you'll be back at: $ rsync -
Re:What's the one Linux command you wish you knew years ago?
by telemachos on Sunday November 20, 2011 @08:59AM
(#3258106)
What I usually do in that situation is Ctrl + u (delete all the way back to the start of the line), then type the intermediate command, then Ctrl + y (place the deleted partial line back on the prompt, with my cursor at the end where it was).
This assume Emacs-style bindings for the shell.
Re:What's the one Linux command you wish you knew years ago?
by joshcorbin on Monday November 21, 2011 @08:24AM
(#3260994)
Even better: just type \ (line continuation) at point that you realize that you need to do something else first. Then hit Ctrl-c to cancel once you get to the new line.