I am interacting with the #Shell for perhaps as much as 50 or 60% of the day. A lot of my interactions are repeating previous commands sometimes with small changes. I have lots of conveniences set up to make this easier ( #Vi mode, opening a previous command or list of commands in the #HelixEditor with `fc`, an alias for `history | grep`, etc., and also lots of configuration for the history facility ) but perhaps the thing I use most is the arrow keys. For so many other people, their favorite tool here is Ctrl-R. I’ve never made that a major part of my toolset.
In #Bash, I used this:
```bash
bind '"\t":menu-complete'
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
```
What that does is: you type something, then up-arrow steps you through all and only the previous commands that start with that exact prefix. My initial translation of this into #Zsh sorta worked but I soon realized it didn’t do the right thing. I’m not a Zsh expert yet. Here’s what actually works:
```zsh
# Load the functions I will use with the up and down arrows. Yes, this is more work than Bash.
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
# Create the matching zle widgets. That's what let's me use them with bindkey.
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# Bind to arrow keys
bindkey '^[[A' up-line-or-beginning-search # Up arrow
bindkey '^[[B' down-line-or-beginning-search # Down arrow
# But lets keep tab-completion as well.
bindkey '^I' menu-complete
```
Zsh is more complicated, but only because it’s more flexible.
By the way, I use `fzf` a lot. I was very pleasantly surprised to see Zsh automatically leveraged that, if available, in Ctrl-R.