Earlier quoted context omitted.
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://…
Useful, but dangerous! I would have to check if there is already an environment variable in use before I did that ..
$!134 can be a nice bash foot shooter if you accidentally mistype the number
41–50 of 54 posts
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#42Earlier quoted context omitted.
Useful, but dangerous! I would have to check if there is already an environment variable in use before I did that ..
I know this command doesn't depend on a lowercase `pin` variable so there is no danger. Note that this doesn't change the variable in the shell, just the executed command.
Cute trick though, will work it into my workflow and see how it feels.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#43Earlier quoted context omitted.
I know this command doesn't depend on a lowercase `pin` variable so there is no danger. Note that this doesn't change the variable in the shell, just the executed command.
Yeah, its the 'knowing beforehand' part that makes this dangerous for me. ;) Cute trick though, will work it into my workflow and see how it feels.
But I guess everyone has a different risk level and what feels near-zero to me is meaningful to someone else.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#44Earlier quoted context omitted.
If you get used to using a different command, you won't use `rm` accidentally
Sure, but in the context of the present thread I'd have to wait until the history file gets rotated - which will never happen on the systems I manage.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#45I have trained myself, over many years, to hit space automatically before I type rm/reboot/shutdown etc. It's occasionally inconvenient if I need to rerun something but does mean I can't fat-finger anything destructive!
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#46Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#47Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#48Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
https://github.com/cantino/mcfly Life changer
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#49Fortunately my memory was never good enough for me to use that facility. C-r is how I always lookup earlier commands.
I always add "\e[A": history-search-backward "\e[B": history-search-forward to my .inputrc, I find it easier to use than C-r as it's some sort of autocomplete from history. But looking up commands with !number can still be very useful when you don't remember the command you need but remember when you used it (e.g. what commands you ran before and after).
I usually do `history | grep ...` to find the command and then use it.
Non-emacs users might tend to find this surprising, but in a shell buffer you can move around with your cursor like in a text file, so after executing `history` you can search for the command as string then copy-paste it.
Re: $!134 can be a nice bash foot shooter if you accidentally mistype the number
#50If your are on a production server, it's more like a Russian roulette rather than lottery.
If you don't like your job there's also the Polish variant, where you take one bullet out of every six.