4 ms·
You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line promp
by pm215 10y ago
You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.
- petepete 10y agoI wasn't aware of this. Thank you. Not that I've been using Bash and zsh every day for twelve plus years...
- mikestew 10y agoTwelve? Youngster. I'd guess I'm coming up on thirty years. And I did not know this. Now the trick is to remember it next time the need comes up. :-)
- deleted 10y ago[deleted]
- verbify 10y agoSeems to be an instance of Cunningham's Law: https://meta.wikimedia.org/wiki/Cunningham%27s_Law https://meta.wikimedia.org/wiki/Cunningham%27s_Law
- tbrock 10y agoOh. My. God. Life changing! Out of curiosity, how did you discover that you could do this?
- pm215 10y agoIt's been something I've used for many years, so I really don't recall any more just where I found out about it...
- riboflava 10y agoMaybe it went something like "god damn it why can't I ctrl+v to copy, what other ctrl keys are there..."? And now I'm looking at http://ss64.com/bash/syntax-keyboard.html http://ss64.com/bash/syntax-keyboard.html and being amazed I didn't know about / forgot a few of these. It'd be nice to put some of the good ones on a coffee mug, I first learned useful vim commands from a coffee mug...
- pm215 10y agoNope, because I've never used control-keystrokes to do cut-n-paste. I always use (and love) X-style mouse cut-n-paste and hate that there are no good implementations of it on other OSes.
- fnj 10y agoDating myself, the way I learned copy and paste was CTRL-insert and SHIFT-insert, and those still work fine in konsole, mate-terminal, most any other half-decent terminal program, and straight text mode outside of X. Not xterm, but I never use that.
- mrb 10y agoI am not the GP but I learned about C-o by reading the man page. If you spend a lot of time in Bash, why not learn to use it properly? There are less than ~100 key bindings, see "Readline Command Names" in http://linux.die.net/man/1/bash http://linux.die.net/man/1/bash You should at the very least skim over them. operate-and-get-next (C-o) Accept the current line for execution and fetch the next line relative to the current line from the history for editing. Any argument is ignored.
- Datsundere 10y agoare you serious? you guys need to learn more shortcuts. http://teohm.com/blog/shortcuts-to-move-faster-in-bash-command-line/ http://teohm.com/blog/shortcuts-to-move-faster-in-bash-comma...
- npsimons 10y agoDon't forget control-R. I find that even the GP's example of up arrow 20x to be ridiculous when I can type C-r and a few unique letters that were anywhere in the command to find it instantly.
- stinos 10y agoWhich is why any sane powershell user would probably have installed PsReadline to get this and other goodies. Preferably running in ConEmu.
- iso-8859-1 10y agoPsReadline is shipped with PowerShell 5: https://technet.microsoft.com/en-us/library/ed48e832-95f9-4577-bf56-a7e5aa9630ba https://technet.microsoft.com/en-us/library/ed48e832-95f9-45...
- titanomachy 10y agoDoesn't work in bash running in my Terminal.app on macOS, although it certainly does when I `ssh` into one of my Ubuntu boxes. Wonderful shortcut. EDIT: If anyone knows an easy way to get this working on macOS, I'd love to know it.
- pm215 10y agoStackoverflow to the rescue: http://apple.stackexchange.com/questions/3253/ctrl-o-behavior-in-terminal-app http://apple.stackexchange.com/questions/3253/ctrl-o-behavio... This turns out to be because on OSX the terminal driver defaults to throwing away control-O which is rather unhelpful of it. "stty discard undef" fixes it.