3 ms·
It's perfectly reasonable. There is already an interface for recalling previous commands, and an interface for editing the command line. Combining them to issue
by Camillo 14y ago
It's perfectly reasonable. There is already an interface for recalling previous commands, and an interface for editing the command line. Combining them to issue a variation of a previous command is the logical thing to do. Having a completely wacky alternate syntax for the specific operation of "put the whole previous command in this place surrounded by new text" is a wart. It's like the irregular English syntax that you hate so much, except that in this case there's still time to fix it, because bash hasn't been around that long.
- GhotiFish 14y agoPerfect! I love regular syntax! For example, Lojban uses a method of saying phonemes to describe words, like Hebrew, so the number 100,508,290 is just an utterance rather than a sentence. panono k'io munobi k'io resono Rather than One hundred million, five hundred and eight thousand, two hundred and ninety. consistent, simple, fast, unambiguous. numbers are a common occurrence, so they should be fast to speak, So when the extremely common occurrence of me forgetting to include sudo for a command that requires escalated privileges, I expect that task made easier. As an alternative, think of it like this. the specific operation of "put the whole previous command in this place surrounded by new text" is actually a common idiom in calculation programs. Commonly called "ans". Mathmatica actually marks the results of all its computations with a tag (I think t[n]) so you can recall arbitrarily. That's not to say I'm a stick in the mud, if "sudo !!" sucks, make it better! How about something that turns a command into a postfix command? Or actually having a hotkey recall the previous command? Maybe a hotkey that looks at the text in the argument then searches up the history to replace? so if I type sudo rm^U it takes 'rm' and searches up history, replacing it with the first match, "sudo rm -rf ~/opt/java"? Lots of possibilities!
- Camillo 14y agoHow about you just press up arrow to recall the previous command, ctrl-A to go to the beginning of the line, and then type "sudo "? It's the same number of keystrokes as typing "sudo !!". And I'm sure you can use something other than up arrow to recall the previous command if you don't want to take your fingers off the home row.
- GhotiFish 14y agothe reasons are legion. Up and ctrl A are independent key strokes. They precede typing sudo, which is a logical train of thought ("Oh I forgot sudo, i should of typed sudo and then x"). ! is a commonly used key in English language, and pressing it twice is fast, where as getting two desperate keys is not. After the proposed action, you end up here: sudo |something fishy as opposed to here: sudo something fishy| which prevents you from writing an addendum to that command. This sounds small, but I was doing what you suggested before I found out I could say "sudo !!" I immediately switched when I found out, and it's now a very common idiom for me. I switched from "up home sudo space" to "sudo space bang bang" for all the reasons described above.