3 ms·
Agreed, but even nicer than control-r are the readline functions `history-search-backward` and `history-search-forward`. Personally I bind them to up/down whic
by Myrmornis 10y ago
Agreed, but even nicer than control-r are the readline functions `history-search-backward` and `history-search-forward`.
Personally I bind them to up/down which on OS X at least involves:
# Put this in some file like ~/.readline-bindings
"\e[A": history-search-backward
"\e[B": history-search-forward
# And this in your ~/.bashrc or ~/.zshrc
bind -f ~/.readline-bindings
That way if you haven't typed any input it behaves like normal up (previous command), but if you've typed some characters it only retrieves matching commands.
http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/ http://codeinthehole.com/writing/the-most-important-command-...
- musicmatze 10y agoIs there a way to make this work with `set -o vi`? So I can use j/k to browse the history this way?
- deleted 10y ago[deleted]
- lolive 10y agoMapping these to Up/Down arrows (instead of PgUp-PdDn) is the best idea EVER !!!
- devnonymous 10y agoJust curious since I don't use a mac, doesn't writing the mappings to .inputrc work? IIRC, putting your readline bindings there makes it available for all readline enabled prompts, not just bash ie: Python, pgsql, mysql,.. Etc
- Myrmornis 10y agoYes I think that's a better approach, thanks. I don't know why I started using `bind` in my shell config.
- deleted 10y ago[deleted]