Comment by alberto-m
10 hours ago
One thing I find life-changing is to remap the up arrow so that it does not iterates through all commands, but only those starting with the characters I have already written. So e.g. I can type `tar -`, then the up arrow, and get the tar parameters that worked last time.
In zsh this is configured with
bindkey "^[OA" up-line-or-beginning-search # Up
bindkey "^[OB" down-line-or-beginning-search # Down
Once you start using CTRL+r, you may find that you never reach for up arrow again.
I'm familiar with ctrl-r, but I still very much like the up-arrow behavior described by that commenter.
Looking at it from a "law of least surprise" angle, it's exactly how it should behave.
"I typed 'cd di↑' and you're giving me 'pwd'??"
There is a difference, I believe. Doesn't Ctrl+r do a substring search instead?
Yes it's different: it will match anywhere in the previous command lines.
Prefix search is faster for the majority of cases. CTRL-r / FZF is useful for the remaining ones.
And once you want to one-up this look into fzf.
And once you get tired of fzf and want something better, you reach for https://atuin.sh.
Completely transformed all of my workflows
7 replies →
export EDITOR=vi and then hitting Esc puts you into vi mode; k, j to move up/down through history or pressing / to search etc including using regex is all available.
I agree it's a game changer! For bash to do the same I put this in my .inputrc:
This is the default `fish` shell behavior. Type anything, up/down keys to iterate through full commands that containing the term; alt + up/down to iterate through args containing the term.
Fish is underrated
This can also be achieved with `.inputrc`:
Thank you !
I do something similar. I leave up and down arrows alone, but have ctrl+p and ctrl+n behave as you describe.
Heh. I've done this since forever, but I use PgUp and PgDn so I can retain the original meaning of the up arrow key.
When I was on ubuntu it was easy to uncomment a couple lines in /etc/inputrc for this
Did this many years ago (but with bash) -- life changing is an apt way of saying it.
Here's the Bash commands for this in case anyone is looking for them
Atuin is better than anything I’ve used in a shell.
> life-changing
For further life-changing experience... add aliases to .bash_aliases
I've got many like these I copied from various people over the years.
One I came up and that I use all the time:
I use it so much I sometimes forget it's not stock.
That's a nice one.
One thing I do is configure my keyboard so that "modifier+{ijkl}" mimicks the inverted T arrows key cluster. So there's never a need for me to reach for the arrow keys. And {ijk} makes more sense than vi's {hjkl} and is faster/more logical/less key fingers travel. The nice thing is: as I do this at the keyboard level, this works in every single map. "modifier" in my case is "an easily reachable key in a natural hand position on which my left thumb is always resting" but YMMV.
I set that up years ago and it works in every app: it's gorgeous. Heck, I'm using it while editing this very message for example.
And of course it composes with SHIFT too: it's basically arrow keys, except at the fingers' natural positions.