I never understood the utility of history substitution (I think this is what it's called). Why not just ctrl-r to see the actual command? Also, `sudo !!` thingy that is (was?) persistent in the internets for some reason, is probably the dumbest thing out there.
$!134 can be a nice bash foot shooter if you accidentally mistype the number
11–20 of 54 posts
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#12You need to enable magic-space: https://relentlesscoding.com/posts/bash-magic-space/ # this will automatically expand any variables and history when you hit the spacebar after them, so you can eyeball before running. Someone tell me what the zsh equivalent is?
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#13Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#14I never understood the utility of history substitution (I think this is what it's called). Why not just ctrl-r to see the actual command? Also, `sudo !!` thingy that is (was?) persistent in the internets for some reason, is probably the dumbest thing out there.
`sudo !!` is just very useful, just as most other things you can do with history substitution. Ctrl-R has its own usefulness but it only does a fraction of what history substitution can do.
So you hit arrow up to bring up the last command, then [Alt]+[E] to sudo-ify it.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#15I don't use the terminal often, but when I do, the feeling of sheer power and control over the system is palpable. I'm a fast and nervous typer, so I always try to slow down and notice all the ways I could lose data, and how easy it would be to make such mistakes (eg. how many mistyped letters away from wiping my database am I?). Over time, I got better at noticing danger areas. Whenever I use 'rm', I re-read the com…
rm () {
mv "$@" ~/.trash
}
So any time I use rm, it actually just moves it to ~/.trash instead. Not fool-proof nor perfect, but have saved me at least once so found it to be good enough for now.Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#16Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#17I never understood the utility of history substitution (I think this is what it's called). Why not just ctrl-r to see the actual command? Also, `sudo !!` thingy that is (was?) persistent in the internets for some reason, is probably the dumbest thing out there.
$!(some number) instead is quite insane and much more likely to have unwanted effects due to (potential) lack of context.
Don't conflate the two.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#18Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#19Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#20Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
Can you navigate C-r history, or are you forced to see only the last command?