4 ms·
I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometim
by senko 4y ago
I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search).
I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key).
Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (for example tailing a logfile).
- 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.
- patrickdavey 4y agoIf you don't already know about it: combining fzf with Ctrl-r is _amazingly good_ https://github.com/junegunn/fzf https://github.com/junegunn/fzf it's a fuzzy finder combined with reverse history search..
- danuker 4y agoI agree with you. What I have also done is increase the history size: https://eshlox.net/2017/08/01/bash-increase-command-history-size https://eshlox.net/2017/08/01/bash-increase-command-history-...
- chungy 4y ago> but it can be useful when you're outputting a lot of text (for example tailing a logfile). Use "tail +F" and press ^C when you need to pause at some line. Press F to resume tailing.
- Oxidation 4y agoA hacked up version of ci"/ca" is my favourite thing, something like this; set keymap vi-command "ci\"": "T\"ct\"" I don't think you can do bracket matching/counting, but, even so, ci( is also pretty handy.
- tcoff91 4y agoCtrl-r history search is made 1000x better with fzf fuzzy history search. https://github.com/junegunn/fzf https://github.com/junegunn/fzf