3 ms·
When dealing with bash history, I find that too many people are still unaware of C-r (Ctrl+R or Command+R): press it and start typing unique bits of your past c
by necovek 3y ago
When dealing with bash history, I find that too many people are still unaware of C-r (Ctrl+R or Command+R): press it and start typing unique bits of your past commands. If multiple commands match, cycle through them with repeated C-r presses.
The usual reaction is :mindblown: :)
- NikkiA 3y agoThat would be the emacs style key mappings, specifically mirroring isearch-backwards. I have no idea what the vim mapping for that would be.
- avidiax 3y agoAnd even more don't know how great FZF (Fuzzy Finder) is. When properly setup, Ctrl-R now shows a fuzzy search of your command history.
- mingus88 3y agothis feature has pretty much eliminated the use of aliases for me. So efficient No longer do I need obscure abbreviated aliases for my common commands I just type ctrl-r and enough characters of the command I need until the one I need bubbles up
- CamJN 3y agoIt’s control+r on macOS too, one of the nicest things about macOS is that command and control are separate so they don’t interfere. So for example control+c in Terminal.app sends SIGINT, and command+c copies and there’s no ambiguity.
- necovek 3y agoThanks for the correction for Mac! But honestly, one of the *worst* things about Macs is that Command and Control are separate, and there are no good keys to remap them to (there is only one Caps Lock), so you have to contort your fingers for an oft used combination.
- gxonatano 3y agoBut if you have autocomplete suggestions enabled in your modern shell (Zsh, Fish, Nushell), you don't even have to press C-r. Just type and it'll complete for you.
- necovek 3y agoEven ignoring that those might not be built-in (at least for zsh), I can't imagine this matching unique part in the middle of a command from history without explicit action (that would be terrible UX). And when you have multiple similar commands in your history that only differ somewhere in the middle, you don't want completion, you want searching.
- gxonatano 3y agoFor those cases you can type until it autocompletes one of those commands, then press the up arrow key to cycle through the variations of that match. I don't know about zsh, but it's the default for fish and nushell.
- necovek 3y agoThe example I have top of mind is something like aws codeartifact login --tool pip ... and aws codeartifact login --tool npm ... I can simply do "C-r pip" to get to the first and "C-r npm" to get to the second (or cycle through any other matches, or if I frequently had a few, maybe do "C-r tool npm"): your suggestion sounds much worse in comparison.