userbinator
2 days ago
Every time someone brings this up, I think "oh right, I could do that" and then immediately forget. Especially if you can type quickly, it's easier to just "drive straight ahead" with the command you want, than add another "mental branch" to interrupt the flow. For the same reason I'll often Ctrl+C and start again instead of trying to backspace and correct.
mkl
2 days ago
> For the same reason I'll often Ctrl+C and start again instead of trying to backspace and correct.
Try ctrl-x ctrl-e to edit the command in your choice of editor ($EDITOR).
Editing commands is not hard with a few keys. At least learn alt-b and alt-f to go a word back or forward. Often ctrl-left and ctrl-right will do the same thing easier (depends on your terminal). Ctrl-w deletes back to the previous space, alt-backspace and alt-d delete the previous and next word respectively. There are many more keys in the manual, but those cover most things.
userbinator
a day ago
So instead of just retyping the command (much less than 1s), I have to remember to open the editor, and then think of how to edit it, and then execute those steps? Hell no. At that point I'll have long lost my original train of thought. The original command, and at least the subsequent one, are already in my mind and can be output immediately. Any deviations from that plan are going to be much slower.
ctrl-x ctrl-e
Just thinking about that almost makes my fingers hurt. A chorded sequence of two keys, same side of the keyboard, nearly in a vertical line on the top and bottom row, is basically the slowest and most awkward possible combination to type.
db48x
17 hours ago
Only because you’re typing it incorrectly. Use both hands. One presses the modifier, the other types the letter. That's why you have modifiers on both sides! C-x means to use your right hand to hold down control, while using your left to type the x.
userbinator
23 minutes ago
X E is still a terribly slow sequence to type.
vrighter
11 hours ago
this is overkill and way slower for most short commands. And you still need to scroll to wherever you need to edit. doesn't save anything, really.
_doctor_love
a day ago
Great advice. On the Mac, make sure to set up Alt/Option as "meta key".
Retr0id
2 days ago
"sudo !!" is quite firmly burnt into my muscle memory, but the whole rest of the time when I type an exclamation mark I mean it literally, and I get annoyed when it turns into a syntax error of some variety.
moring
2 days ago
Worse, the "press up-arrow to get the previous command, then fix the errors in it" flow is broken when an exclamation mark causes a syntax error.
zcw100
2 days ago
I like to alias it to "please"
Fnoord
a day ago
Oh, nice.
I alias'ed it to please as well. But because I use fish, I had to do this: alias please 'sudo (history -1)'
adityaathalye
2 days ago
As an Emacs using degenerate, `M-.` is my friend. `!` is too awkward on the keyboard.
pcblues
2 days ago
I guess you could map it to the right-hand M key?
adityaathalye
a day ago
Not while I've my keys mapped as the Lords of Lisp intended. Thumbs are always on the `Ctrl`s... https://en.wikipedia.org/wiki/Space-cadet_keyboard
squigz
2 days ago
As someone who can type rather quickly, I disagree. It can take some time to internalize, but once you do, it's much faster.
Same with Ctrl-C - once I got used to navigating by word instead of by character to correct things, it became much faster than starting over.