4 ms·
> select commands and data iteratively ... Emacs is way better in that sense Bind up/down to history-search-backward/history-search-forward. In ~/.inputrc
by pdkl95 8y ago
> select commands and data iteratively ... Emacs is way better in that sense
Bind up/down to history-search-backward/history-search-forward. In ~/.inputrc
# your terminal might send something else for the
# for the up/down keys; check with ^v<key>
# UP
"\e[A": history-search-backward
# DOWN
"\e[B": history-search-forward
(note that this affects anything that uses readline, not just bash)
The default (previous-history/next-history) only step through history one item at a time. The history-search- commands step through only the history entries that match the prefix you have already typed. (i.e. typing "cp<UP>" gets the last "cp ..." command; continuing to press <UP> steps through all of the "cp ..." commands in ${HISTFILE}). As your history file grows, this ends up kind of like smex[1] (ido-mode for M-x that prefers recently and most frequently used commands).
For maximum effect, you might want to also significantly increase the size of the saved history:
# no file size limit
HISTFILESIZE="-1"
# runtime limit of commands in history. default is 500!
HISTSIZE="1000000"
# ignoredups to make the searching more efficient
HISTCONTROL="ignorespace:ignoredups"
# (and make sure HISTFILE is set to something sane)
[1] https://github.com/nonsequitur/smex/ https://github.com/nonsequitur/smex/
- SomethingOrNot 8y agoBoth terminals, shells and Emacs suffer from the problem that you have to configure them out of their ancient defaults.
- gknoy 8y agoI also like setting my history so that it appends to the history file after each command, so that they don't get clobbered when you have two shells open: shopt -s histappend export PROMPT_COMAND="history -a"