3 ms·
I prefer Ctrl-P, Ctrl-A, "sudo ", enter It's pretty much the same number of keystrokes aside from having to hold down the Ctrl key. However, I can now go back
by zacharypinter 16y ago
I prefer Ctrl-P, Ctrl-A, "sudo ", enter
It's pretty much the same number of keystrokes aside from having to hold down the Ctrl key. However, I can now go back in my history and run the command again. Also, if I mistyped something, I can easily hit Ctrl-P and fix it without having to retype sudo.
- jonhohle 16y ago!! (bang-bang) is expanded by the shell before its committed to your history (at least in bash), so if you hit ctrl+p, you'll get the full sudo command for running/modifying later.
- tjarratt 16y agoIn zsh, !! is expanded by the shell, but leaves the expanded command at the terminal, waiting for you to execute it. Most of the time this means I have to hit enter twice to run the command, but it's convenient when I want to explain to someone what !! is useful for.
- vsync 16y agoI don't have that enabled but zsh also expands bang constructs with tab. So any commands I want to double check, or if I am demonstrating to someone, I just hit tab. Also handy for expressions like !-2:3 where if I messed up I can just hit "undo" and then retry.
- zacharypinter 16y agoAh. Good to know.