$!134 can be a nice bash foot shooter if you accidentally mistype the number
31–40 of 54 posts
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#32I 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…
Regarding `rm`, I usually have something like this setup in my bashrc/zshrc: 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
#33Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#34I 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…
Regarding `rm`, I usually have something like this setup in my bashrc/zshrc: 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
#35Earlier quoted context omitted.
> Maybe it'd be best to just give this command a new name like `delete` or `trash` just to be safe. But this would defeat the original purpose, i.e. the prevention of someone accidentally using rm.
If you get used to using a different command, you won't use `rm` accidentally
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#36Earlier quoted context omitted.
> Maybe it'd be best to just give this command a new name like `delete` or `trash` just to be safe. But this would defeat the original purpose, i.e. the prevention of someone accidentally using rm.
Not necessarily. If you get used to using `delete` all the time, that is most likely what you would use on the server too. Once you trip over it missing, you are reminded that you are in dangerous territory.
That said, an accidental removal of files has never been a problem for me (an accidental chmod -R caused me more woes once), and these days with snapshots it's a complete non issue.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#37Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
By COMMENTING your commands:
$ grep -i myname /etc/passwd # passgrep
.. ..
$ Ctrl-R "passgr"
It is so rewarding to do some intense bash work with liberal command line comments and then come back a few weeks later, "history | grep \#", and see my work notes - along with the relevant commands - available.
I used to write '~/bin' scripts for special stuff, including comments in the .sh source itself - but now it just makes more sense to wang a comment at the end of the complex/interesting commands and then just grep for the comment later ..
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#38Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
I do this too, but you know what is an even cooler and more rewarding way to exploit the shell history? By COMMENTING your commands: $ grep -i myname /etc/passwd # passgrep .. .. $ Ctrl-R "passgr" It is so rewarding to do some intense bash work with liberal command line comments and then come back a few weeks later, "history | grep \#", and see my work notes - along with the relevant commands - available. I used to w…
For commands that I reuse semi-frequently I set an environment variable so that I can easily find them with prefix searching. So for example I sometimes pin IPFS paths to Infura so I have this command in my history. I can then type pin= and recall that command (until it drops off the end of my shell history).
pin= r curl -fiXPOST "https://ipfs.infura.io:5001/api/v0/pin/add?recursive=true&arg=$(c)"Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#39I 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.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#40Earlier quoted context omitted.
I do this too, but you know what is an even cooler and more rewarding way to exploit the shell history? By COMMENTING your commands: $ grep -i myname /etc/passwd # passgrep .. .. $ Ctrl-R "passgr" It is so rewarding to do some intense bash work with liberal command line comments and then come back a few weeks later, "history | grep \#", and see my work notes - along with the relevant commands - available. I used to w…
I have a similar system but take advantage of prefix-search rather than Ctrl+r For commands that I reuse semi-frequently I set an environment variable so that I can easily find them with prefix searching. So for example I sometimes pin IPFS paths to Infura so I have this command in my history. I can then type pin= and recall that command (until it drops off the end of my shell history). pin= r curl -fiXPOST "https://…