4 ms·
>by far the most useful shortcut for me is Ctrl-r I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those start
by asicsp 4y ago
>by far the most useful shortcut for me is Ctrl-r
I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc`
"\e[A": history-search-backward
"\e[B": history-search-forward
- kleiba 4y agoThat's useful, but C-r has its merits too, as you can search for any string in the history. So, even if you run, say, python programs all day, here's a way to find that one time you used a different command line parameter... etc.
- heleninboodler 4y agoa really cool hack I found in an HN thread long ago was to stick "hashtags" (aka bash end-of-line comments) at the ends of commands you want to find in your history quickly: sudo systemctl restart myservice #bounce and then ctrl-r and type your hashtag to get right to it
- mrzool 4y agoThat’s a good one.
- jbaber 4y agoThis is now the HN thread in which I found this really cool hack. Thank you.
- heleninboodler 4y agoI'm officially naming these "bashtags".
- rcoveson 4y agoI don't want to discount how valuable this may be to you. However, for the average sysadmin, or developer who spends time in shells on many different machines, I would gently suggest that this is not a good idea. It's not a significant enough improvement over the way it works out-of-the-box to merit both (1) not getting used to Ctrl-r and (2) getting used to a different behavior for the arrow keys. Just my opinion, of course.
- JelteF 4y agoIf you're the sysadmin, then chances are high you can add this to the base image of all the systems you regularly touch.
- nine_k 4y agoMany of my commands start identically but continue and end differently. Here C-r (or ^R if you prefer) is the most convenient. Sending a looong command to your editor for modification via C-x C-e is also convenient sometimes.
- asicsp 4y ago>Many of my commands start identically but continue and end differently. Here C-r (or ^R if you prefer) is the most convenient. Not sure if I understood this correctly. You can use up/down arrow multiple times, just like Ctrl-r/s - so it is a huge improvement for me.