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 # DownI agree it's a game changer! For bash to do the same I put this in my .inputrc:
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forwardThis 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.
This can also be achieved with `.inputrc`:
"\e[A": history-search-backward
"\e[B": history-search-forwardVery nice! Here's the full code for those that had, like me, a more minimalistic .zshrc:
```
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[OA" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
bindkey "^[[OB" down-line-or-beginning-search
```
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.
I do something similar. I leave up and down arrows alone, but have ctrl+p and ctrl+n behave as you describe.
I'd try this, but I often find that I want to repeat a cycle of two or more commands. Yes, I probably should edit and put them on one line with semicolons (or even make a function), but.
Did this many years ago (but with bash) -- life changing is an apt way of saying it.
> life-changing
For further life-changing experience... add aliases to .bash_aliases
alias gph='history | grep --colour -i '
alias gpc='grep --colour -Hin '
#if gnu time is installed
alias timef='/usr/bin/time -f "tm %E , cpu %P , mem %M" 'Atuin is better than anything I’ve used in a shell.
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.
Once you start using CTRL+r, you may find that you never reach for up arrow again.